Do not eagerly fold consts in normalize_param_env_or_error if new solver
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index 31b075d..f73603c 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -340,7 +340,7 @@ pub fn normalize_param_env_or_error<'tcx>(
let mut predicates: Vec<_> = util::elaborate(
tcx,
unnormalized_env.caller_bounds().into_iter().map(|predicate| {
- if tcx.features().generic_const_exprs() {
+ if tcx.features().generic_const_exprs() || tcx.next_trait_solver_globally() {
return predicate;
}
@@ -405,8 +405,6 @@ fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
// compatibility. Eventually when lazy norm is implemented this can just be removed.
// We do not normalize types here as there is no backwards compatibility requirement
// for us to do so.
- //
- // FIXME(-Znext-solver): remove this hack since we have deferred projection equality
predicate.fold_with(&mut ConstNormalizer(tcx))
}),
)
diff --git a/tests/ui/traits/next-solver/no-param-env-const-fold.rs b/tests/ui/traits/next-solver/no-param-env-const-fold.rs
new file mode 100644
index 0000000..4f47332
--- /dev/null
+++ b/tests/ui/traits/next-solver/no-param-env-const-fold.rs
@@ -0,0 +1,10 @@
+//@ check-pass
+//@ compile-flags: -Znext-solver
+
+// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/213>.
+
+use std::ops::Deref;
+
+trait Trait: Deref<Target = [u8; { 1 + 1 }]> {}
+
+fn main() {}