Open
Description
I tried this code:
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
const fn wrap<const N: usize>() -> usize {
0
}
const fn inner<const N: usize>() -> usize {
0
}
const fn flip_magic_base_inner<const N: usize>()
-> !
where [(); wrap::<{ inner::<N>() }>()] : {
todo!()
}
I expected to see this happen: no error
The following code, which is essentially the same, can compile.
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=a568ce2d4a1d358435f825aa172c4440
Instead, this happened:
Compiling playground v0.0.1 (/playground)
error[E0391]: cycle detected when building an abstract representation for `flip_magic_base_inner::{constant#0}`
--> src/lib.rs:14:16
|
14 | where [(); wrap::<{ inner::<N>() }>()] : {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires building THIR for `flip_magic_base_inner::{constant#0}`...
--> src/lib.rs:14:16
|
14 | where [(); wrap::<{ inner::<N>() }>()] : {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `flip_magic_base_inner::{constant#0}`...
--> src/lib.rs:14:16
|
14 | where [(); wrap::<{ inner::<N>() }>()] : {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires building an abstract representation for `flip_magic_base_inner::{constant#0}`, completing the cycle
note: cycle used when checking that `flip_magic_base_inner` is well-formed
--> src/lib.rs:12:1
|
12 | / const fn flip_magic_base_inner<const N: usize>()
13 | | -> !
14 | | where [(); wrap::<{ inner::<N>() }>()] : {
| |____________________________________________^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
For more information about this error, try `rustc --explain E0391`.
error: could not compile `playground` (lib) due to 1 previous error
There is something wrong with it because it can be compiled if it is not duplicated.
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=aba90728c00aaa4808ecd5762ae9fa26
Meta
rustc --version --verbose
:
rustc 1.87.0-nightly (f8a913b13 2025-02-23)
binary: rustc
commit-hash: f8a913b1381e90379c7ca63ac2b88b9518936628
commit-date: 2025-02-23
host: x86_64-pc-windows-msvc
release: 1.87.0-nightly
LLVM version: 20.1.0