Skip to content

Add a lint for patterns for enum variants with no fields (unit variants) that don't need to use braces #16292

@ErichDonGubler

Description

@ErichDonGubler

Description

With an enum like this one:

enum Hey { What, YaFace, }

...it's possible to match it with braces in a destructuring pattern using braces with a rest pattern, e.g.:

match Hey::What { Hey::YaFace { .. } => todo!(), // ... }

...despite having no fields. When refactoring enum pattern matching, these can be left in when a variant has its fields removed. It might be nice for Clippy to note when such braces are no longer necessary.

Version

rustc 1.92.0 (ded5c06cf 2025-12-08) binary: rustc commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234 commit-date: 2025-12-08 host: aarch64-apple-darwin release: 1.92.0 LLVM version: 21.1.3 

Additional Labels

@rustbot label C-enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions