Closed
Description
Given the example code:
enum E { A, B, C }
fn f() -> E { unimplemented!(); }
fn main() {
match f() {
A => print!("It was A!"),
_ => print!("Something else"),
}
}
I get a really nice warning message about what I did wrong:
warning[E0170]: pattern binding `A` is named the same as one of the variants of the type `E`
--> src/main.rs:6:9
|
6 | A => print!("It was A!"),
| ^
|
= help: if you meant to match on a variant, consider making the path in the pattern qualified: `E::A`
However, if I change the main function to match multiple patterns:
fn main() {
match f() {
A => print!("It was A!"),
B | C => print!("It was B or C!"),
}
}
The error message is really confusing with no hint how to fix it:
error[E0408]: variable `B` is not bound in all patterns
--> src/main.rs:8:13
|
8 | B | C => print!("It was B or C!"),
| - ^ pattern doesn't bind `B`
| |
| variable not in all patterns
Please expand the error message for the second case to look a bit more like the first case.