rust icon indicating copy to clipboard operation
rust copied to clipboard

regression with the new opaque type generics

Open aliemjay opened this issue 1 year ago • 3 comments

The following should compile.

#![feature(type_alias_impl_trait)]
#![allow(unconditional_recursion)]

type Opaque<'a> = impl Sized + 'a;

fn test<'a>() -> Opaque<'a> {
    let _: () = test::<'a>();
    //~^ ERROR expected generic lifetime parameter, found `'_`
}

Regressed in #122103. With the new generics of Opaque, the defining use at the let statement is Opaque<'_, 'a> := (). Cc @compiler-errors

aliemjay avatar Mar 10 '24 20:03 aliemjay

You minimized this from the same issue we have with RPITs, right? Because this code ICEs:

#![allow(unconditional_recursion)]

fn test<'a>() -> impl Sized + 'a {
    let _: () = test::<'a>();
}

compiler-errors avatar Mar 10 '24 20:03 compiler-errors

No, I discovered it accidentally by rebasing #116891.

aliemjay avatar Mar 10 '24 20:03 aliemjay

Wait, @aliemjay isn't this issue also fixed by #116891? It should be filtering out the uncaptured lifetimes in that PR.

compiler-errors avatar Mar 11 '24 18:03 compiler-errors