Detect shadowing in pattern field (#13797)

Fix #13795

changelog: [`shadow_same`]: detect shadowing as a pattern field
This commit is contained in:
Jason Newcomb 2024-12-11 02:17:28 +00:00 committed by GitHub
commit c2d23ad0df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 2 deletions

View file

@ -133,4 +133,12 @@ fn shadow_closure() {
.collect();
}
struct Issue13795 {
value: i32,
}
fn issue13795(value: Issue13795) {
let Issue13795 { value, .. } = value;
}
fn main() {}

View file

@ -304,5 +304,17 @@ note: previous binding is here
LL | .map(|i| i.map(|i| i - 10))
| ^
error: aborting due to 25 previous errors
error: `value` is shadowed by itself in `value`
--> tests/ui/shadow.rs:141:22
|
LL | let Issue13795 { value, .. } = value;
| ^^^^^
|
note: previous binding is here
--> tests/ui/shadow.rs:140:15
|
LL | fn issue13795(value: Issue13795) {
| ^^^^^
error: aborting due to 26 previous errors