Skip to content

Error reporting for missing match comma could be improved #29586

Closed
@ghost

Description

UPDATE: Mentoring instructions below.


Given this code:

enum Foo { A, B, }

fn main() {
    match &Foo::A {
        &Foo::A => "art"
        &Foo::B => "bart"
    };
}

rustc reports this error:

error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, `}`, or an operator, found `=>`
 --> src/main.rs:6:17
  |
6 |         &Foo::B => "bart"
  |                 ^^ expected one of 8 possible tokens here

As @mbrubeck pointed out in IRC, the cause is that a bitwise-and operation, namely "art" & Foo::B is being parsed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions