Rust

E0004 Non-Exhaustive Patterns Fix

You write a match that handles every case you care about — and the compiler rejects it for a case you left out. That rejection is the match doing its job: a match must account for every value its type can hold, because the code after it has to run, or produce a value, for all of them. E0004 names the exact value your patterns miss, and the repair is to decide what that value should do — handle it explicitly, or say with a wildcard that it truly does not matter — never to guess at a pattern until the error goes quiet.

Written November 27, 2026 · Tested with Rust 1.99.1 · 20 min read

By the end of this guide
  • The error: a missing enum variant
  • The error: gaps in an integer or char match
  • The error: a missing bool, Option, or Result case
  • The error: a missing tuple or struct combination

Written November 27, 2026

Tested with Rust 1.99.1

What this guide is

A match in Rust must be exhaustive: its patterns, taken together, must cover every possible value of the matched type. The error codes index states the reason in one sentence — the compiler cannot guarantee a matching pattern for one or more possible inputs to a match expression, and guaranteed matches are required in order to assign values to match expressions or determine the flow of execution. If a value could arrive that no arm matches, the match would have nowhere to go.

E0004 is the report for that gap, and it is unusually helpful: its header names a concrete uncovered value — a variant, a range, a combination — not just the fact that something is missing. Read that value first. It tells you whether you forgot a real case your program must handle, or whether the remaining values genuinely share one outcome and a wildcard arm is the honest answer.

This guide reproduces the error for a missing enum variant, for gaps in integer and char matches, for a missing bool, Option, or Result case, for a missing tuple or struct combination, for a nested enum, for a guarded arm — which does not count toward exhaustiveness — and for a #[non_exhaustive] enum matched from another crate. It finishes with the choice between explicit arms and a wildcard, and with two neighboring shapes that are not E0004 at all.

Build every program in this guide with rustc --edition 2021. The cross-crate program near the end is built in two steps, shown where it appears. In the compiler transcripts below, the file names are the bare names shown on the command line.

The error: a missing enum variant

The smallest form is one variant left out of an enum match. The value at runtime is covered here — the error is about the type, not about which value this run happens to hold:

Rust
enum E { A, B, C }
fn main() { let x = E::A; match x { E::A => println!("a"), E::C => println!("c"), } }
Terminal
$ rustc --edition 2021 enum_missing.rs -o enum_missing.bin
error[E0004]: non-exhaustive patterns: `E::B` not covered
 --> enum_missing.rs:2:33
  |
2 | fn main() { let x = E::A; match x { E::A => println!("a"), E::C => println!("c"), } }
  |                                 ^ pattern `E::B` not covered
  |
note: `E` defined here
 --> enum_missing.rs:1:6
  |
1 | enum E { A, B, C }
  |      ^      - not covered
  = note: the matched value is of type `E`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
2 | fn main() { let x = E::A; match x { E::A => println!("a"), E::C => println!("c"), E::B => todo!(), } }
  |                                                                                 +++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.

For an enum you own, the explicit repair is usually right — name the missing variant and give it its own behavior:

Rust
enum E { A, B, C }
fn main() { let x = E::B; match x { E::A => println!("a"), E::B => println!("b"), E::C => println!("c"), } }
Terminal
$ rustc --edition 2021 enum_missing_fixed.rs -o enum_missing_fixed.bin
warning: variants `A` and `C` are never constructed
 --> enum_missing_fixed.rs:1:10
  |
1 | enum E { A, B, C }
  |      -   ^     ^
  |      |
  |      variants in this enum
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: 1 warning emitted
$ ./enum_missing_fixed.bin
b

The error index gives the same advice: for types with a small number of variants, like enums, you should probably cover all cases explicitly. The payoff is future-proofing in the other direction — when a variant is added later, every exhaustive match on the enum fails to compile until someone decides what the new variant does there.

The error: gaps in an integer or char match

Numbers and characters have far too many values to list, so a match on them is exhaustive only when ranges cover the whole type or a wildcard closes the rest. Two literal arms leave almost all of a u8 uncovered, and the compiler names the uncovered range:

Rust
fn main() { let x: u8 = 2; match x { 0 => println!("zero"), 1 => println!("one"), } }
Terminal
$ rustc --edition 2021 int_gap.rs -o int_gap.bin
error[E0004]: non-exhaustive patterns: `2_u8..=u8::MAX` not covered
 --> int_gap.rs:1:34
  |
1 | fn main() { let x: u8 = 2; match x { 0 => println!("zero"), 1 => println!("one"), } }
  |                                  ^ pattern `2_u8..=u8::MAX` not covered
  |
  = note: the matched value is of type `u8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
1 | fn main() { let x: u8 = 2; match x { 0 => println!("zero"), 1 => println!("one"), 2_u8..=u8::MAX => todo!(), } }
  |                                                                                 +++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.

Here the remaining values really do share one outcome, so the wildcard is the right repair:

Rust
fn main() { let x: u8 = 2; match x { 0 => println!("zero"), 1 => println!("one"), _ => println!("other"), } }
Terminal
$ rustc --edition 2021 int_gap_fixed.rs -o int_gap_fixed.bin
$ ./int_gap_fixed.bin
other

A char match shows the same rule with the gaps split around the covered range — including the surrogate gap in the middle of the char range, which is why the uncovered set is three ranges, not two:

Rust
fn main() { let c = 'x'; match c { 'a'..='m' => println!("first"), } }
Terminal
$ rustc --edition 2021 char_range.rs -o char_range.bin
error[E0004]: non-exhaustive patterns: `'\0'..='`'`, `'n'..='\u{d7ff}'` and `'\u{e000}'..='\u{10ffff}'` not covered
 --> char_range.rs:1:32
  |
1 | fn main() { let c = 'x'; match c { 'a'..='m' => println!("first"), } }
  |                                ^ patterns `'\0'..='`'`, `'n'..='\u{d7ff}'` and `'\u{e000}'..='\u{10ffff}'` not covered
  |
  = note: the matched value is of type `char`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
  |
1 | fn main() { let c = 'x'; match c { 'a'..='m' => println!("first"), '\0'..='`' | 'n'..='\u{d7ff}' | '\u{e000}'..='\u{10ffff}' => todo!(), } }
  |                                                                  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.
Rust
fn main() { let c = 'x'; match c { 'a'..='m' => println!("first"), _ => println!("other"), } }
Terminal
$ rustc --edition 2021 char_fixed.rs -o char_fixed.bin
$ ./char_fixed.bin
other

The error: a missing bool, Option, or Result case

bool has exactly two values, so matching only true is the enum error in miniature:

Rust
fn main() { let b = true; match b { true => println!("yes"), } }
Terminal
$ rustc --edition 2021 bool_missing.rs -o bool_missing.bin
error[E0004]: non-exhaustive patterns: `false` not covered
 --> bool_missing.rs:1:33
  |
1 | fn main() { let b = true; match b { true => println!("yes"), } }
  |                                 ^ pattern `false` not covered
  |
  = note: the matched value is of type `bool`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
1 | fn main() { let b = true; match b { true => println!("yes"), false => todo!(), } }
  |                                                            ++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.
Rust
fn main() { let b = false; match b { true => println!("yes"), false => println!("no"), } }
Terminal
$ rustc --edition 2021 bool_fixed.rs -o bool_fixed.bin
$ ./bool_fixed.bin
no

Option and Result are ordinary enums, so the same rule applies to the case programmers most often want to skip. Matching only Some leaves None uncovered:

Rust
fn main() { let x: Option<i32> = Some(3); match x { Some(n) => println!("{}", n), } }
Terminal
$ rustc --edition 2021 option_missing.rs -o option_missing.bin
error[E0004]: non-exhaustive patterns: `None` not covered
   --> option_missing.rs:1:49
    |
  1 | fn main() { let x: Option<i32> = Some(3); match x { Some(n) => println!("{}", n), } }
    |                                                 ^ pattern `None` not covered
    |
note: `Option<i32>` defined here
   --> /home/droopy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:598:1
    |
598 | pub enum Option<T> {
    | ^^^^^^^^^^^^^^^^^^
...
602 |     None,
    |     ---- not covered
    = note: the matched value is of type `Option<i32>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
  1 | fn main() { let x: Option<i32> = Some(3); match x { Some(n) => println!("{}", n), None => todo!(), } }
    |                                                                                 +++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.
Rust
fn main() { let x: Option<i32> = None; match x { Some(n) => println!("{}", n), None => println!("none"), } }
Terminal
$ rustc --edition 2021 option_fixed.rs -o option_fixed.bin
$ ./option_fixed.bin
none

Matching only Ok leaves Err(_) uncovered — the underscore inside the named pattern is the compiler showing that any error value at all is missing:

Rust
fn main() { let r: Result<i32, String> = Ok(1); match r { Ok(n) => println!("{}", n), } }
Terminal
$ rustc --edition 2021 result_missing.rs -o result_missing.bin
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
   --> result_missing.rs:1:55
    |
  1 | fn main() { let r: Result<i32, String> = Ok(1); match r { Ok(n) => println!("{}", n), } }
    |                                                       ^ pattern `Err(_)` not covered
    |
note: `Result<i32, String>` defined here
   --> /home/droopy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:558:1
    |
558 | pub enum Result<T, E> {
    | ^^^^^^^^^^^^^^^^^^^^^
...
567 |     Err(#[stable(feature = "rust1", since = "1.0.0")] E),
    |     --- not covered
    = note: the matched value is of type `Result<i32, String>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
  1 | fn main() { let r: Result<i32, String> = Ok(1); match r { Ok(n) => println!("{}", n), Err(_) => todo!(), } }
    |                                                                                     +++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.

The explicit repair handles the error value instead of discarding it:

Rust
fn main() { let r: Result<i32, String> = Err("bad".to_string()); match r { Ok(n) => println!("{}", n), Err(e) => println!("err: {}", e), } }
Terminal
$ rustc --edition 2021 result_fixed.rs -o result_fixed.bin
$ ./result_fixed.bin
err: bad

In real code the None and Err arms are rarely filler. They are where the absence or the failure gets its behavior — a default, a retry, a propagated error — which is why a wildcard in their place deserves a second thought.

The error: a missing tuple or struct combination

Patterns compose, and exhaustiveness is checked over the combinations. Matching (true, true) and (false, _) covers three of the four pairs of two bool values — and the compiler names the fourth:

Rust
fn main() { let t = (true, false); match t { (true, true) => println!("tt"), (false, _) => println!("f"), } }
Terminal
$ rustc --edition 2021 tuple_missing.rs -o tuple_missing.bin
error[E0004]: non-exhaustive patterns: `(true, false)` not covered
 --> tuple_missing.rs:1:42
  |
1 | fn main() { let t = (true, false); match t { (true, true) => println!("tt"), (false, _) => println!("f"), } }
  |                                          ^ pattern `(true, false)` not covered
  |
  = note: the matched value is of type `(bool, bool)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
1 | fn main() { let t = (true, false); match t { (true, true) => println!("tt"), (false, _) => println!("f"), (true, false) => todo!(), } }
  |                                                                                                         ++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.
Rust
fn main() { let t = (true, false); match t { (true, true) => println!("tt"), (true, false) => println!("tf"), (false, _) => println!("f"), } }
Terminal
$ rustc --edition 2021 tuple_fixed.rs -o tuple_fixed.bin
$ ./tuple_fixed.bin
tf

Struct patterns behave the same way, field by field. Here .. in the second arm covers both values of y when x is false, but nothing covers x: true, y: false:

Rust
struct P { x: bool, y: bool }
fn main() { let p = P { x: true, y: false }; match p { P { x: true, y: true } => println!("tt"), P { x: false, .. } => println!("f"), } }
Terminal
$ rustc --edition 2021 struct_missing.rs -o struct_missing.bin
error[E0004]: non-exhaustive patterns: `P { x: true, y: false }` not covered
 --> struct_missing.rs:2:52
  |
2 | fn main() { let p = P { x: true, y: false }; match p { P { x: true, y: true } => println!("tt"), P { x: false, .. } => println!("f"),...
  |                                                    ^ pattern `P { x: true, y: false }` not covered
  |
note: `P` defined here
 --> struct_missing.rs:1:8
  |
1 | struct P { x: bool, y: bool }
  |        ^
  = note: the matched value is of type `P`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
2 | fn main() { let p = P { x: true, y: false }; match p { P { x: true, y: true } => println!("tt"), P { x: false, .. } => println!("f"), P { x: true, y: false } => todo!(), } }
  |                                                                                                                                     ++++++++++++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.

Adding that exact combination repairs it:

Rust
struct P { x: bool, y: bool }
fn main() { let p = P { x: true, y: false }; match p { P { x: true, y: true } => println!("tt"), P { x: true, y: false } => println!("tf"), P { x: false, .. } => println!("f"), } }
Terminal
$ rustc --edition 2021 struct_fixed.rs -o struct_fixed.bin
$ ./struct_fixed.bin
tf

When combinations multiply, a wildcard arm for the combinations that share an outcome is reasonable — but name the meaningful combinations first, so the wildcard holds only what is genuinely left over.

The error: a nested enum

Nesting does not hide cases; it multiplies them. Outer::Inner carries an Option, so covering Inner(Some(n)) and Other still leaves Inner(None):

Rust
enum Outer { Inner(Option<i32>), Other }
fn main() { let x = Outer::Inner(Some(1)); match x { Outer::Inner(Some(n)) => println!("{}", n), Outer::Other => println!("other"), } }
Terminal
$ rustc --edition 2021 nested_enum.rs -o nested_enum.bin
error[E0004]: non-exhaustive patterns: `Outer::Inner(None)` not covered
 --> nested_enum.rs:2:50
  |
2 | fn main() { let x = Outer::Inner(Some(1)); match x { Outer::Inner(Some(n)) => println!("{}", n), Outer::Other => println!("other"), } }
  |                                                  ^ pattern `Outer::Inner(None)` not covered
  |
note: `Outer` defined here
 --> nested_enum.rs:1:6
  |
1 | enum Outer { Inner(Option<i32>), Other }
  |      ^^^^^   ----- not covered
  = note: the matched value is of type `Outer`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
2 | fn main() { let x = Outer::Inner(Some(1)); match x { Outer::Inner(Some(n)) => println!("{}", n), Outer::Other => println!("other"), Outer::Inner(None) => todo!(), } }
  |                                                                                                                                   +++++++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.
Rust
enum Outer { Inner(Option<i32>), Other }
fn main() { let x = Outer::Inner(None); match x { Outer::Inner(Some(n)) => println!("{}", n), Outer::Inner(None) => println!("none"), Outer::Other => println!("other"), } }
Terminal
$ rustc --edition 2021 nested_fixed.rs -o nested_fixed.bin
warning: variant `Other` is never constructed
 --> nested_fixed.rs:1:34
  |
1 | enum Outer { Inner(Option<i32>), Other }
  |      ----- variant in this enum  ^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: 1 warning emitted
$ ./nested_fixed.bin
none

The trap: a guard does not make a match exhaustive

Trap
A match arm with a guard looks like it covers its pattern — Some(n) if n > 0 sits right there in the match — but a guard is a runtime test the compiler cannot evaluate, so the guarded arm counts for nothing toward exhaustiveness. This match covers None and, apparently, Some — and still fails, because a Some whose guard is false would fall through:
Rust
fn main() { let x: Option<i32> = Some(5); match x { Some(n) if n > 0 => println!("pos"), None => println!("none"), } }
Terminal
$ rustc --edition 2021 guard_not_exhaustive.rs -o guard_not_exhaustive.bin
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
   --> guard_not_exhaustive.rs:1:49
    |
  1 | fn main() { let x: Option<i32> = Some(5); match x { Some(n) if n > 0 => println!("pos"), None => println!("none"), } }
    |                                                 ^ pattern `Some(_)` not covered
    |
note: `Option<i32>` defined here
   --> /home/droopy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:598:1
    |
598 | pub enum Option<T> {
    | ^^^^^^^^^^^^^^^^^^
...
606 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ---- not covered
    = note: the matched value is of type `Option<i32>`
    = note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
  1 | fn main() { let x: Option<i32> = Some(5); match x { Some(n) if n > 0 => println!("pos"), None => println!("none"), Some(_) => todo!(), } }
    |                                                                                                                  ++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.

The diagnostic carries the note that settles it: match arms with guards don't count towards exhaustivity. The repair is an unguarded arm for the values the guard rejects:

Rust
fn main() { let x: Option<i32> = Some(-1); match x { Some(n) if n > 0 => println!("pos"), Some(_) => println!("nonpos"), None => println!("none"), } }
Terminal
$ rustc --edition 2021 guard_fixed.rs -o guard_fixed.bin
$ ./guard_fixed.bin
nonpos

Treat every guarded arm as an addition to an already-exhaustive match, never as part of the coverage itself.

The error: a #[non_exhaustive] enum from another crate

An enum marked #[non_exhaustive] promises its owner may add variants later, so a match on it in another crate must include a wildcard even when every currently known variant is named. That rule only bites across a crate boundary. This library defines the enum:

Rust
#[non_exhaustive]
pub enum E { A, B }
Command
$ rustc --edition 2021 --crate-type rlib libne.rs -o liblibne.rlib

This program, in a separate crate, names both variants — and still fails, with the uncovered pattern itself reported as _:

Rust
extern crate libne; fn main() { let x = libne::E::A; match x { libne::E::A => println!("a"), libne::E::B => println!("b"), } }
Terminal
$ rustc --edition 2021 --extern libne=liblibne.rlib cross_ne.rs -o cross_ne.bin
error[E0004]: non-exhaustive patterns: `_` not covered
 --> cross_ne.rs:1:60
  |
1 | extern crate libne; fn main() { let x = libne::E::A; match x { libne::E::A => println!("a"), libne::E::B => println!("b"), } }
  |                                                            ^ pattern `_` not covered
  |
note: `E` defined here
 --> libne.rs:2:1
  |
2 | pub enum E { A, B }
  | ^^^^^^^^^^
  = note: the matched value is of type `E`
  = note: `E` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
1 | extern crate libne; fn main() { let x = libne::E::A; match x { libne::E::A => println!("a"), libne::E::B => println!("b"), _ => todo!(), } }
  |                                                                                                                          ++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0004`.
Rust
extern crate libne; fn main() { let x = libne::E::B; match x { libne::E::A => println!("a"), libne::E::B => println!("b"), _ => println!("future"), } }
Terminal
$ rustc --edition 2021 --extern libne=liblibne.rlib cross_ne_fixed.rs -o cross_ne_fixed.bin
$ ./cross_ne_fixed.bin
b

Inside the crate that defines the enum, the same match without a wildcard compiles — #[non_exhaustive] constrains downstream matches, not the owner's own. The wildcard arm in downstream code is where a future variant lands, so give it a deliberate outcome: a default, an error, or an explicit "unsupported" path — not a silent copy of another variant's behavior.

Wildcard or explicit arms

The error index offers both repairs — cover cases explicitly, or add the underscore wildcard to match "anything else" — and they are not interchangeable.

Use explicit arms when the type is an enum you own, when each case needs different behavior, and when you want a future variant to break compilation at every match until it is handled. That breakage is a feature: it turns "a new case exists" into a list of places that must decide about it.

Use a wildcard when the remaining values genuinely share one outcome — the tail of a numeric range, the uninteresting combinations, a default — and when the type is #[non_exhaustive], where a wildcard is required downstream no matter what. Place the wildcard last: arms are tried in order, so a wildcard placed first matches everything and every later arm is dead. That mistake is not E0004 — the match is exhaustive — it compiles with an unreachable pattern warning and silently discards the specific arms below it.

The cost of a wildcard is exactly its convenience: it also catches the variant added next year, routing a case nobody has thought about into the default behavior without a compile error anywhere. Prefer the smallest wildcard that is honest — a named leftover pattern such as Err(_) or P { x: false, .. } where the shape is known, and a bare _ only where any remaining value really is equivalent.

Neighboring shapes that are not E0004

A refutable pattern in a plain let looks like the same complaint — a pattern that does not cover every value — but it is a different error, E0005, because a let binding requires an irrefutable pattern:

Rust
fn main() { let x: Option<i32> = Some(7); let Some(n) = x; println!("{}", n); }
Terminal
$ rustc --edition 2021 let_refutable.rs -o let_refutable.bin
error[E0005]: refutable pattern in local binding
 --> let_refutable.rs:1:47
  |
1 | fn main() { let x: Option<i32> = Some(7); let Some(n) = x; println!("{}", n); }
  |                                               ^^^^^^^ pattern `None` not covered
  |
  = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
  = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
  = note: the matched value is of type `Option<i32>`
help: you might want to use `let...else` to handle the variant that isn't matched
  |
1 | fn main() { let x: Option<i32> = Some(7); let Some(n) = x else { todo!() }; println!("{}", n); }
  |                                                           ++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0005`.

Do not file that under E0004 or fix it with match arms. Its repairs are let ... else, which must diverge on the unmatched case, or a match or if let when both cases continue:

Rust
fn main() { let x: Option<i32> = Some(7); let Some(n) = x else { println!("none"); return; }; println!("{}", n); }
Terminal
$ rustc --edition 2021 let_else_ok.rs -o let_else_ok.bin
$ ./let_else_ok.bin
7

Checklist

  • Read the uncovered value in the E0004 header first. It is a concrete value, range, or combination — it tells you exactly which case has no behavior yet.
  • For an enum you own, add the missing variant as its own arm. Let future variants break the match again; that breakage is the reminder to decide.
  • For numbers, chars, and large combination spaces, cover the meaningful cases explicitly and close the rest with a wildcard or a covering range.
  • Never count a guarded arm toward coverage. Add an unguarded arm for the values the guard can reject.
  • Downstream of a #[non_exhaustive] type, always include a wildcard arm, and give it a deliberate outcome for variants that do not exist yet.
  • Keep the wildcard last, and prefer a named leftover pattern over a bare _ when the shape of what remains is known.
  • Do not silence the error with a wildcard before asking what the missing case should do. None, Err, and a new variant are usually behavior, not filler.
  • If the diagnostic says E0005, stop: that is a refutable let, repaired with let ... else or a match, not an exhaustiveness fix.

Sources

Keep Exploring