Skip to content

Various infalliable patterns in clippy::redundant_pattern_matching #16235

@akiramusic000

Description

@akiramusic000

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::Bar where Bar is the only variant of Foo
  • 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

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions