Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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,6 +1,6 @@
//@ known-bug: unknown
// Ensure that we print unsatisfied always-const trait bounds as `const Trait` in diagnostics.
//@ compile-flags: -Znext-solver
//@ compile-flags: -Znext-solver=coherence
Comment thread
Dnreikronos marked this conversation as resolved.
Outdated

#![feature(const_trait_impl, generic_const_exprs)]
#![allow(incomplete_features)]
Expand Down
56 changes: 21 additions & 35 deletions tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr
Original file line number Diff line number Diff line change
@@ -1,45 +1,31 @@
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
error[E0277]: the trait bound `T: const Trait` is not satisfied
--> $DIR/unsatisfied-const-trait-bound.rs:28:37
|
LL | #![feature(const_trait_impl, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
LL | fn accept0<T: Trait>(_: Container<{ T::make() }>) {}
| ^

error[E0277]: the trait bound `T: const Trait` is not satisfied
--> $DIR/unsatisfied-const-trait-bound.rs:32:51
|
= help: remove one of these features
LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {}
| ^

error[E0391]: cycle detected when evaluating type-level constant
--> $DIR/unsatisfied-const-trait-bound.rs:28:35
error[E0277]: the trait bound `Ty: const Trait` is not satisfied
--> $DIR/unsatisfied-const-trait-bound.rs:21:15
|
LL | fn accept0<T: Trait>(_: Container<{ T::make() }>) {}
| ^^^^^^^^^^^^^
LL | require::<Ty>();
| ^^
|
= 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
note: required by a bound in `require`
--> $DIR/unsatisfied-const-trait-bound.rs:8:15
|
LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {}
| ^^^^^^^^^^^^^
LL | fn require<T: const Trait>() {}
| ^^^^^^^^^^^ required by this bound in `require`
help: make the `impl` of trait `Trait` `const`
|
= 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>
LL | impl const Trait for Ty {
| +++++

error: aborting due to 3 previous errors

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