mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-18 23:18:55 +00:00
Comments
This commit is contained in:
parent
122793b494
commit
5c8a00923b
1 changed files with 10 additions and 6 deletions
|
@ -174,15 +174,11 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
||||||
if let TyKind::TraitObject(bounds, ..) = mut_ty.ty.kind;
|
if let TyKind::TraitObject(bounds, ..) = mut_ty.ty.kind;
|
||||||
if bounds.len() > 2;
|
if bounds.len() > 2;
|
||||||
then {
|
then {
|
||||||
let mut bounds_span = bounds[0].span;
|
|
||||||
|
|
||||||
for bound in bounds.iter().skip(1) {
|
|
||||||
bounds_span = bounds_span.to(bound.span);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut seen_def_ids = FxHashSet::default();
|
let mut seen_def_ids = FxHashSet::default();
|
||||||
let mut fixed_traits = Vec::new();
|
let mut fixed_traits = Vec::new();
|
||||||
|
|
||||||
|
// Iterate the bounds and add them to our seen hash
|
||||||
|
// If we haven't yet seen it, add it to the fixed traits
|
||||||
for bound in bounds.iter() {
|
for bound in bounds.iter() {
|
||||||
let Some(def_id) = bound.trait_ref.trait_def_id() else { continue; };
|
let Some(def_id) = bound.trait_ref.trait_def_id() else { continue; };
|
||||||
|
|
||||||
|
@ -193,7 +189,15 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the number added to fixed (which are not duplicates) isn't the same as the number found,
|
||||||
|
// there must be 1 or more duplicates
|
||||||
if bounds.len() != fixed_traits.len() {
|
if bounds.len() != fixed_traits.len() {
|
||||||
|
let mut bounds_span = bounds[0].span;
|
||||||
|
|
||||||
|
for bound in bounds.iter().skip(1) {
|
||||||
|
bounds_span = bounds_span.to(bound.span);
|
||||||
|
}
|
||||||
|
|
||||||
let fixed_trait_snippet = fixed_traits
|
let fixed_trait_snippet = fixed_traits
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|b| snippet_opt(cx, b.span))
|
.filter_map(|b| snippet_opt(cx, b.span))
|
||||||
|
|
Loading…
Add table
Reference in a new issue