-
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 thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.
Description
#![feature(const_if_match)]
pub const fn is_some(x: Option<u32>) -> bool {
if let Some(_) = x { true } else { false }
}
Checking playground v0.0.1 (/playground)
warning: redundant pattern matching, consider using `is_some()`
--> src/lib.rs:3:12
|
3 | if let Some(_) = x { true } else { false }
| -------^^^^^^^---- help: try this: `if x.is_some()`
|
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
However, Option::is_some
is not const fn
in nightly-2020-06-07
, so it can't be used in const fn
.
Version: 2020-06-07 0262de5
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.