diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 1fefb5d6ecf48..06e937cf5920e 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -746,8 +746,10 @@ fn check_new_solver_banned_features(sess: &Session, features: &Features) { .find(|feat| feat.gate_name == sym::generic_const_exprs) .map(|feat| feat.attr_sp) { + // Abort immediately, otherwise GCE can lower to `ConstKind::Expr`, + // which the new solver intentionally does not support. #[allow(rustc::symbol_intern_string_literal)] - sess.dcx().emit_err(diagnostics::IncompatibleFeatures { + sess.dcx().emit_fatal(diagnostics::IncompatibleFeatures { spans: vec![gce_span], f1: Symbol::intern("-Znext-solver=globally"), f2: sym::generic_const_exprs, diff --git a/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.rs b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.rs new file mode 100644 index 0000000000000..9d114a1173929 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Znext-solver=globally + +#![feature(min_generic_const_args)] +#![feature(generic_const_args)] +#![feature(generic_const_exprs)] +//~^ ERROR `-Znext-solver=globally` and `generic_const_exprs` are incompatible +//@ normalize-stderr: "(--> ).*/tests/ui/const-generics/generic_const_exprs" -> "$1$$DIR" + +use std::mem::size_of; + +union AsBytes { + as_bytes: [u8; const { size_of::() }], +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.stderr b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.stderr new file mode 100644 index 0000000000000..9c2b303107185 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.stderr @@ -0,0 +1,10 @@ +error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed + --> $DIR/next-solver-gce-incompatible-issue-158428.rs:5:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: remove one of these features + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs index 57641423643e8..a88009aa91d23 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs @@ -1,5 +1,6 @@ //@ known-bug: unknown -// Ensure that we print unsatisfied always-const trait bounds as `const Trait` in diagnostics. +// This used to ensure that the next solver prints unsatisfied always-const trait bounds as +// `const Trait`, but no longer does because GCE is incompatible with the next solver. //@ compile-flags: -Znext-solver #![feature(const_trait_impl, generic_const_exprs)] diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr index 147b248c33da8..912cdd1d42944 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr @@ -1,45 +1,10 @@ error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed - --> $DIR/unsatisfied-const-trait-bound.rs:5:30 + --> $DIR/unsatisfied-const-trait-bound.rs:6:30 | LL | #![feature(const_trait_impl, generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = help: remove one of these features -error[E0391]: cycle detected when evaluating type-level constant - --> $DIR/unsatisfied-const-trait-bound.rs:28:35 - | -LL | fn accept0(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ - | - = note: ...which requires const-evaluating + checking `accept0::{constant#0}`... - = note: ...which requires checking if `accept0::{constant#0}` is a trivial const... - = note: ...which requires building MIR for `accept0::{constant#0}`... - = note: ...which requires building an abstract representation for `accept0::{constant#0}`... - = note: ...which requires building THIR for `accept0::{constant#0}`... - = note: ...which requires type-checking `accept0::{constant#0}`... - = note: ...which requires computing normalized predicates of `accept0::{constant#0}`... - = note: ...which again requires evaluating type-level constant, completing the cycle - = note: cycle used when computing normalized predicates of `accept0` - = note: for more information, see and - -error[E0391]: cycle detected when checking if `accept1::{constant#0}` is a trivial const - --> $DIR/unsatisfied-const-trait-bound.rs:32:49 - | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ - | - = note: ...which requires building MIR for `accept1::{constant#0}`... - = note: ...which requires building an abstract representation for `accept1::{constant#0}`... - = note: ...which requires building THIR for `accept1::{constant#0}`... - = note: ...which requires type-checking `accept1::{constant#0}`... - = note: ...which requires computing normalized predicates of `accept1::{constant#0}`... - = note: ...which requires evaluating type-level constant... - = note: ...which requires const-evaluating + checking `accept1::{constant#0}`... - = note: ...which again requires checking if `accept1::{constant#0}` is a trivial const, completing the cycle - = note: cycle used when const-evaluating + checking `accept1::{constant#0}` - = note: for more information, see and - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0391`.