Skip to content

Commit f70920a

Browse files
committed
Resolve unnecessary_map_or clippy lint
warning: this `map_or` can be simplified --> build.rs:76:38 | 76 | if cfg!(not(feature = "std")) && rustc.map_or(false, |rustc| rustc < 81) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or = note: `-W clippy::unnecessary-map-or` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::unnecessary_map_or)]` help: use `is_some_and` instead | 76 - if cfg!(not(feature = "std")) && rustc.map_or(false, |rustc| rustc < 81) { 76 + if cfg!(not(feature = "std")) && rustc.is_some_and(|rustc| rustc < 81) { | warning: this `map_or` can be simplified --> impl/src/expand.rs:385:13 | 385 | / v.attrs 386 | | .display 387 | | .as_ref() 388 | | .map_or(false, |display| display.has_bonus_display) | |___________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or = note: `-W clippy::unnecessary-map-or` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::unnecessary_map_or)]` help: use `is_some_and` instead | 388 - .map_or(false, |display| display.has_bonus_display) 388 + .is_some_and(|display| display.has_bonus_display) | warning: this `map_or` can be simplified --> impl/src/prop.rs:131:8 | 131 | if from_field.map_or(false, |from_field| { | ________^ 132 | | from_field.member == backtrace_field.member 133 | | }) { | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or help: use `is_some_and` instead | 131 - if from_field.map_or(false, |from_field| { 131 + if from_field.is_some_and(|from_field| { | warning: this `map_or` can be simplified --> impl/src/valid.rs:242:32 | 242 | Type::Reference(ty) => ty | ________________________________^ 243 | | .lifetime 244 | | .as_ref() 245 | | .map_or(false, |lifetime| lifetime.ident != "static"), | |_________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or help: use `is_some_and` instead | 245 - .map_or(false, |lifetime| lifetime.ident != "static"), 245 + .is_some_and(|lifetime| lifetime.ident != "static"), |
1 parent 910be13 commit f70920a

4 files changed

Lines changed: 4 additions & 6 deletions

File tree

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() {
7373
// core::error::Error stabilized in Rust 1.81
7474
// https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#coreerrorerror
7575
let rustc = rustc_minor_version();
76-
if cfg!(not(feature = "std")) && rustc.map_or(false, |rustc| rustc < 81) {
76+
if cfg!(not(feature = "std")) && rustc.is_some_and(|rustc| rustc < 81) {
7777
println!("cargo:rustc-cfg=feature=\"std\"");
7878
}
7979

impl/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ fn impl_enum(input: Enum) -> TokenStream {
385385
v.attrs
386386
.display
387387
.as_ref()
388-
.map_or(false, |display| display.has_bonus_display)
388+
.is_some_and(|display| display.has_bonus_display)
389389
});
390390
let use_as_display = use_as_display(has_bonus_display);
391391
let void_deref = if input.variants.is_empty() {

impl/src/prop.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ fn distinct_backtrace_field<'a, 'b>(
128128
backtrace_field: &'a Field<'b>,
129129
from_field: Option<&Field>,
130130
) -> Option<&'a Field<'b>> {
131-
if from_field.map_or(false, |from_field| {
132-
from_field.member == backtrace_field.member
133-
}) {
131+
if from_field.is_some_and(|from_field| from_field.member == backtrace_field.member) {
134132
None
135133
} else {
136134
Some(backtrace_field)

impl/src/valid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ fn contains_non_static_lifetime(ty: &Type) -> bool {
242242
Type::Reference(ty) => ty
243243
.lifetime
244244
.as_ref()
245-
.map_or(false, |lifetime| lifetime.ident != "static"),
245+
.is_some_and(|lifetime| lifetime.ident != "static"),
246246
_ => false, // maybe implement later if there are common other cases
247247
}
248248
}

0 commit comments

Comments
 (0)