-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
The clippy::redundant_pattern_matching lint only checks for _ patterns, and not other infallible patterns such as:
- Infallible tuple patterns e.g.
(_, _) - Infallible enum patterns e.g.
Foo::BarwhereBaris the only variant ofFoo - Infalliable struct patterns e.g.
Foo { bar: _ }
The lint should be checking for all of these.
Lint Name
clippy::redundant_pattern_matching
Reproducer
I tried this code:
#![allow(clippy::disallowed_names)]
enum Baz {
Qux
}
struct Quux {
#[allow(dead_code)]
corge: bool,
}
fn main() {
let foo = Some((2, 4));
let bar = Some(Baz::Qux);
let grault = Some(Quux {
corge: true,
});
if let Some((_, _)) = foo {}
if let Some(Baz::Qux) = bar {}
if let Some(Quux { corge: _ }) = grault {}
}I expected to receive multiple warnings from the clippy::redundant_pattern_matching lint, since this pattern matching is redundant, but instead, there was no warning.
Version
rustc 1.93.0-nightly (83e49b75e 2025-12-03)
binary: rustc
commit-hash: 83e49b75e7daf827e4390ae0ccbcb0d0e2c96493
commit-date: 2025-12-03
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.5
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't