rust-lang / trait-system-refactor-initiative

The Rustc Trait System Refactor Initiative
22 stars 0 forks source link

query cycle in `layout_of` #123

Open lcnr opened 2 months ago

lcnr commented 2 months ago

likely due to lazy norm

https://rust.godbolt.org/z/Gce6rnTTc, cc https://github.com/rust-lang/rust/issues/129541

trait Bound {}
trait Normalize {
    type Assoc;
}

impl<T: Bound> Normalize for T {
    type Assoc = T;
}

impl<T: Bound> Normalize for [T] {
    type Assoc = T;
}

impl Bound for Hello {}
enum Hello {
    Variant(<[Hello] as Normalize>::Assoc),
}
error[E0391]: cycle detected when computing layout of `<[Hello] as Normalize>::Assoc`
  |
  = note: ...which requires computing layout of `Hello`...
  = note: ...which again requires computing layout of `<[Hello] as Normalize>::Assoc`, completing the cycle
  = note: cycle used when computing layout of `Hello`
  = 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