@@ -7,7 +7,9 @@ use crate::mir::interpret;
7
7
use crate :: ty:: fold:: { FallibleTypeFolder , TypeFoldable , TypeSuperFoldable } ;
8
8
use crate :: ty:: print:: { with_no_trimmed_paths, FmtPrinter , Printer } ;
9
9
use crate :: ty:: visit:: { TypeSuperVisitable , TypeVisitable , TypeVisitor } ;
10
- use crate :: ty:: { self , AliasTy , InferConst , Lift , Term , TermKind , Ty , TyCtxt } ;
10
+ use crate :: ty:: {
11
+ self , noop_if_trivially_traversable, AliasTy , InferConst , Lift , Term , TermKind , Ty , TyCtxt ,
12
+ } ;
11
13
use rustc_hir:: def:: Namespace ;
12
14
use rustc_target:: abi:: TyAndLayout ;
13
15
use rustc_type_ir:: { ConstKind , DebugWithInfcx , InferCtxtLike , WithInfcx } ;
@@ -770,16 +772,31 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Const<'tcx> {
770
772
) -> Result < Self , F :: Error > {
771
773
let ty = self . ty ( ) . try_fold_with ( folder) ?;
772
774
let kind = match self . kind ( ) {
773
- ConstKind :: Param ( p) => ConstKind :: Param ( p. try_fold_with ( folder) ?) ,
774
- ConstKind :: Infer ( i) => ConstKind :: Infer ( i. try_fold_with ( folder) ?) ,
775
- ConstKind :: Bound ( d, b) => {
776
- ConstKind :: Bound ( d. try_fold_with ( folder) ?, b. try_fold_with ( folder) ?)
777
- }
778
- ConstKind :: Placeholder ( p) => ConstKind :: Placeholder ( p. try_fold_with ( folder) ?) ,
779
- ConstKind :: Unevaluated ( uv) => ConstKind :: Unevaluated ( uv. try_fold_with ( folder) ?) ,
780
- ConstKind :: Value ( v) => ConstKind :: Value ( v. try_fold_with ( folder) ?) ,
781
- ConstKind :: Error ( e) => ConstKind :: Error ( e. try_fold_with ( folder) ?) ,
782
- ConstKind :: Expr ( e) => ConstKind :: Expr ( e. try_fold_with ( folder) ?) ,
775
+ ConstKind :: Param ( p) => ConstKind :: Param ( noop_if_trivially_traversable ! (
776
+ p. try_fold_with:: <TyCtxt <' tcx>>( folder)
777
+ ) ?) ,
778
+ ConstKind :: Infer ( i) => ConstKind :: Infer ( noop_if_trivially_traversable ! (
779
+ i. try_fold_with:: <TyCtxt <' tcx>>( folder)
780
+ ) ?) ,
781
+ ConstKind :: Bound ( d, b) => ConstKind :: Bound (
782
+ noop_if_trivially_traversable ! ( d. try_fold_with:: <TyCtxt <' tcx>>( folder) ) ?,
783
+ noop_if_trivially_traversable ! ( b. try_fold_with:: <TyCtxt <' tcx>>( folder) ) ?,
784
+ ) ,
785
+ ConstKind :: Placeholder ( p) => ConstKind :: Placeholder ( noop_if_trivially_traversable ! (
786
+ p. try_fold_with:: <TyCtxt <' tcx>>( folder)
787
+ ) ?) ,
788
+ ConstKind :: Unevaluated ( uv) => ConstKind :: Unevaluated ( noop_if_trivially_traversable ! (
789
+ uv. try_fold_with:: <TyCtxt <' tcx>>( folder)
790
+ ) ?) ,
791
+ ConstKind :: Value ( v) => ConstKind :: Value ( noop_if_trivially_traversable ! (
792
+ v. try_fold_with:: <TyCtxt <' tcx>>( folder)
793
+ ) ?) ,
794
+ ConstKind :: Error ( e) => ConstKind :: Error ( noop_if_trivially_traversable ! (
795
+ e. try_fold_with:: <TyCtxt <' tcx>>( folder)
796
+ ) ?) ,
797
+ ConstKind :: Expr ( e) => ConstKind :: Expr ( noop_if_trivially_traversable ! (
798
+ e. try_fold_with:: <TyCtxt <' tcx>>( folder)
799
+ ) ?) ,
783
800
} ;
784
801
if ty != self . ty ( ) || kind != self . kind ( ) {
785
802
Ok ( folder. interner ( ) . mk_ct_from_kind ( kind, ty) )
@@ -795,18 +812,32 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
795
812
visitor : & mut V ,
796
813
) -> ControlFlow < V :: BreakTy > {
797
814
self . ty ( ) . visit_with ( visitor) ?;
798
- match self . kind ( ) {
799
- ConstKind :: Param ( p) => p. visit_with ( visitor) ,
800
- ConstKind :: Infer ( i) => i. visit_with ( visitor) ,
815
+ match & self . kind ( ) {
816
+ ConstKind :: Param ( p) => {
817
+ noop_if_trivially_traversable ! ( p. visit_with:: <TyCtxt <' tcx>>( visitor) )
818
+ }
819
+ ConstKind :: Infer ( i) => {
820
+ noop_if_trivially_traversable ! ( i. visit_with:: <TyCtxt <' tcx>>( visitor) )
821
+ }
801
822
ConstKind :: Bound ( d, b) => {
802
- d. visit_with ( visitor) ?;
803
- b. visit_with ( visitor)
823
+ noop_if_trivially_traversable ! ( d. visit_with:: <TyCtxt <' tcx>>( visitor) ) ?;
824
+ noop_if_trivially_traversable ! ( b. visit_with:: <TyCtxt <' tcx>>( visitor) )
825
+ }
826
+ ConstKind :: Placeholder ( p) => {
827
+ noop_if_trivially_traversable ! ( p. visit_with:: <TyCtxt <' tcx>>( visitor) )
828
+ }
829
+ ConstKind :: Unevaluated ( uv) => {
830
+ noop_if_trivially_traversable ! ( uv. visit_with:: <TyCtxt <' tcx>>( visitor) )
831
+ }
832
+ ConstKind :: Value ( v) => {
833
+ noop_if_trivially_traversable ! ( v. visit_with:: <TyCtxt <' tcx>>( visitor) )
834
+ }
835
+ ConstKind :: Error ( e) => {
836
+ noop_if_trivially_traversable ! ( e. visit_with:: <TyCtxt <' tcx>>( visitor) )
837
+ }
838
+ ConstKind :: Expr ( e) => {
839
+ noop_if_trivially_traversable ! ( e. visit_with:: <TyCtxt <' tcx>>( visitor) )
804
840
}
805
- ConstKind :: Placeholder ( p) => p. visit_with ( visitor) ,
806
- ConstKind :: Unevaluated ( uv) => uv. visit_with ( visitor) ,
807
- ConstKind :: Value ( v) => v. visit_with ( visitor) ,
808
- ConstKind :: Error ( e) => e. visit_with ( visitor) ,
809
- ConstKind :: Expr ( e) => e. visit_with ( visitor) ,
810
841
}
811
842
}
812
843
}
0 commit comments