Skip to content

impl Trait lifetimes regression 1.67 part 2 #108592

Closed
@aliemjay

Description

@aliemjay

Another regresssion of #103491 with a different failure path:

fn opaque<'a: 'a>() -> impl Sized {}
fn assert_static<T: 'static>(_: T) {}

fn test() {
    let closure = |_| {
        assert_static(opaque());
        //~^ ERROR the opaque type may not live long enough
    };
    closure(&opaque());
}
#![feature(type_alias_impl_trait)]
type Opaque<'a> = impl Sized;
fn define<'a>() -> Opaque<'a> {}

fn test(_: &Opaque<'_>) {
    None::<&'static Opaque<'_>>;
    //~^ ERROR the opaque type may not live long enough
}

It should be fixed by ignoring non-captured lifetimes in:

cc @cjgillot

@rustbot label regression-from-stable-to-stable C-bug T-compiler T-types A-impl-trait

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions