Skip to content

let_unit_value should be allowed when I explicitly write "let () = ..." #9048

Closed
@safinaskar

Description

@safinaskar

Summary

Sometimes I write code like this: let () = some_function_call(). I do this to make sure that this function returns unit value, i. e. to make sure that I didn't miss any return value. But let_unit_value warns on this code. So, please, make it not to warn on this code

Lint Name

let_unit_value

Reproducer

I tried this code:

fn main() {
    let mut v = vec![2, 1];
    let () = v.sort();
}

I saw this happen:

    Checking playground v0.0.1 (/playground)
warning: this let-binding has unit value
 --> src/main.rs:3:5
  |
3 |     let () = v.sort();
  |     ^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `v.sort();`
  |
  = note: `#[warn(clippy::let_unit_value)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value

warning: `playground` (bin "playground") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s

I expected to see this happen:
(no warn)

Version

Version from https://play.rust-lang.org/ as on today (2022-06-25)

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions