Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
oconnor663 opened this issue Jul 12, 2021 · 1 comment · Fixed by #87101
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST A-patterns Relating to patterns and pattern matching C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@oconnor663
Copy link
Contributor

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.

@oconnor663 oconnor663 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 12, 2021
@estebank estebank added A-parser Area: The parsing of Rust source code to an AST A-patterns Relating to patterns and pattern matching labels Jul 12, 2021
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 13, 2021
@bors bors closed this as completed in d8943a7 Jul 14, 2021
@oconnor663
Copy link
Contributor Author

So fast! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST A-patterns Relating to patterns and pattern matching C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants