Skip to content

const generics: error[E0391]: cycle detected when const-evaluating + checking Foo::{{constant}}#0 #67185

Closed
@is8ac

Description

@is8ac

Source

#![feature(const_generics)]

trait Baz {
    type Quaks;
}
impl Baz for u8 {
    type Quaks = [u16; 3];
}

trait Bar {}
impl Bar for [u16; 3] {}
impl Bar for [[u16; 3]; 2] {}

trait Foo
where
    [<u8 as Baz>::Quaks; 2]: Bar,
    <u8 as Baz>::Quaks: Bar,
{
}

fn main() {}

Error

[isaac@d6-arch bitnn]$ rustc src/bin/cycle_demo.rs 
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> src/bin/cycle_demo.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

error[E0391]: cycle detected when const-evaluating + checking `Foo::{{constant}}#0`
  --> src/bin/cycle_demo.rs:17:26
   |
17 |     [<u8 as Baz>::Quaks; 2]: Bar,
   |                          ^
   |
note: ...which requires const-evaluating + checking `Foo::{{constant}}#0`...
  --> src/bin/cycle_demo.rs:17:26
   |
17 |     [<u8 as Baz>::Quaks; 2]: Bar,
   |                          ^
note: ...which requires const-evaluating `Foo::{{constant}}#0`...
  --> src/bin/cycle_demo.rs:17:26
   |
17 |     [<u8 as Baz>::Quaks; 2]: Bar,
   |                          ^
note: ...which requires processing `Foo::{{constant}}#0`...
  --> src/bin/cycle_demo.rs:17:26
   |
17 |     [<u8 as Baz>::Quaks; 2]: Bar,
   |                          ^
note: ...which requires processing `Foo::{{constant}}#0`...
  --> src/bin/cycle_demo.rs:17:26
   |
17 |     [<u8 as Baz>::Quaks; 2]: Bar,
   |                          ^
   = note: ...which again requires const-evaluating + checking `Foo::{{constant}}#0`, completing the cycle
note: cycle used when processing `Foo`
  --> src/bin/cycle_demo.rs:14:1
   |
14 | / trait Foo
15 | | where
16 | |     Self: Sized,
17 | |     [<u8 as Baz>::Quaks; 2]: Bar,
18 | |     <u8 as Baz>::Quaks: Bar,
19 | | {
20 | | }
   | |_^

error: aborting due to previous error

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

Remove the line [<u8 as Baz>::Quaks; 2]: Bar, and it compiles.
Removing #![feature(const_generics)] also makes it compile.

Meta

[isaac@d6-arch bitnn]$ rustc --version --verbose
rustc 1.41.0-nightly (59947fcae 2019-12-08)
binary: rustc
commit-hash: 59947fcae6a40df12e33af8c8c7291014b7603e0
commit-date: 2019-12-08
host: x86_64-unknown-linux-gnu
release: 1.41.0-nightly
LLVM version: 9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions