Skip to content

GAT impl with type parameter causes ICE, even without feature enabled #64755

Closed
@PlasmaPower

Description

This also applies to stable rust, since it still ICEs without the feature gate, though of course on stable there's no way to encounter it without having another error due to the feature not being enabled. It's similar to #60654 but with type parameters instead of lifetime parameters. Here's an example (playground link):

struct Foo;

trait MyTrait {
    type Item<T>;
}

impl MyTrait for Foo {
    type Item<T> = T;
}

This is a bit easier to encounter than that example shows, since type cohesion isn't checked for GATs yet, meaning that you can reproduce this by implementing the normal Iterator trait but still placing a type parameter on the Item type (note for whoever implements that: almost all of the code in rustc_typeck::check::compare_method is reusable there).

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. GATsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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