From 81d459083499c35700f3d7fa2b28cdae2f35a636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Tue, 1 Nov 2022 19:31:47 +0100 Subject: [PATCH] missnamed_getters: use all_fields iterator --- clippy_lints/src/functions/missnamed_getters.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/clippy_lints/src/functions/missnamed_getters.rs b/clippy_lints/src/functions/missnamed_getters.rs index 60922fb4e..306dccdbd 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); }