File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -174,15 +174,11 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
174
174
if let TyKind :: TraitObject ( bounds, ..) = mut_ty. ty. kind;
175
175
if bounds. len( ) > 2 ;
176
176
then {
177
- let mut bounds_span = bounds[ 0 ] . span;
178
-
179
- for bound in bounds. iter( ) . skip( 1 ) {
180
- bounds_span = bounds_span. to( bound. span) ;
181
- }
182
-
183
177
let mut seen_def_ids = FxHashSet :: default ( ) ;
184
178
let mut fixed_traits = Vec :: new( ) ;
185
179
180
+ // Iterate the bounds and add them to our seen hash
181
+ // If we haven't yet seen it, add it to the fixed traits
186
182
for bound in bounds. iter( ) {
187
183
let Some ( def_id) = bound. trait_ref. trait_def_id( ) else { continue ; } ;
188
184
@@ -193,7 +189,15 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
193
189
}
194
190
}
195
191
192
+ // If the number added to fixed (which are not duplicates) isn't the same as the number found,
193
+ // there must be 1 or more duplicates
196
194
if bounds. len( ) != fixed_traits. len( ) {
195
+ let mut bounds_span = bounds[ 0 ] . span;
196
+
197
+ for bound in bounds. iter( ) . skip( 1 ) {
198
+ bounds_span = bounds_span. to( bound. span) ;
199
+ }
200
+
197
201
let fixed_trait_snippet = fixed_traits
198
202
. iter( )
199
203
. filter_map( |b| snippet_opt( cx, b. span) )
You can’t perform that action at this time.
0 commit comments