Closed
Description
This code [playground]:
#![feature(generic_associated_types)]
trait Trait {
type Assoc<'a>;
}
type AssocAlias<'a, T> = <T as Trait>::Assoc<'a>;
fn works<'a, T: Trait>(entity: T::Assoc<'a>) -> &'a i32 {&5}
fn fails<'a, T: Trait>(entity: AssocAlias<'a, T>) -> &'a i32 {&5}
Produces the following error on 1.54.0-nightly (2021-05-19 f94942d):
error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types
--> src/lib.rs:10:54
|
10 | fn fails<'a, T: Trait>(entity: AssocAlias<'a, T>) -> &'a i32 {&5}
|
The version that uses T::Assoc
directly works, but the one using the type alias (which should be identical) fails.