Skip to content

Can define a associated type more than once #23969

Closed
@Kimundi

Description

@Kimundi
trait Foo {
    type Ty;
}

impl Foo for () {
    type Ty = ();
    type Ty = usize;
}

fn main() { 
    let _: <() as Foo>::Ty = ();
}

This erroneously parses and compiles fine, the compiler seems to use the first definition of Ty in the impl.

This might have been introduced by #23265, ping @eddyb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type systemP-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions