rust-lang / trait-system-refactor-initiative

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

Nested bodies need to have pre-defined opaques #132

Open compiler-errors opened 2 weeks ago

compiler-errors commented 2 weeks 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 2 weeks 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.