@@ -10,6 +10,7 @@ use rustc_span::Span;
1010use rustc_trait_selection:: traits:: check_args_compatible;
1111
1212use crate :: errors:: { DuplicateArg , NotParam } ;
13+ use crate :: sig_types:: SpannedTypeVisitor ;
1314
1415struct OpaqueTypeCollector < ' tcx > {
1516 tcx : TyCtxt < ' tcx > ,
@@ -47,13 +48,6 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
4748 } )
4849 }
4950
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-
5751 fn parent_trait_ref ( & self ) -> Option < ty:: TraitRef < ' tcx > > {
5852 let parent = self . parent ( ) ?;
5953 if matches ! ( self . tcx. def_kind( parent) , DefKind :: Impl { .. } ) {
@@ -176,7 +170,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
176170 . instantiate_identity_iter_copied ( )
177171 {
178172 trace ! ( ?pred) ;
179- self . visit_spanned ( span, pred) ;
173+ self . visit ( span, pred) ;
180174 }
181175 }
182176 Err ( NotUniqueParam :: NotParam ( arg) ) => {
@@ -197,10 +191,13 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
197191 }
198192}
199193
200- impl < ' tcx > super :: sig_types :: SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
194+ impl < ' tcx > SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
201195 #[ instrument( skip( self ) , ret, level = "trace" ) ]
202196 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;
204201 }
205202}
206203
@@ -293,7 +290,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
293290 // would have to walk all generic parameters of an Adt, which can quickly
294291 // degenerate into looking at an exponential number of types.
295292 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) ;
297294 }
298295 }
299296 }
0 commit comments