Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadow_unrelated triggers on destructuring #13795

Closed
purplesyringa opened this issue Dec 8, 2024 · 0 comments · Fixed by #13797
Closed

shadow_unrelated triggers on destructuring #13795

purplesyringa opened this issue Dec 8, 2024 · 0 comments · Fixed by #13797
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@purplesyringa
Copy link

Summary

let Struct { value, .. } = value;

triggers shadow_unrelated.

Lint Name

shadow_unrelated

Reproducer

I tried this code:

#![warn(clippy::shadow_unrelated)]

struct Struct {
    value: i32,
}

fn f(value: Struct) {
    let Struct { value, .. } = value;
}

I saw this happen:

warning: `value` shadows a previous, unrelated binding
 --> src/lib.rs:8:18
  |
8 |     let Struct { value, .. } = value;
  |                  ^^^^^
  |
note: previous binding is here
 --> src/lib.rs:7:6
  |
7 | fn f(value: Struct) {
  |      ^^^^^

I expected to see this happen:

No warning.

Version

rustc 1.84.0-nightly (1e4f10ba6 2024-10-29)
binary: rustc
commit-hash: 1e4f10ba6476e48a42a79b9f846a2d9366525b9e
commit-date: 2024-10-29
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Additional Labels

No response

@purplesyringa purplesyringa added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Dec 8, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 11, 2024
Fix #13795

changelog: [`shadow_same`]: detect shadowing as a pattern field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant