Open
Description
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
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Category: This is a bug.`#![feature(generic_const_exprs)]`Issue: A query cycle occurred while none was expectedLow priorityRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires the use of incomplete features.This issue requires a nightly compiler in some way.