@@ -11,6 +11,7 @@ use crate::ty::{self, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt};
1111use rustc_hir:: def:: Namespace ;
1212use rustc_index:: { Idx , IndexVec } ;
1313use rustc_target:: abi:: TyAndLayout ;
14+ use rustc_type_ir:: ConstKind ;
1415
1516use std:: fmt;
1617use std:: ops:: ControlFlow ;
@@ -710,7 +711,18 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Const<'tcx> {
710711 folder : & mut F ,
711712 ) -> Result < Self , F :: Error > {
712713 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+ } ;
714726 if ty != self . ty ( ) || kind != self . kind ( ) {
715727 Ok ( folder. interner ( ) . mk_ct_from_kind ( kind, ty) )
716728 } else {
@@ -725,7 +737,19 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
725737 visitor : & mut V ,
726738 ) -> ControlFlow < V :: BreakTy > {
727739 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+ }
729753 }
730754}
731755
0 commit comments