diff --git a/compiler/rustc_middle/src/ty/abstract_const.rs b/compiler/rustc_middle/src/ty/abstract_const.rs index c9b9ec771b324..79ee9bd328d93 100644 --- a/compiler/rustc_middle/src/ty/abstract_const.rs +++ b/compiler/rustc_middle/src/ty/abstract_const.rs @@ -63,7 +63,12 @@ impl<'tcx> TyCtxt<'tcx> { }, _ => c, }; - ct.super_fold_with(self) + + if ct.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) { + ct.super_fold_with(self) + } else { + ct + } } } ac.fold_with(&mut Expander { tcx: self }) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index de337710b5ef7..a8ac5f01e7ba5 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -376,6 +376,22 @@ pub fn normalize_param_env_or_error<'tcx>( c } + + fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { + if t.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) { + t.super_fold_with(self) + } else { + t + } + } + + fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> { + if p.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) { + p.super_fold_with(self) + } else { + p + } + } } // This whole normalization step is a hack to work around the fact that