Skip to content

Self: 'static causes GAT outlives lint to needlessly fire #90888

Closed
@BoxyUwU

Description

@BoxyUwU

The following code (playground):

#![feature(generic_associated_types)]

trait Trait: 'static {
    type Assoc<'a>;
    fn make_assoc(_: &u32) -> Self::Assoc<'_>;
}

Gives an error:

error: Missing required bounds on Assoc
 --> src/lib.rs:4:5
  |
4 |     type Assoc<'a>;
  |     ^^^^^^^^^^^^^^-
  |                   |
  |                   help: add the required where clauses: `where Self: 'a`

I would have expected the where Self: 'a not to be required as we already know that Self outlives 'a as it outlives 'static

Meta

rustc version: 1.58.0-nightly (e90c5fb 2021-11-12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)C-bugCategory: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions