Skip to content

Commit 32caf58

Browse files
committed
remove first outer iteration and unnecessary variable
1 parent 1cbf7ae commit 32caf58

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

clippy_lints/src/item_name_repetitions.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,13 @@ fn check_fields(cx: &LateContext<'_>, threshold: u64, fields: &[FieldDef<'_>], i
209209
}
210210
}
211211

212-
let mut pre = match fields.get(0) {
213-
Some(first_field) => {
214-
let words: Vec<&str> = first_field.ident.name.as_str().split('_').collect();
215-
if words.len() == 1 {
216-
return;
217-
}
218-
words
219-
},
212+
let mut pre: Vec<&str> = match fields.get(0) {
213+
Some(first_field) => first_field.ident.name.as_str().split('_').collect(),
220214
None => return,
221215
};
222216
let mut post = pre.clone();
223217
post.reverse();
224-
for field in fields.iter().skip(1) {
218+
for field in fields {
225219
let field_split: Vec<&str> = field.ident.name.as_str().split('_').collect();
226220
if field_split.len() == 1 {
227221
return;
@@ -432,8 +426,6 @@ impl LateLintPass<'_> for ItemNameRepetitions {
432426
}
433427
}
434428
}
435-
let item_name = item.ident.name.as_str();
436-
437429
if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.owner_id.def_id)) {
438430
match item.kind {
439431
ItemKind::Enum(def, _) => check_variant(cx, self.threshold, &def, item_name, item.span),

0 commit comments

Comments
 (0)