@@ -11,6 +11,7 @@ use crate::ty::{self, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt};
11
11
use rustc_hir:: def:: Namespace ;
12
12
use rustc_index:: { Idx , IndexVec } ;
13
13
use rustc_target:: abi:: TyAndLayout ;
14
+ use rustc_type_ir:: ConstKind ;
14
15
15
16
use std:: fmt;
16
17
use std:: ops:: ControlFlow ;
@@ -710,7 +711,18 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Const<'tcx> {
710
711
folder : & mut F ,
711
712
) -> Result < Self , F :: Error > {
712
713
let ty = self . ty ( ) . try_fold_with ( folder) ?;
713
- let kind = self . kind ( ) . try_fold_with ( folder) ?;
714
+ let kind = match self . kind ( ) {
715
+ ConstKind :: Param ( p) => ConstKind :: Param ( p. try_fold_with ( folder) ?) ,
716
+ ConstKind :: Infer ( i) => ConstKind :: Infer ( i. try_fold_with ( folder) ?) ,
717
+ ConstKind :: Bound ( d, b) => {
718
+ ConstKind :: Bound ( d. try_fold_with ( folder) ?, b. try_fold_with ( folder) ?)
719
+ }
720
+ ConstKind :: Placeholder ( p) => ConstKind :: Placeholder ( p. try_fold_with ( folder) ?) ,
721
+ ConstKind :: Unevaluated ( uv) => ConstKind :: Unevaluated ( uv. try_fold_with ( folder) ?) ,
722
+ ConstKind :: Value ( v) => ConstKind :: Value ( v. try_fold_with ( folder) ?) ,
723
+ ConstKind :: Error ( e) => ConstKind :: Error ( e. try_fold_with ( folder) ?) ,
724
+ ConstKind :: Expr ( e) => ConstKind :: Expr ( e. try_fold_with ( folder) ?) ,
725
+ } ;
714
726
if ty != self . ty ( ) || kind != self . kind ( ) {
715
727
Ok ( folder. interner ( ) . mk_ct_from_kind ( kind, ty) )
716
728
} else {
@@ -725,7 +737,19 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
725
737
visitor : & mut V ,
726
738
) -> ControlFlow < V :: BreakTy > {
727
739
self . ty ( ) . visit_with ( visitor) ?;
728
- self . kind ( ) . visit_with ( visitor)
740
+ match self . kind ( ) {
741
+ ConstKind :: Param ( p) => p. visit_with ( visitor) ,
742
+ ConstKind :: Infer ( i) => i. visit_with ( visitor) ,
743
+ ConstKind :: Bound ( d, b) => {
744
+ d. visit_with ( visitor) ?;
745
+ b. visit_with ( visitor)
746
+ }
747
+ ConstKind :: Placeholder ( p) => p. visit_with ( visitor) ,
748
+ ConstKind :: Unevaluated ( uv) => uv. visit_with ( visitor) ,
749
+ ConstKind :: Value ( v) => v. visit_with ( visitor) ,
750
+ ConstKind :: Error ( e) => e. visit_with ( visitor) ,
751
+ ConstKind :: Expr ( e) => e. visit_with ( visitor) ,
752
+ }
729
753
}
730
754
}
731
755
0 commit comments