diff options
| author | Sosthène Guédon <sosthene@guedon.gdn> | 2022-11-01 19:31:47 +0100 |
|---|---|---|
| committer | Sosthène Guédon <sosthene@guedon.gdn> | 2022-11-20 13:45:12 +0100 |
| commit | 81d459083499c35700f3d7fa2b28cdae2f35a636 (patch) | |
| tree | 3ef860f4404c58c1b83b730a37e1f9755b6f4ebe | |
| parent | ddc49966dc4552b77582cf7e5aace8ac97d736fc (diff) | |
| download | rust-81d459083499c35700f3d7fa2b28cdae2f35a636.tar.gz rust-81d459083499c35700f3d7fa2b28cdae2f35a636.zip | |
missnamed_getters: use all_fields iterator
| -rw-r--r-- | clippy_lints/src/functions/missnamed_getters.rs | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/clippy_lints/src/functions/missnamed_getters.rs b/clippy_lints/src/functions/missnamed_getters.rs index 60922fb4ea4..306dccdbd48 100644 --- a/clippy_lints/src/functions/missnamed_getters.rs +++ b/clippy_lints/src/functions/missnamed_getters.rs @@ -83,24 +83,9 @@ pub fn check_fn( } }; - let variants = def.variants(); - - // We're accessing a field, so it should be an union or a struct and have one and only one variant - if variants.len() != 1 { - if cfg!(debug_assertions) { - panic!("Struct or union expected to have only one variant"); - } else { - // Don't ICE when possible - return; - } - } - - let first = variants.last().unwrap(); - let fields = &variants[first]; - let mut used_field = None; let mut correct_field = None; - for f in &fields.fields { + for f in def.all_fields() { if f.name.as_str() == name { correct_field = Some(f); } |
