Skip to content

a missing path separator (: instead of ::) in enum match leads to confusing error #87086

Closed
@oconnor663

Description

@oconnor663
enum Foo {
    Bar,
    Baz,
}

fn main() {
    let myfoo = Foo::Bar;
    match myfoo {
        Foo::Bar => {}
        Foo:Baz => {}  // OOPS: I forgot a colon here
    }
}

On the playground (rustc 1.53), here's what I see:

error: expected one of `=>`, `@`, `if`, or `|`, found `:`
  --> src/main.rs:10:12
   |
10 |         Foo:Baz => {}
   |            ^ expected one of `=>`, `@`, `if`, or `|`

It would be nice if rustc could say "hey it looks like you forgot a colon" here, similar to this case.

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 ASTA-patternsRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.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