Skip to content

Commit 256acb4

Browse files
committed
Fix clippy::unnecessary_map_or warning
``` error: this `map_or` is redundant --> src/cargo.rs:84:41 | 84 | need_doctest_in_workspace = cmd!(config.cargo(), "-Z", "help") | _________________________________________^ 85 | | .read() 86 | | .map_or(false, |s| s.contains("doctest-in-workspace")); | |______________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or = note: `-D clippy::unnecessary-map-or` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_or)]` help: use is_ok_and instead | 84 ~ need_doctest_in_workspace = cmd!(config.cargo(), "-Z", "help") 85 ~ .read().is_ok_and(|s| s.contains("doctest-in-workspace")); | error: this `map_or` is redundant --> src/context.rs:156:24 | 156 | if cmd!("rustup", "toolchain", "list") | ________________________^ 157 | | .read() 158 | | .map_or(false, |t| t.contains(toolchain)) | |_________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or help: use is_ok_and instead | 156 ~ if cmd!("rustup", "toolchain", "list") 157 + .read().is_ok_and(|t| t.contains(toolchain)) | error: this `map_or` is redundant --> src/main.rs:701:24 | 701 | if p.file_name() | ________________________^ 702 | | .map_or(false, |f| f == "incremental" || f == ".fingerprint" || f == "out") | |___________________________________________________________________________________________________^ help: use is_some_and instead: `p.file_name().is_some_and(|f| f == "incremental" || f == ".fingerprint" || f == "out")` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or error: this `map_or` is redundant --> src/main.rs:1313:20 | 1313 | if p.extension().map_or(false, |e| e == "rs") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `p.extension().is_some_and(|e| e == "rs")` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or ```
1 parent 232d762 commit 256acb4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/cargo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Workspace {
8383
if doctests {
8484
need_doctest_in_workspace = cmd!(config.cargo(), "-Z", "help")
8585
.read()
86-
.map_or(false, |s| s.contains("doctest-in-workspace"));
86+
.is_ok_and(|s| s.contains("doctest-in-workspace"));
8787
}
8888

8989
let target_dir =

src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl Context {
155155
let toolchain = sysroot.file_name().unwrap();
156156
if cmd!("rustup", "toolchain", "list")
157157
.read()
158-
.map_or(false, |t| t.contains(toolchain))
158+
.is_ok_and(|t| t.contains(toolchain))
159159
{
160160
// If toolchain is installed from rustup and llvm-tools-preview is not installed,
161161
// suggest installing llvm-tools-preview via rustup.

src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ fn object_files(cx: &Context) -> Result<Vec<OsString>> {
699699
let p = e.path();
700700
if p.is_dir() {
701701
if p.file_name()
702-
.map_or(false, |f| f == "incremental" || f == ".fingerprint" || f == "out")
702+
.is_some_and(|f| f == "incremental" || f == ".fingerprint" || f == "out")
703703
{
704704
// Ignore incremental compilation related files and output from build scripts.
705705
return false;
@@ -1310,7 +1310,7 @@ fn resolve_excluded_paths(cx: &Context) -> Vec<Utf8PathBuf> {
13101310
for _ in WalkDir::new(excluded).into_iter().filter_entry(|e| {
13111311
let p = e.path();
13121312
if !p.is_dir() {
1313-
if p.extension().map_or(false, |e| e == "rs") {
1313+
if p.extension().is_some_and(|e| e == "rs") {
13141314
let p = p.strip_prefix(&cx.ws.metadata.workspace_root).unwrap_or(p);
13151315
excluded_path.push(p.to_owned().try_into().unwrap());
13161316
}

0 commit comments

Comments
 (0)