Skip to content

Nightly #![feature(generic_const_exprs)]: cycle detected when building an abstract representation for the const argument #106420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
is8ac opened this issue Jan 3, 2023 · 0 comments
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-cycle Issue: A query cycle occurred while none was expected requires-incomplete-features This issue requires the use of incomplete features. requires-nightly This issue requires a nightly compiler in some way.

Comments

@is8ac
Copy link

is8ac commented Jan 3, 2023

Code:

#![feature(generic_const_exprs)]

pub trait Foo<const K: u32> {
    type T;
}

struct Bar<const A: u32>
where
    (): Foo<{A as u32}>,
    //(): Foo<A>,
    <() as Foo<A>>::T: Sized,
{}

fn main() {}

Error:

error[E0391]: cycle detected when building an abstract representation for the const argument `Bar::{constant#0}`
 --> src/bin/clone_demo2.rs:9:13
  |
9 |     (): Foo<{A as u32}>,
  |             ^^^^^^^^^^
  |
note: ...which requires building THIR for `Bar::{constant#0}`...
 --> src/bin/clone_demo2.rs:9:13
  |
9 |     (): Foo<{A as u32}>,
  |             ^^^^^^^^^^
note: ...which requires type-checking the const argument `Bar::{constant#0}`...
 --> src/bin/clone_demo2.rs:9:13
  |
9 |     (): Foo<{A as u32}>,
  |             ^^^^^^^^^^
note: ...which requires computing normalized predicates of `Bar::{constant#0}`...
 --> src/bin/clone_demo2.rs:9:13
  |
9 |     (): Foo<{A as u32}>,
  |             ^^^^^^^^^^
  = note: ...which again requires building an abstract representation for the const argument `Bar::{constant#0}`, completing the cycle
note: cycle used when computing normalized predicates of `Bar`
 --> src/bin/clone_demo2.rs:7:1
  |
7 | struct Bar<const A: u32>
  | ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

To work around, replace {A as u32} with A.

The same issue happens with <() as Foo<{A as u32}>>::T: Sized,.

May be related to #106419 ?

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (d6f99e535 2023-01-02)
binary: rustc
commit-hash: d6f99e535a301a421dfee52a7c25bb4bdf420344
commit-date: 2023-01-02
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6
@is8ac is8ac added the C-bug Category: This is a bug. label Jan 3, 2023
@Noratrieb Noratrieb added A-const-generics Area: const generics (parameters and arguments) requires-nightly This issue requires a nightly compiler in some way. F-generic_const_exprs `#![feature(generic_const_exprs)]` labels Jan 3, 2023
@workingjubilee workingjubilee added the requires-incomplete-features This issue requires the use of incomplete features. label Mar 4, 2023
@fmease fmease added the I-cycle Issue: A query cycle occurred while none was expected label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-cycle Issue: A query cycle occurred while none was expected requires-incomplete-features This issue requires the use of incomplete features. requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests

4 participants