Summary
wildcard_enum_match_arm does not fire when matching Option<LocalEnum> or Result<LocalEnum, _> with _. The wildcard silently covers both None and any unmatched Some(Variant), meaning new enum variants are swallowed without warning — exactly what this lint is designed to prevent.
The lint skips Option because it's a foreign/std type. But when the inner type is a local enum, the _ arm defeats exhaustiveness protection. The safe alternative is to destructure the Option first and match the inner enum directly, but nothing guides the developer toward this pattern.
Proposal: Either extend wildcard_enum_match_arm to fire when a wildcard covers Some(T)/Ok(T) where T is an enum that would otherwise trigger the lint, or introduce a separate lint for this case.
I would be interested in contributing to either extending the lint or creating a new one, depending on
Version
rustc 1.95.0 (59807616e 2026-04-14)
clippy 0.1.96 (ac68faa20c 2026-05-25)
Lint Name
wildcard_enum_match_arm
Reproducer
I tried this code:
#![deny(clippy::wildcard_enum_match_arm)]
enum Action {
Create,
Delete,
}
fn handle(action: Option<Action>) -> &'static str {
match action {
Some(Action::Create) => "creating",
_ => "nothing", // covers None AND Some(Action::Delete)
}
}
I expected to see this happen: a warning that the _ arm covers Some(Action::Delete) (and would silently cover any future variants added to Action).
Instead, this happened: no warning. If a developer adds Action::Update, it is silently caught by _ with no compiler or clippy diagnostic.
The safe pattern that preserves exhaustiveness:
fn handle(action: Option<Action>) -> &'static str {
let Some(action) = action else { return "nothing" };
match action {
Action::Create => "creating",
Action::Delete => "nothing",
}
}
Version
rustc 1.96.0 (ac68faa20 2026-05-25)
binary: rustc
commit-hash: ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96
commit-date: 2026-05-25
host: x86_64-unknown-linux-gnu
release: 1.96.0
LLVM version: 22.1.2
Summary
wildcard_enum_match_armdoes not fire when matchingOption<LocalEnum>orResult<LocalEnum, _>with_. The wildcard silently covers bothNoneand any unmatchedSome(Variant), meaning new enum variants are swallowed without warning — exactly what this lint is designed to prevent.The lint skips
Optionbecause it's a foreign/std type. But when the inner type is a local enum, the_arm defeats exhaustiveness protection. The safe alternative is to destructure theOptionfirst and match the inner enum directly, but nothing guides the developer toward this pattern.Proposal: Either extend
wildcard_enum_match_armto fire when a wildcard coversSome(T)/Ok(T)whereTis an enum that would otherwise trigger the lint, or introduce a separate lint for this case.I would be interested in contributing to either extending the lint or creating a new one, depending on
Version
Lint Name
wildcard_enum_match_arm
Reproducer
I tried this code:
I expected to see this happen: a warning that the
_arm coversSome(Action::Delete)(and would silently cover any future variants added toAction).Instead, this happened: no warning. If a developer adds
Action::Update, it is silently caught by_with no compiler or clippy diagnostic.The safe pattern that preserves exhaustiveness:
Version