@@ -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 { .. } ) {
@@ -174,7 +168,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
174
168
. instantiate_identity_iter_copied ( )
175
169
{
176
170
trace ! ( ?pred) ;
177
- self . visit_spanned ( span, pred) ;
171
+ self . visit ( span, pred) ;
178
172
}
179
173
}
180
174
Err ( NotUniqueParam :: NotParam ( arg) ) => {
@@ -195,10 +189,13 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
195
189
}
196
190
}
197
191
198
- impl < ' tcx > super :: sig_types :: SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
192
+ impl < ' tcx > SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
199
193
#[ instrument( skip( self ) , ret, level = "trace" ) ]
200
194
fn visit ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) {
201
- self . visit_spanned ( span, value) ;
195
+ let old = self . span ;
196
+ self . span = Some ( span) ;
197
+ value. visit_with ( self ) ;
198
+ self . span = old;
202
199
}
203
200
}
204
201
@@ -279,7 +276,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
279
276
// would have to walk all generic parameters of an Adt, which can quickly
280
277
// degenerate into looking at an exponential number of types.
281
278
let ty = self . tcx . type_of ( field. did ) . instantiate_identity ( ) ;
282
- self . visit_spanned ( self . tcx . def_span ( field. did ) , ty) ;
279
+ self . visit ( self . tcx . def_span ( field. did ) , ty) ;
283
280
}
284
281
}
285
282
}
0 commit comments