Skip to content

Improve diagnostics for missing associated types #60595

Closed
@alexreg

Description

@alexreg

When the user fails to specify associated types for a trait object, the span used for the label associated type `Output` must be specified is the entire trait object, when it should ideally just be the trait (bound) from which the associated type is missing.

For example, we currently get:

3 | type Foo = Add + Sub;
  |            ^^^^^^^^^ associated type `Output` must be specified

when we really want something like:

3 | type Foo = Add + Sub;
  |            |     ^^^ associated type `Output` must be specified
  |            ^^^^      associated type `Output` must be specified

Note that PR #59445 will ensure that there at least are two labels in the above example, which is more correct, although the spans of both labels will still be the entire trait object.

See also #59445 (comment).

CC @estebank @eddyb @Centril

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler 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