-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
This example should not yield any warning.
Lint Name
redundant_pattern_matching
Reproducer
I tried this code:
fn _test<T>(boolean: bool, maybe_some: Option<T>) -> bool {
matches!(maybe_some, None if !boolean)
}
I saw this happen:
warning: redundant pattern matching, consider using `is_none()`
--> src/lib.rs:2:5
|
2 | matches!(maybe_some, None if !boolean)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `maybe_some.is_none()`
|
Expected:
fn _test<T>(boolean: bool, maybe_some: Option<T>) -> bool {
// matches!(maybe_some, None if !boolean)
maybe_some.is_none() && !boolean
}
Version
rustc 1.73.0-nightly (33a2c2487 2023-07-12)
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have