@@ -11,15 +11,15 @@ use rustc_hir::def::Namespace;
1111use rustc_span:: source_map:: Spanned ;
1212use rustc_target:: abi:: TyAndLayout ;
1313use rustc_type_ir:: ConstKind ;
14- use rustc_type_ir:: traverse:: TypeTraversable ;
14+ use rustc_type_ir:: traverse:: { ImportantTypeTraversal , TypeTraversable } ;
1515
1616use super :: print:: PrettyPrinter ;
1717use super :: { GenericArg , GenericArgKind , Pattern , Region } ;
1818use crate :: mir:: interpret;
1919use crate :: ty:: fold:: { FallibleTypeFolder , TypeFoldable , TypeSuperFoldable } ;
2020use crate :: ty:: print:: { FmtPrinter , Printer , with_no_trimmed_paths} ;
2121use crate :: ty:: visit:: { TypeSuperVisitable , TypeVisitable , TypeVisitor } ;
22- use crate :: ty:: { self , InferConst , Lift , Term , TermKind , Ty , TyCtxt } ;
22+ use crate :: ty:: { self , Lift , Term , TermKind , Ty , TyCtxt } ;
2323
2424impl fmt:: Debug for ty:: TraitDef {
2525 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -258,7 +258,6 @@ TrivialTypeTraversalImpls! {
258258 :: rustc_span:: Span ,
259259 :: rustc_span:: symbol:: Ident ,
260260 ty:: BoundVar ,
261- ty:: ValTree <' tcx>,
262261}
263262// For some things about which the type library does not know, or does not
264263// provide any traversal implementations, we need to provide a traversal
@@ -304,12 +303,6 @@ impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
304303///////////////////////////////////////////////////////////////////////////
305304// Traversal implementations.
306305
307- impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ty:: AdtDef < ' tcx > {
308- fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , _visitor : & mut V ) -> V :: Result {
309- V :: Result :: output ( )
310- }
311- }
312-
313306impl < ' tcx > TypeFoldable < TyCtxt < ' tcx > > for & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > {
314307 fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
315308 self ,
@@ -338,6 +331,9 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Pattern<'tcx> {
338331 }
339332}
340333
334+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for Pattern < ' tcx > {
335+ type Kind = ImportantTypeTraversal ;
336+ }
341337impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for Pattern < ' tcx > {
342338 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
343339 ( * * self ) . visit_with ( visitor)
@@ -353,6 +349,9 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
353349 }
354350}
355351
352+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for Ty < ' tcx > {
353+ type Kind = ImportantTypeTraversal ;
354+ }
356355impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for Ty < ' tcx > {
357356 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
358357 visitor. visit_ty ( * self )
@@ -469,6 +468,9 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ty::Region<'tcx> {
469468 }
470469}
471470
471+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for ty:: Region < ' tcx > {
472+ type Kind = ImportantTypeTraversal ;
473+ }
472474impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ty:: Region < ' tcx > {
473475 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
474476 visitor. visit_region ( * self )
@@ -494,12 +496,18 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ty::Clause<'tcx> {
494496 }
495497}
496498
499+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for ty:: Predicate < ' tcx > {
500+ type Kind = ImportantTypeTraversal ;
501+ }
497502impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ty:: Predicate < ' tcx > {
498503 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
499504 visitor. visit_predicate ( * self )
500505 }
501506}
502507
508+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for ty:: Clause < ' tcx > {
509+ type Kind = ImportantTypeTraversal ;
510+ }
503511impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ty:: Clause < ' tcx > {
504512 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
505513 visitor. visit_predicate ( self . as_predicate ( ) )
@@ -522,6 +530,9 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Predicate<'tcx> {
522530 }
523531}
524532
533+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for ty:: Clauses < ' tcx > {
534+ type Kind = ImportantTypeTraversal ;
535+ }
525536impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ty:: Clauses < ' tcx > {
526537 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
527538 visitor. visit_clauses ( self )
@@ -552,6 +563,9 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ty::Const<'tcx> {
552563 }
553564}
554565
566+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for ty:: Const < ' tcx > {
567+ type Kind = ImportantTypeTraversal ;
568+ }
555569impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ty:: Const < ' tcx > {
556570 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
557571 visitor. visit_const ( * self )
@@ -602,6 +616,9 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
602616 }
603617}
604618
619+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for rustc_span:: ErrorGuaranteed {
620+ type Kind = ImportantTypeTraversal ;
621+ }
605622impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for rustc_span:: ErrorGuaranteed {
606623 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
607624 visitor. visit_error ( * self )
@@ -617,27 +634,20 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for rustc_span::ErrorGuaranteed {
617634 }
618635}
619636
620- impl < ' tcx > TypeFoldable < TyCtxt < ' tcx > > for InferConst {
621- fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
622- self ,
623- _folder : & mut F ,
624- ) -> Result < Self , F :: Error > {
625- Ok ( self )
626- }
627- }
628-
629- impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for InferConst {
630- fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , _visitor : & mut V ) -> V :: Result {
631- V :: Result :: output ( )
632- }
637+ impl < ' tcx > TypeTraversable < TyCtxt < ' tcx > > for TyAndLayout < ' tcx , Ty < ' tcx > > {
638+ type Kind = ImportantTypeTraversal ;
633639}
634-
635640impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for TyAndLayout < ' tcx , Ty < ' tcx > > {
636641 fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
637642 visitor. visit_ty ( self . ty )
638643 }
639644}
640645
646+ impl < ' tcx , T : TypeVisitable < TyCtxt < ' tcx > > + Debug + Clone > TypeTraversable < TyCtxt < ' tcx > >
647+ for Spanned < T >
648+ {
649+ type Kind = ImportantTypeTraversal ;
650+ }
641651impl < ' tcx , T : TypeVisitable < TyCtxt < ' tcx > > + Debug + Clone > TypeVisitable < TyCtxt < ' tcx > >
642652 for Spanned < T >
643653{
0 commit comments