Skip to content

Enable clippy::unnested_or_patterns lint #167

Description

@tupe12334

What

Enable the clippy::unnested_or_patterns lint (from the pedantic group) at deny level in core/Cargo.toml's [lints.clippy] table.

What it catches

unnested_or_patterns flags patterns where multiple variants of an or-pattern share the same outer constructor and could be collapsed into a single nested or-pattern. For example:

// flagged
match x {
    Some(1) | Some(2) => ...,
}
// preferred
match x {
    Some(1 | 2) => ...,
}

It applies to any nested or-pattern position — enum tuple variants, struct fields, tuples, slices, references, etc.

Why it improves code quality

  • Less repetition — the shared constructor is written once, not per alternative.
  • More readable — the real variation between arms is surfaced at the inner level instead of being buried under a repeated wrapper.
  • Easier to extend — adding another alternative is a one-token change inside the nested or-pattern.

This matches the repo's existing incremental clippy ratchet (every PR promotes one more lint to deny). The current codebase has zero violations, so enabling it is a clean, no-fix guard that prevents nested-or-pattern duplication from creeping in going forward.


This issue was opened by the Clippy lint improvements → issue + PR (Rust repos) → Slack routine of moadim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions