Skip to content

Commit

Permalink
remove first outer iteration and unnecessary variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jonboh committed Sep 27, 2023
1 parent 4b4531f commit 430f8ae
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions clippy_lints/src/item_name_repetitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -435,8 +429,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),
Expand Down

0 comments on commit 430f8ae

Please sign in to comment.