Skip to content

Nested bodies need to have pre-defined opaques #132

Open
@compiler-errors

Description

@compiler-errors

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>();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions