Skip to content

The suggestion of let_unit_value is invalid when the value is used in formatted in print #15061

Open
@ViggoC

Description

@ViggoC

Description

let res = returns_unit();
returns_result(res).unwrap();
println!("The result is {res:?}");

The suggestion of above code is

help: omit the `let` binding and replace variable usages with `()`
   |
22 ~     returns_unit();
23 ~     returns_result(()).unwrap();
24 ~     println!("The result is {():?}");

But println!("The result is {():?}"); is not valid.

Version

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: aarch64-apple-darwin
release: 1.86.0
LLVM version: 19.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions