Skip to content

Commit 81d4590

Browse files
committed
missnamed_getters: use all_fields iterator
1 parent ddc4996 commit 81d4590

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

clippy_lints/src/functions/missnamed_getters.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,9 @@ pub fn check_fn(
8383
}
8484
};
8585

86-
let variants = def.variants();
87-
88-
// We're accessing a field, so it should be an union or a struct and have one and only one variant
89-
if variants.len() != 1 {
90-
if cfg!(debug_assertions) {
91-
panic!("Struct or union expected to have only one variant");
92-
} else {
93-
// Don't ICE when possible
94-
return;
95-
}
96-
}
97-
98-
let first = variants.last().unwrap();
99-
let fields = &variants[first];
100-
10186
let mut used_field = None;
10287
let mut correct_field = None;
103-
for f in &fields.fields {
88+
for f in def.all_fields() {
10489
if f.name.as_str() == name {
10590
correct_field = Some(f);
10691
}

0 commit comments

Comments
 (0)