Skip to content

lifetime-parametric GATs cause ICEs (with feature(generic_associated_types)) #62521

Closed
@pnkfelix

Description

@pnkfelix

Many people playing with #[feature(generic_associated_types)] have noticed that they break very easily when you attempt to use a lifetime formal parameter.

Examples follow

ICE: Region parameter out of range

#62326 (play):

#![feature(generic_associated_types)]
trait Iterator {
    type Item<'a>: 'a;
}

#58694 (play)

#![feature(generic_associated_types)]
trait Foo {
  type PublicKey<'a> : From<&'a [u8]>;     
}

#49362 (play)

#![feature(generic_associated_types)]

trait Trait {
    type Associated<'a>;
}

impl Trait for () {
    type Associated<'a> = &'a ();
}

ICE: cannot convert ReEarlyBound(0, 'b) to a region vid

#60654 (play)

#![feature(generic_associated_types)]
struct Foo;

impl Iterator for Foo {
    type Item<'b> = &'b Foo;

    fn next(&mut self) -> Option<Self::Item> {
        None
    }
}

This obviously blocks stabilization of GATs (#44265).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.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