File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 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 {
174174 if let TyKind :: TraitObject ( bounds, ..) = mut_ty. ty. kind;
175175 if bounds. len( ) > 2 ;
176176 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-
183177 let mut seen_def_ids = FxHashSet :: default ( ) ;
184178 let mut fixed_traits = Vec :: new( ) ;
185179
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
186182 for bound in bounds. iter( ) {
187183 let Some ( def_id) = bound. trait_ref. trait_def_id( ) else { continue ; } ;
188184
@@ -193,7 +189,15 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
193189 }
194190 }
195191
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
196194 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+
197201 let fixed_trait_snippet = fixed_traits
198202 . iter( )
199203 . filter_map( |b| snippet_opt( cx, b. span) )
You can’t perform that action at this time.
0 commit comments