Skip to content

let_unit_value suggestion replacing variable in println with unit #15494

@MolotovCherry

Description

@MolotovCherry

Summary

let_unit_value suggestion is turning a statement like println!("{a:?}); into println!("{():?});

Lint Name

let_unit_value

Reproducer

I tried this code:

let a = vec![1,2,3].resize(0, 5);
println!("{a:?}");

I saw this happen:

warning: this let-binding has unit value
 --> src/main.rs:4:1
  |
4 | let a = vec![1,2,3].resize(0, 5);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
  = note: `#[warn(clippy::let_unit_value)]` on by default
help: omit the `let` binding and replace variable usages with `()`
  |
4 + vec![1,2,3].resize(0, 5);
5 ~ println!("{():?}");
  |

I expected to see this happen:

warning: this let-binding has unit value
 --> src/main.rs:4:1
  |
4 | let a = vec![1,2,3].resize(0, 5);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
  = note: `#[warn(clippy::let_unit_value)]` on by default
help: omit the `let` binding and replace variable usages with `()`
  |
4 + vec![1,2,3].resize(0, 5);
5 ~ println!("{:?}", ());
  |

Version

1.89 stable rustc

0.1.89 (2025-08-04 29483883ee)

Additional Labels

@rustbot label: +I-suggestion-causes-error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedS-fixedStatus: Issues that got fixed, waiting to be closed as completed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions