rust-lang / trait-system-refactor-initiative

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

Nested bodies need to have pre-defined opaques #132

Open compiler-errors opened 1 month ago

compiler-errors commented 1 month ago
#![feature(type_alias_impl_trait)]

struct Foo;
trait Bar {}
impl Bar for Foo {}

type Tait<'a> = impl Sized;

fn needs_bar<'a>() where Tait<'a>: Bar {
    let x: Tait<'a> = Foo;
}

fn foo<'a>() -> Tait<'a> {
    || {
        needs_bar();
    };
    Foo
}

But they also may not define the opaque, so we have to be ok w/ that too.

compiler-errors commented 1 month ago

Probably need to predefine opaques in the nested bodies, but in order to not require them to also always define those opaques, we need to propagate them to the body owner the same way we do with closure region requirements.