Closed
Description
I can reproduce this in both stable and nightly. Minimal test case:
enum Enum {
A, B, C, D, E, F
}
use Enum::*;
fn main() {
match (A, ()) {
(A, _) => {}
}
}
Error message from nightly:
error[E0004]: non-exhaustive patterns: `(B, C)`, `D`, `E` and 1 more not covered
--> <anon>:7:5
|
7 | match (A, ()) {
| ^^^^^^^^^^^^^ patterns `(B, C)`, `D`, `E` and 1 more not covered
The error from stable looks similar, just with a different template:
error: non-exhaustive patterns: `(B, C)`, `D`, `E` and 1 more not covered [--explain E0004]
--> <anon>:7:5
7 |> match (A, ()) {
|> ^
If the matched item uses a different tuple nesting structure, the error message will fill in all the components of that structure with the enum values:
enum Enum {
A, B, C, D, E, F
}
use Enum::*;
fn main() {
match ((A, ()), ()) {
((A, ()), _) => {}
}
}
error[E0004]: non-exhaustive patterns: `((B, C), D)`, `E` and `F` not covered
--> <anon>:7:5
|
7 | match ((A, ()), ()) {
| ^^^^^^^^^^^^^^^^^^^ patterns `((B, C), D)`, `E` and `F` not covered
If the number of slots to fill in in the tuple structure exceeds the number of un-handled enum variants, the error message will use _ for the remaining slots:
enum Enum {
A, B, C
}
use Enum::*;
fn main() {
match ((A, ()), ()) {
((A, _), _) => {}
}
}
error[E0004]: non-exhaustive patterns: `((B, C), _)` not covered
--> <anon>:7:5
|
7 | match ((A, ()), ()) {
| ^^^^^^^^^^^^^^^^^^^ pattern `((B, C), _)` not covered
Edit: this also occurs with tuple structs:
enum Enum {
A, B, C, D, E, F
}
use Enum::*;
struct S(Enum, ());
fn main() {
match S(A, ()) {
S(A, _) => {}
}
}
error[E0004]: non-exhaustive patterns: `S(B, C)`, `D`, `E` and 1 more not covered
--> <anon>:8:5
|
8 | match S(A, ()) {
| ^^^^^^^^^^^^^^ patterns `S(B, C)`, `D`, `E` and 1 more not covered
And with structs:
enum Enum {
A, B, C, D, E, F
}
use Enum::*;
struct S { x: Enum, y: () }
fn main() {
match (S { x: A, y: () }) {
S { x: A, y: _ } => {}
}
}
error[E0004]: non-exhaustive patterns: `S { x: B, y: C }`, `D`, `E` and 1 more not covered
--> <anon>:8:5
|
8 | match (S { x: A, y: () }) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `S { x: B, y: C }`, `D`, `E` and 1 more not covered
Metadata
Metadata
Assignees
Labels
No labels