Skip to content

Can't specific multiple associated type bindings for same GAT even if args differ #143143

@Jules-Bertholet

Description

@Jules-Bertholet

I tried this code:

trait Trait {
    type Gat<T>;
}

trait Subtrait: Trait<Gat<u32> = u32, Gat<u64> = u64> {}

I expected to see this happen: It compiles

Instead, this happened:

error[E0719]: the value of the associated type `Gat` in trait `Trait` is already specified
 --> src/lib.rs:5:39
  |
5 | trait Subtrait: Trait<Gat<u32> = u32, Gat<u64> = u64> {}
  |                       --------------  ^^^^^^^^^^^^^^ re-bound here
  |                       |
  |                       `Gat` bound here first

For more information about this error, try `rustc --explain E0719`.

(Perhaps E0719 should be removed entirely, and turned into a lint?)

Meta

rustc --version:

1.88.0

Originally reported on Internals: https://internals.rust-lang.org/t/multiple-gat-constraints-with-different-generics-on-trait-bounds/23148

@rustbot label T-types A-associated-items A-GATs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions