Skip to content

E0023 should have smaller, more targeted spans #86307

Closed

Description

@estebank

Currently, when a tuple pattern has a different number of fields than a tuple variant, the output is like the following:

error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field
   --> compiler/rustc_middle/src/ty/print/pretty.rs:634:27
    |
634 |                         | ty::PredicateKind::ImplicitSizedTrait(pred, _) =
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 field, found 2
    | 
   ::: compiler/rustc_middle/src/ty/mod.rs:440:5
    |
440 |     ImplicitSizedTrait(TraitPredicate<'tcx>),
    |     ---------------------------------------- tuple variant defined here

Ideally, the primary span would be for the individual fields, with a secondary span pointing at the pattern path. As a stretch goal, when pointing at the definition we'd point at the fields in the same way, instead of the whole variant (but this isn't absolutely necessary).

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    P-lowLow priority
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    D-papercutDiagnostics: An error or lint that needs small tweaks.
    on Jun 14, 2021
  2. self-assigned this
    on Jun 14, 2021
  3. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Jul 1, 2021
  4. added a commit that references this issue on Aug 26, 2021
  5. added a commit that references this issue on Aug 26, 2021
  6. added a commit that references this issue on Aug 26, 2021
  7. added a commit that references this issue on Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

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.P-lowLow priorityT-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