Skip to content

Bad diagnostic for associated types when forgetting type arguments #51913

@estebank

Description

@estebank

Given an incorrect order of associated types:

type Bar = Foo<C = u32, B = bool, A = String>;

struct Foo<A, B, C> {
    a: A,
    b: B,
    c: C
}

We currently identify the first argument as a type binding and emit two errors:

error[E0243]: wrong number of type arguments: expected 3, found 0
 --> src/main.rs:4:12
  |
4 | type Bar = Foo<C = u32, B = bool, A = String>;
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 type arguments

error[E0229]: associated type bindings are not allowed here
 --> src/main.rs:4:16
  |
4 | type Bar = Foo<C = u32, B = bool, A = String>;
  |                ^^^^^^^ associated type not allowed here

Modify to emit only one error complaining only about the ordermissing type arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions