Skip to content
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

Nested bodies need to have pre-defined opaques #132

Open
compiler-errors opened this issue Oct 8, 2024 · 1 comment
Open

Nested bodies need to have pre-defined opaques #132

compiler-errors opened this issue Oct 8, 2024 · 1 comment

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Oct 8, 2024

https://rust.godbolt.org/z/fjjTxrYnh

#![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.

This example does not compile with the old solver as-well, however the old solver may have non-defining uses of the opaque in nested bodies, e.g.

pub fn defines_in_closure<'a>() -> impl Sized + 'a {
    let _ = || defines_in_closure::<'a>();
}
@compiler-errors
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant