@@ -7,9 +7,7 @@ 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:: {
11
- self , noop_if_trivially_traversable, AliasTy , InferConst , Lift , Term , TermKind , Ty , TyCtxt ,
12
- } ;
10
+ use crate :: ty:: { self , AliasTy , InferConst , Lift , Term , TermKind , Ty , TyCtxt } ;
13
11
use rustc_hir:: def:: Namespace ;
14
12
use rustc_span:: source_map:: Spanned ;
15
13
use rustc_type_ir:: { ConstKind , DebugWithInfcx , InferCtxtLike , WithInfcx } ;
@@ -714,33 +712,7 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Const<'tcx> {
714
712
folder : & mut F ,
715
713
) -> Result < Self , F :: Error > {
716
714
let ty = self . ty ( ) . try_fold_with ( folder) ?;
717
- let kind = match self . kind ( ) {
718
- ConstKind :: Param ( p) => ConstKind :: Param ( noop_if_trivially_traversable ! (
719
- p. try_fold_with:: <TyCtxt <' tcx>>( folder)
720
- ) ?) ,
721
- ConstKind :: Infer ( i) => ConstKind :: Infer ( noop_if_trivially_traversable ! (
722
- i. try_fold_with:: <TyCtxt <' tcx>>( folder)
723
- ) ?) ,
724
- ConstKind :: Bound ( d, b) => ConstKind :: Bound (
725
- noop_if_trivially_traversable ! ( d. try_fold_with:: <TyCtxt <' tcx>>( folder) ) ?,
726
- noop_if_trivially_traversable ! ( b. try_fold_with:: <TyCtxt <' tcx>>( folder) ) ?,
727
- ) ,
728
- ConstKind :: Placeholder ( p) => ConstKind :: Placeholder ( noop_if_trivially_traversable ! (
729
- p. try_fold_with:: <TyCtxt <' tcx>>( folder)
730
- ) ?) ,
731
- ConstKind :: Unevaluated ( uv) => ConstKind :: Unevaluated ( noop_if_trivially_traversable ! (
732
- uv. try_fold_with:: <TyCtxt <' tcx>>( folder)
733
- ) ?) ,
734
- ConstKind :: Value ( v) => ConstKind :: Value ( noop_if_trivially_traversable ! (
735
- v. try_fold_with:: <TyCtxt <' tcx>>( folder)
736
- ) ?) ,
737
- ConstKind :: Error ( e) => ConstKind :: Error ( noop_if_trivially_traversable ! (
738
- e. try_fold_with:: <TyCtxt <' tcx>>( folder)
739
- ) ?) ,
740
- ConstKind :: Expr ( e) => ConstKind :: Expr ( noop_if_trivially_traversable ! (
741
- e. try_fold_with:: <TyCtxt <' tcx>>( folder)
742
- ) ?) ,
743
- } ;
715
+ let kind = self . kind ( ) . try_fold_with ( folder) ?;
744
716
if ty != self . ty ( ) || kind != self . kind ( ) {
745
717
Ok ( folder. interner ( ) . mk_ct_from_kind ( kind, ty) )
746
718
} else {
@@ -755,33 +727,7 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
755
727
visitor : & mut V ,
756
728
) -> ControlFlow < V :: BreakTy > {
757
729
self . ty ( ) . visit_with ( visitor) ?;
758
- match & self . kind ( ) {
759
- ConstKind :: Param ( p) => {
760
- noop_if_trivially_traversable ! ( p. visit_with:: <TyCtxt <' tcx>>( visitor) )
761
- }
762
- ConstKind :: Infer ( i) => {
763
- noop_if_trivially_traversable ! ( i. visit_with:: <TyCtxt <' tcx>>( visitor) )
764
- }
765
- ConstKind :: Bound ( d, b) => {
766
- noop_if_trivially_traversable ! ( d. visit_with:: <TyCtxt <' tcx>>( visitor) ) ?;
767
- noop_if_trivially_traversable ! ( b. visit_with:: <TyCtxt <' tcx>>( visitor) )
768
- }
769
- ConstKind :: Placeholder ( p) => {
770
- noop_if_trivially_traversable ! ( p. visit_with:: <TyCtxt <' tcx>>( visitor) )
771
- }
772
- ConstKind :: Unevaluated ( uv) => {
773
- noop_if_trivially_traversable ! ( uv. visit_with:: <TyCtxt <' tcx>>( visitor) )
774
- }
775
- ConstKind :: Value ( v) => {
776
- noop_if_trivially_traversable ! ( v. visit_with:: <TyCtxt <' tcx>>( visitor) )
777
- }
778
- ConstKind :: Error ( e) => {
779
- noop_if_trivially_traversable ! ( e. visit_with:: <TyCtxt <' tcx>>( visitor) )
780
- }
781
- ConstKind :: Expr ( e) => {
782
- noop_if_trivially_traversable ! ( e. visit_with:: <TyCtxt <' tcx>>( visitor) )
783
- }
784
- }
730
+ self . kind ( ) . visit_with ( visitor)
785
731
}
786
732
}
787
733
0 commit comments