@@ -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 { .. } ) {
@@ -174,7 +168,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
174168 . instantiate_identity_iter_copied ( )
175169 {
176170 trace ! ( ?pred) ;
177- self . visit_spanned ( span, pred) ;
171+ self . visit ( span, pred) ;
178172 }
179173 }
180174 Err ( NotUniqueParam :: NotParam ( arg) ) => {
@@ -195,10 +189,13 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
195189 }
196190}
197191
198- impl < ' tcx > super :: sig_types :: SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
192+ impl < ' tcx > SpannedTypeVisitor < ' tcx > for OpaqueTypeCollector < ' tcx > {
199193 #[ instrument( skip( self ) , ret, level = "trace" ) ]
200194 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;
202199 }
203200}
204201
@@ -279,7 +276,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
279276 // would have to walk all generic parameters of an Adt, which can quickly
280277 // degenerate into looking at an exponential number of types.
281278 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) ;
283280 }
284281 }
285282 }
0 commit comments