- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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 }]>() {}
  | ^^^^^^^^^^^^^^^^^^^^
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.