Skip to content

Be consistent about whether the span label duplicates info in an error message #41695

Closed
@nrc

Description

@nrc

Often an error message has two parts - the heading and a label on a span. E.g.,

error[E0425]: cannot find value `labe` in this scope
   --> src/actions/compiler_message_parsing.rs:116:30
    |
116 |             message.push_str(labe);
    |                              ^^^^ did you mean `label`?

Here the heading is cannot find value labe in this scope and the label on the span is did you mean label? In this case the two contain different information.

However, in some cases, the info is duplicated, e.g.,

error[E0061]: this function takes 1 parameter but 0 parameters were supplied
   --> src/actions/compiler_message_parsing.rs:116:21
    |
116 |             message.push_str();
    |                     ^^^^^^^^ expected 1 parameter

This is a problem for IDEs because all errors are on spans and we must choose to either show both pieces of text (which looks weird and redundant in the second example) or just the heading (which elides information in the first example).

Alternatively, we could add some flag to the JSON error structure to indicate whether a label is redundant or not.

cc @jonathandturner

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.I-needs-decisionIssue: In need of a decision.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