-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsGATs-triagedIssues using the `generic_associated_types` feature that have been triagedIssues using the `generic_associated_types` feature that have been triaged
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.
Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)C-bugCategory: This is a bug.Category: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsGATs-triagedIssues using the `generic_associated_types` feature that have been triagedIssues using the `generic_associated_types` feature that have been triaged