E0601: Empty match
| Code | Category | Stability |
|---|---|---|
E0601 | Match | Permanent |
Explanation
A match with no arms is valid only when its scrutinee is an enum with zero variants. Every inhabited type has at least one possible value, so an empty arm list cannot cover it.
Likely cause
A match body was left empty while being drafted, or code attempted to use an empty match with an integer, boolean, or enum that has one or more variants. Add arms covering the scrutinee or reserve the empty form for a zero-variant enum.
Examples
Leave an integer match empty
fn main() -> i32 {
match 0 {}
}
Add an exhaustive wildcard arm
fn main() -> i32 {
match 0 {
_ => 0,
}
}