rust-lang / trait-system-refactor-initiative

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

unavoidable overflow due to cycle fixpoint + region constaints #118

Open lcnr opened 4 months ago

lcnr commented 4 months ago
struct MyType<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h> {
    is_static: SendIfStatic<'a>,
    rot: Option<Box<MyType<'b, 'c, 'd, 'e, 'f, 'g, 'h, 'a>>>,
}

struct SendIfStatic<'a>(&'a ());
unsafe impl Send for SendIfStatic<'static> {}

fn is_send<T: Send>(x: T) {}

fn main() {
    let is_static = SendIfStatic(&());
    is_send(MyType {
        is_static,
        rot: None, 
    })
}

this compiles with the old solver and overflows with new. https://rust.godbolt.org/z/v9bMKM5T4

lcnr commented 4 months ago

This only affects cases where coinductive cycles include goals with more constraints than the struct definition, so it may not matter in practice