Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T> {
as_bytes: [u8; const { size_of::<T>() }],
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
39 changes: 2 additions & 37 deletions tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr
Original file line number Diff line number Diff line change
@@ -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<T: Trait>(_: 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 <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

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<T: [const] Trait>(_: 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 <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 3 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
Loading