-
Notifications
You must be signed in to change notification settings - Fork 0
Open
rust-lang/rust
#148698Labels
from-craterA regression found via a crater run, not part of our test suiteA regression found via a crater run, not part of our test suite
Description
const CONST: &str = "hi";
trait ToUnit {
type Assoc;
}
impl<T> ToUnit for T {
type Assoc = ();
}
fn foo()
where
<[u8; CONST.len()] as ToUnit>::Assoc: Sized,
{}results in
error[E0391]: cycle detected when evaluating type-level constant
--> src/main.rs:12:11
|
12 | <[u8; CONST.len()] as ToUnit>::Assoc: Sized,
| ^^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `foo::{constant#0}`...
--> src/main.rs:12:11
|
12 | <[u8; CONST.len()] as ToUnit>::Assoc: Sized,
| ^^^^^
note: ...which requires simplifying constant for the type system `CONST`...
--> src/main.rs:1:1
|
1 | const CONST: &str = "hi";
| ^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `CONST`...
--> src/main.rs:1:1
|
1 | const CONST: &str = "hi";
| ^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `&str`...
note: ...which requires computing whether `str` is `Sized`...
--> src/main.rs:12:11
|
12 | <[u8; CONST.len()] as ToUnit>::Assoc: Sized,
| ^^^^^^^^^^^
= note: ...which again requires evaluating type-level constant, completing the cycle
note: cycle used when checking that `foo` is well-formed
--> src/main.rs:12:11
|
12 | <[u8; CONST.len()] as ToUnit>::Assoc: Sized,
| ^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
with the new solver as we evaluate CONST.len() in the param_env of the impl, we then try to use the where-bound containing that const when checking whether str: Sized holds while computing the layout of the return type of CONST.
The reason this doesn't have a cycle error in the old solver is that we don't try to normalize where-bounds while trait solving.
Metadata
Metadata
Assignees
Labels
from-craterA regression found via a crater run, not part of our test suiteA regression found via a crater run, not part of our test suite
Type
Projects
Status
todo