@@ -11,6 +11,7 @@ use rustc_trait_selection::traits::check_args_compatible;
11
11
use std:: ops:: ControlFlow ;
12
12
13
13
use crate :: errors:: { DuplicateArg , NotParam } ;
14
+ use crate :: sig_types:: SpannedTypeVisitor ;
14
15
15
16
struct OpaqueTypeCollector < ' tcx > {
16
17
tcx : TyCtxt < ' tcx > ,
@@ -35,13 +36,6 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
35
36
} )
36
37
}
37
38
38
- fn visit_spanned ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) {
39
- let old = self . span ;
40
- self . span = Some ( span) ;
41
- value. visit_with ( self ) ;
42
- self . span = old;
43
- }
44
-
45
39
fn parent_trait_ref ( & self ) -> Option < ty:: TraitRef < ' tcx > > {
46
40
let parent = self . parent ( ) ?;
47
41
if matches ! ( self . tcx. def_kind( parent) , DefKind :: Impl { .. } ) {
@@ -162,7 +156,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
162
156
. instantiate_identity_iter_copied ( )
163
157
{
164
158
trace ! ( ?pred) ;
165
- self . visit_spanned ( span, pred) ;
159
+ self . visit ( span, pred) ;
166
160
}
167
161
}
168
162
Err ( NotUniqueParam :: NotParam ( arg) ) => {
@@ -183,10 +177,13 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
183
177
}
184
178
}
185
179
186
- impl < ' tcx > super :: sig_types :: SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
180
+ impl < ' tcx > SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
187
181
#[ instrument( skip( self ) , ret, level = "trace" ) ]
188
182
fn visit ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) -> ControlFlow < !> {
189
- self . visit_spanned ( span, value) ;
183
+ let old = self . span ;
184
+ self . span = Some ( span) ;
185
+ value. visit_with ( self ) ;
186
+ self . span = old;
190
187
ControlFlow :: Continue ( ( ) )
191
188
}
192
189
}
@@ -265,7 +262,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
265
262
// would have to walk all generic parameters of an Adt, which can quickly
266
263
// degenerate into looking at an exponential number of types.
267
264
let ty = self . tcx . type_of ( field. did ) . instantiate_identity ( ) ;
268
- self . visit_spanned ( self . tcx . def_span ( field. did ) , ty) ;
265
+ self . visit ( self . tcx . def_span ( field. did ) , ty) ;
269
266
}
270
267
}
271
268
}
@@ -277,7 +274,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
277
274
278
275
struct ImplTraitInAssocTypeCollector < ' tcx > ( OpaqueTypeCollector < ' tcx > ) ;
279
276
280
- impl < ' tcx > super :: sig_types :: SpannedTypeVisitor < ' tcx > for ImplTraitInAssocTypeCollector < ' tcx > {
277
+ impl < ' tcx > SpannedTypeVisitor < ' tcx > for ImplTraitInAssocTypeCollector < ' tcx > {
281
278
#[ instrument( skip( self ) , ret, level = "trace" ) ]
282
279
fn visit ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) -> ControlFlow < !> {
283
280
let old = self . 0 . span ;
0 commit comments