You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
constfnbar() -> Result<(),Error>{Ok(())}pubfnfoo() -> 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
Re-write shadow lints
changelog: Move shadow_unrelated to restriction
changelog: The shadow lints find a lot more shadows and are not limited to certain patterns
Drastically simplifies the implementation. Catches a lot more cases.
I removed the "initialization happens here" note. It is not helpful IMO.
Closes#318Fixes#2890Fixes#6563Fixes#7588Fixes#7620
When I name a variable
val
, next fn call with?
producesshadow_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_valI tried this code:
I expected to see this happen: no warnings
Instead, this happened:
Meta
cargo clippy -V
: clippy 0.1.53 (53cb7b0 2021-06-17)rustc -Vv
:The text was updated successfully, but these errors were encountered: