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

Error message could be improved in generic match arm #37282

Closed
srinivasreddy opened this issue Oct 19, 2016 · 2 comments
Closed

Error message could be improved in generic match arm #37282

srinivasreddy opened this issue Oct 19, 2016 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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

@srinivasreddy
Copy link
Contributor

srinivasreddy commented Oct 19, 2016

In the following program instead of underscore, i put a hyphen. The error message i received is misleading. I think it can be improved. What do you guys think?

fn main() {
   let integer = 2;
   match integer {
    2 => { println!("this is two");}
    - => { println!("This is Not two"); }
    }
}
srinivas@Srini:~/workspace/github/rust-exercises$ rustc 3.rs
3.rs:5:7: 5:9 error: expected pattern, found `=>`
3.rs:5     - => { println!("This is None"); }
             ^~
error: aborting due to 2 previous errors

Here is the playpen

@srinivasreddy srinivasreddy changed the title Error message could be improved Error message could be improved in generic match arm Oct 19, 2016
@TimNN TimNN added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 19, 2016
@estebank
Copy link
Contributor

I think this is because it is expecting a number (the pattern it couldn't find) after the -. I believe this might have to be special cased to point at the - instead of the =>.

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@estebank
Copy link
Contributor

Duplicate of #29586.

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 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

No branches or pull requests

5 participants