- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.8k
 
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
When I name a variable val, next fn call with ? produces shadow_unrelated warning.
If I rename the variable, the warning disappears. Both on stable and nightly.
Reproducible with cargo clippy on this repo: https://github.com/romand/shadowed_val
I tried this code:
const fn bar() -> Result<(), Error> {
    Ok(())
}
pub fn foo() -> Result<(), Error> {
    let val = 1;
    bar()?;
    println!("{}", val);
    Ok(())
}I expected to see this happen: no warnings
Instead, this happened:
    Checking shadowed_val v0.1.0 (/home/romand/shadowed_val)
error: `bar()?` is being shadowed
  --> src/lib.rs:14:5
   |
14 |     bar()?;
   |     ^^^^^^
   |
   = note: `-D clippy::shadow-unrelated` implied by `-D warnings`
note: initialization happens here
  --> src/lib.rs:14:5
   |
14 |     bar()?;
   |     ^^^^^^
note: previous binding is here
  --> src/lib.rs:13:9
   |
13 |     let val = 1;
   |         ^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#shadow_unrelated
error: aborting due to previous error
error: could not compile `shadowed_val`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: `bar()?` is being shadowed
  --> src/lib.rs:14:5
   |
14 |     bar()?;
   |     ^^^^^^
   |
   = note: `-D clippy::shadow-unrelated` implied by `-D warnings`
note: initialization happens here
  --> src/lib.rs:14:5
   |
14 |     bar()?;
   |     ^^^^^^
note: previous binding is here
  --> src/lib.rs:13:9
   |
13 |     let val = 1;
   |         ^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#shadow_unrelated
error: aborting due to previous error
error: build failed
cargo-clippy exited abnormally with code 101 at Thu Aug 19 13:58:18
Meta
cargo clippy -V: clippy 0.1.53 (53cb7b0 2021-06-17)rustc -Vv:
rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing