@@ -9,6 +9,7 @@ use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
99use crate :: ty:: visit:: { TypeSuperVisitable , TypeVisitable , TypeVisitor } ;
1010use crate :: ty:: { self , AliasTy , InferConst , Lift , Term , TermKind , Ty , TyCtxt } ;
1111use rustc_hir:: def:: Namespace ;
12+ use rustc_span:: source_map:: Spanned ;
1213use rustc_target:: abi:: TyAndLayout ;
1314use rustc_type_ir:: { ConstKind , DebugWithInfcx , InferCtxtLike , WithInfcx } ;
1415
@@ -819,3 +820,27 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for TyAndLayout<'tcx, Ty<'tcx>> {
819820 visitor. visit_ty ( self . ty )
820821 }
821822}
823+
824+ impl < ' tcx , T : TypeVisitable < TyCtxt < ' tcx > > + Debug + Clone > TypeVisitable < TyCtxt < ' tcx > >
825+ for Spanned < T >
826+ {
827+ fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> ControlFlow < V :: BreakTy > {
828+ self . node . visit_with ( visitor) ?;
829+ self . span . visit_with ( visitor) ?;
830+ ControlFlow :: Continue ( ( ) )
831+ }
832+ }
833+
834+ impl < ' tcx , T : TypeFoldable < TyCtxt < ' tcx > > + Debug + Clone > TypeFoldable < TyCtxt < ' tcx > >
835+ for Spanned < T >
836+ {
837+ fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
838+ self ,
839+ folder : & mut F ,
840+ ) -> Result < Self , F :: Error > {
841+ Ok ( Spanned {
842+ node : self . node . try_fold_with ( folder) ?,
843+ span : self . span . try_fold_with ( folder) ?,
844+ } )
845+ }
846+ }
0 commit comments