Open
Description
I tried this code:
enum Foo {
A(bool),
B,
C,
}
fn main() {
let a = Foo::A(false);
match a {
Foo::A(x) if x => {},
Foo::A(x) if !x => {},
Foo::B => {},
Foo::C => {},
}
}
I expected to see this happen: Compilation without an error
Instead, this happened: Rustc wants a catch-all for Foo::A(_)
, which is not required since the other match arms are covering.
Compiling playground v0.0.1 (/playground)
error[[E0004]](https://doc.rust-lang.org/stable/error-index.html#E0004): non-exhaustive patterns: `A(_)` not covered
[--> src/main.rs:12:11
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b70f6933b22baa139e9ad679a7559935#) |
2 | / enum Foo {
3 | | A(bool),
| | - not covered
4 | | B,
5 | | C,
6 | | }
| |_- `Foo` defined here
...
12 | match a {
| ^ pattern `A(_)` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
= note: the matched value is of type `Foo`
For more information about this error, try `rustc --explain E0004`.
error: could not compile `playground` due to previous error
Meta
rustc --version --verbose
:
1.58.1
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsRelating to exhaustiveness / usefulness checking of patternsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.