Skip to content

shadow_unrelated does not register a variable being shadowed #7620

@nemqe

Description

@nemqe

I accidentally shadowed a variable without knowing and the linter did not warn me about that. Not a huge deal but just wanted to report the issue.

Lint name:
shadow_unrelated

I tried this code:

let s = "&str";
println!("{}", s);

let s = String::from("String");
println!("{}", s);

let x = 1;
println!("{}", x);

let x = "2".parse::<i32>().unwrap();
println!("{}", x);

I expected to see this happen: Warning shown about variables s and x being shadowed when running cargo clippy -- -W clippy::shadow_reuse -W clippy::shadow_same -W clippy::shadow_unrelated.

Instead, this happened: No warning for variable s was shown.

Meta

Rust version (rustc -Vv):

rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-unknown-linux-gnu
release: 1.54.0
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions