Open
Description
// check-pass
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo<T>(T);
fn test() where [u8; {
let _: Foo<[u8; 3 + 4]>;
3
}]: Sized {}
ends up failing with
error[E0391]: cycle detected when simplifying constant for the type system `test::{constant#0}`
--> src/lib.rs:7:22
|
7 | fn test() where [u8; {
| ______________________^
8 | | let _: Foo<[u8; 3 + 4]>;
9 | | 3
10 | | }]: Sized {
| |_^
|
note: ...which requires const-evaluating + checking `test::{constant#0}`...
--> src/lib.rs:7:22
|
7 | fn test() where [u8; {
| ______________________^
8 | | let _: Foo<[u8; 3 + 4]>;
9 | | 3
10 | | }]: Sized {
| |_^
note: ...which requires type-checking `test::{constant#0}`...
--> src/lib.rs:7:22
|
7 | fn test() where [u8; {
| ______________________^
8 | | let _: Foo<[u8; 3 + 4]>;
9 | | 3
10 | | }]: Sized {
| |_^
= note: ...which requires evaluating trait selection obligation `[u8; _]: std::marker::Sized`...
= note: ...which again requires simplifying constant for the type system `test::{constant#0}`, completing the cycle
note: cycle used when checking that `test` is well-formed
--> src/lib.rs:10:5
|
10 | }]: Sized {
| ^^^^^
The cycle happens while typechecking the outer array length. This happens because Foo<[u8; 3 + 4]>
requires [u8; 3 + 4]
to be sized. While trying to fulfill this we see the [u8; ...]: Sized
bound in the param_env and try to unify these two. This causes us to evaluate both constants which once again relies on typechecking them.
*This test succeeds with min_const_generics
and currently fails with const_generics
.