Skip to content

manual_let_else produces wrong variable name #10171

Closed
@ericwu17

Description

@ericwu17

Description

Take the following line of code (which appears in the ui test for manual_let_else):

let v = if let Some(v_some) = g() { v_some } else { return };

which declares a new variable called v. If we run clippy on the following code, we get the suggestion to replace it with

if let Some(v_some) = g() { v_some } else { return };

which declares a new variable called v_some.

The suggestion should be:

-if let Some(v_some) = g() { v_some } else { return };
+if let Some(v) = g() { v_some } else { return };

Please correct me if I'm wrong, but it looks like we have unit tests that are generating the wrong output.

Version

rustc 1.68.0-nightly (574b64a97 2022-12-31)
binary: rustc
commit-hash: 574b64a97f52162f965bc201e47f0af8279ca65d
commit-date: 2022-12-31
host: aarch64-apple-darwin
release: 1.68.0-nightly
LLVM version: 15.0.6

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions