Skip to content

Commit

Permalink
Extract closure for trait ref filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldhsu committed Jul 11, 2022
1 parent a5df0a3 commit a0c2da9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions clippy_lints/src/trait_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,16 @@ fn into_comparable_trait_ref(trait_ref: &TraitRef<'_>) -> ComparableTraitRef {
fn rollup_traits(cx: &LateContext<'_>, bounds: &[GenericBound<'_>], msg: &str) {
let mut map = FxHashMap::default();
let mut repeated_res = false;
for bound in bounds.iter().filter_map(|bound| {

let only_comparable_trait_refs = |bound: &GenericBound<'_>| {
if let GenericBound::Trait(t, _) = bound {
Some((into_comparable_trait_ref(&t.trait_ref), t.span))
} else {
None
}
}) {
};

for bound in bounds.iter().filter_map(only_comparable_trait_refs) {
let (comparable_bound, span_direct) = bound;
if map.insert(comparable_bound, span_direct).is_some() {
repeated_res = true;
Expand Down

0 comments on commit a0c2da9

Please sign in to comment.