Skip to content

single_match should not lint exhaustive match #8282

Closed
@camsteffen

Description

@camsteffen

Summary

single_match should not lint an exhaustive match

Lint Name

single_match

Reproducer

I tried this code:

enum Foo { Bar }

match Some(Foo::Bar) {
    Some(Foo::Bar) => {dbg!()}
    None => {}
}

I saw this happen:

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
 --> src/main.rs:5:5
  |
5 | /     match Some(Foo::Bar) {
6 | |         Some(Foo::Bar) => {dbg!()}
7 | |         None => {}
8 | |     }
  | |_____^ help: try this: `if let Some(Foo::Bar) = Some(Foo::Bar) {dbg!()}`

I expected to see this happen: nothing

Version

No response

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions