From 32caf586f3245ec6423f51f8540a693afe805bb0 Mon Sep 17 00:00:00 2001 From: jonboh Date: Wed, 27 Sep 2023 19:24:21 +0200 Subject: [PATCH] remove first outer iteration and unnecessary variable --- clippy_lints/src/item_name_repetitions.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/clippy_lints/src/item_name_repetitions.rs b/clippy_lints/src/item_name_repetitions.rs index 0f18349f8152..65d939d83149 100644 --- a/clippy_lints/src/item_name_repetitions.rs +++ b/clippy_lints/src/item_name_repetitions.rs @@ -209,19 +209,13 @@ fn check_fields(cx: &LateContext<'_>, threshold: u64, fields: &[FieldDef<'_>], i } } - let mut pre = match fields.get(0) { - Some(first_field) => { - let words: Vec<&str> = first_field.ident.name.as_str().split('_').collect(); - if words.len() == 1 { - return; - } - words - }, + let mut pre: Vec<&str> = match fields.get(0) { + Some(first_field) => first_field.ident.name.as_str().split('_').collect(), None => return, }; let mut post = pre.clone(); post.reverse(); - for field in fields.iter().skip(1) { + for field in fields { let field_split: Vec<&str> = field.ident.name.as_str().split('_').collect(); if field_split.len() == 1 { return; @@ -432,8 +426,6 @@ impl LateLintPass<'_> for ItemNameRepetitions { } } } - let item_name = item.ident.name.as_str(); - if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.owner_id.def_id)) { match item.kind { ItemKind::Enum(def, _) => check_variant(cx, self.threshold, &def, item_name, item.span),