Skip to content

Commit

Permalink
Use new filter map heuristic in clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Dec 14, 2020
1 parent 46aca65 commit bc1af63
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion clippy_lints/src/multiple_crate_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ impl LateLintPass<'_> for MultipleCrateVersions {
if let Some(resolve) = &metadata.resolve;
if let Some(local_id) = packages
.iter()
.find_map(|p| if p.name == *local_name { Some(&p.id) } else { None });
.find(|p| p.name == *local_name)
.map(|p| &p.id);
then {
for (name, group) in &packages.iter().group_by(|p| p.name.clone()) {
let group: Vec<&Package> = group.collect();
Expand Down
4 changes: 1 addition & 3 deletions clippy_lints/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ fn check_pat<'tcx>(
if let ExprKind::Struct(_, ref efields, _) = init_struct.kind {
for field in pfields {
let name = field.ident.name;
let efield = efields
.iter()
.find_map(|f| if f.ident.name == name { Some(&*f.expr) } else { None });
let efield = efields.iter().find(|f| f.ident.name == name).map(|f| f.expr);
check_pat(cx, &field.pat, efield, span, bindings);
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/suspicious_operation_groupings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,5 @@ fn skip_index<A, Iter>(iter: Iter, index: usize) -> impl Iterator<Item = A>
where
Iter: Iterator<Item = A>,
{
iter.enumerate()
.filter_map(move |(i, a)| if i == index { None } else { Some(a) })
iter.enumerate().filter(move |&(i, _)| i != index).map(|(_, a)| a)
}

0 comments on commit bc1af63

Please sign in to comment.