Skip to content

GAT + enum: incorrect unused lifetime error #69184

Closed
@dhardy

Description

@dhardy

This is a follow up on #67089, which now works. The following doesn't (play link):

#![feature(generic_associated_types)]

trait A {
    type B<'a>;
    
    fn make_b<'a>(&'a self) -> Self::B<'a>;
}

struct S {}

impl A for S {
    type B<'a> = &'a S;
    fn make_b<'a>(&'a self) -> &'a Self {
        self
    }
}

enum E<'a> {
    S(<S as A>::B<'a>),
}

Error is:

18 | enum E<'a> {
   |        ^^ unused parameter

however, this lifetime clearly is used and is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-lifetimesArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions