Closed
Description
#![feature(const_generics)]
fn foo<const N: [u8; { 3 + 1 }]>() {}
should compile, but currently results in the following. I am kind of surprised that this ends up with 3 separate cycle errors.
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/lib.rs:1:12
|
1 | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
error[E0391]: cycle detected when computing type of `foo::N`
--> src/lib.rs:3:14
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^
|
= note: ...which again requires computing type of `foo::N`, completing the cycle
note: cycle used when computing type of `foo`
--> src/lib.rs:3:1
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^^^^^^^^^^^^
error[E0391]: cycle detected when computing type of `foo::N`
--> src/lib.rs:3:14
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^
|
note: ...which requires const-evaluating + checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires const-evaluating + checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires const-evaluating `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires optimizing MIR for `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires elaborating drops for `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires borrow-checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires processing `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires const checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires processing MIR for `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires unsafety-checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires building MIR for `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
= note: ...which again requires computing type of `foo::N`, completing the cycle
note: cycle used when computing type of `foo`
--> src/lib.rs:3:1
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^^^^^^^^^^^^
error[E0391]: cycle detected when computing type of `foo::N`
--> src/lib.rs:3:14
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^
|
note: ...which requires const-evaluating + checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires const-evaluating + checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires const-evaluating `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires optimizing MIR for `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires elaborating drops for `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
note: ...which requires borrow-checking `foo::{{constant}}#0`...
--> src/lib.rs:3:22
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^
= note: ...which again requires computing type of `foo::N`, completing the cycle
note: cycle used when computing type of `foo`
--> src/lib.rs:3:1
|
3 | fn foo<const N: [u8; { 3 + 1 }]>() {}
| ^^^^^^^^^^^^^^^^^^^^