Skip to content

putting [(); CONSTANT]: bound on trait causes cycle #107874

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
djdisodo opened this issue Feb 10, 2023 · 1 comment
Open

putting [(); CONSTANT]: bound on trait causes cycle #107874

djdisodo opened this issue Feb 10, 2023 · 1 comment
Labels
A-const-generics Area: const generics (parameters and arguments) 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@djdisodo
Copy link

djdisodo commented Feb 10, 2023

EDITED(workingjubilee): Inlined source

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
#![allow(dead_code)]

trait Foo: where [(); Self::BAR]: {
    const BAR: usize;
}

struct Baz<F: Foo> {
    _a: [u8; F::BAR],
    _b: u32,
}

struct Qux;
impl Foo for Qux {
    const BAR: usize = 4;
}

fn main() {
    assert_eq!(std::mem::size_of::<Baz<Qux>>(), 8);
}

source

   Compiling playground v0.0.1 (/playground)
error[E0391]: cycle detected when building an abstract representation for `Foo::{constant#0}`
 --> src/main.rs:5:23
  |
5 | trait Foo: where [(); Self::BAR]: {
  |                       ^^^^^^^^^
  |
note: ...which requires building THIR for `Foo::{constant#0}`...
 --> src/main.rs:5:23
  |
5 | trait Foo: where [(); Self::BAR]: {
  |                       ^^^^^^^^^
note: ...which requires type-checking `Foo::{constant#0}`...
 --> src/main.rs:5:23
  |
5 | trait Foo: where [(); Self::BAR]: {
  |                       ^^^^^^^^^
  = note: ...which again requires building an abstract representation for `Foo::{constant#0}`, completing the cycle
note: cycle used when checking that `Foo` is well-formed
 --> src/main.rs:5:1
  |
5 | trait Foo: where [(); Self::BAR]: {
  | ^^^^^^^^^

For more information about this error, try `rustc --explain E0391`.
error: could not compile `playground` due to previous error

@djdisodo
Copy link
Author

#104400

@workingjubilee workingjubilee 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 Feb 10, 2023
@workingjubilee workingjubilee added the requires-incomplete-features This issue requires the use of incomplete features. label Mar 4, 2023
@fmease fmease added I-cycle Issue: A query cycle occurred while none was expected T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels 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) 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants