@@ -10,6 +10,7 @@ use rustc_span::Span;
10
10
use rustc_trait_selection:: traits:: check_args_compatible;
11
11
12
12
use crate :: errors:: { DuplicateArg , NotParam } ;
13
+ use crate :: sig_types:: SpannedTypeVisitor ;
13
14
14
15
struct OpaqueTypeCollector < ' tcx > {
15
16
tcx : TyCtxt < ' tcx > ,
@@ -47,13 +48,6 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
47
48
} )
48
49
}
49
50
50
- fn visit_spanned ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) {
51
- let old = self . span ;
52
- self . span = Some ( span) ;
53
- value. visit_with ( self ) ;
54
- self . span = old;
55
- }
56
-
57
51
fn parent_trait_ref ( & self ) -> Option < ty:: TraitRef < ' tcx > > {
58
52
let parent = self . parent ( ) ?;
59
53
if matches ! ( self . tcx. def_kind( parent) , DefKind :: Impl { .. } ) {
@@ -176,7 +170,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
176
170
. instantiate_identity_iter_copied ( )
177
171
{
178
172
trace ! ( ?pred) ;
179
- self . visit_spanned ( span, pred) ;
173
+ self . visit ( span, pred) ;
180
174
}
181
175
}
182
176
Err ( NotUniqueParam :: NotParam ( arg) ) => {
@@ -197,10 +191,13 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
197
191
}
198
192
}
199
193
200
- impl < ' tcx > super :: sig_types :: SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
194
+ impl < ' tcx > SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
201
195
#[ instrument( skip( self ) , ret, level = "trace" ) ]
202
196
fn visit ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) {
203
- self . visit_spanned ( span, value) ;
197
+ let old = self . span ;
198
+ self . span = Some ( span) ;
199
+ value. visit_with ( self ) ;
200
+ self . span = old;
204
201
}
205
202
}
206
203
@@ -293,7 +290,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
293
290
// would have to walk all generic parameters of an Adt, which can quickly
294
291
// degenerate into looking at an exponential number of types.
295
292
let ty = self . tcx . type_of ( field. did ) . instantiate_identity ( ) ;
296
- self . visit_spanned ( self . tcx . def_span ( field. did ) , ty) ;
293
+ self . visit ( self . tcx . def_span ( field. did ) , ty) ;
297
294
}
298
295
}
299
296
}
0 commit comments