Skip to content

Commit

Permalink
test_suite: Fix clippy::unnecessary_map_or warning
Browse files Browse the repository at this point in the history
```
error: this `map_or` is redundant
  --> test_suite/build.rs:35:5
   |
35 | /     env::var_os("RUSTC")
36 | |         .and_then(|rustc| Command::new(rustc).arg("--version").output().ok())
37 | |         .and_then(|output| String::from_utf8(output.stdout).ok())
38 | |         .map_or(false, |version| version.contains("nightly") || version.contains("dev"))
   | |________________________________________________________________________________________^
   |
   = 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_some_and instead
   |
35 ~     env::var_os("RUSTC")
36 +         .and_then(|rustc| Command::new(rustc).arg("--version").output().ok())
37 +         .and_then(|output| String::from_utf8(output.stdout).ok()).is_some_and(|version| version.contains("nightly") || version.contains("dev"))
   |
```
  • Loading branch information
taiki-e committed Nov 17, 2024
1 parent ddc9ea9 commit c810b2a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test_suite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ fn is_nightly() -> bool {
env::var_os("RUSTC")
.and_then(|rustc| Command::new(rustc).arg("--version").output().ok())
.and_then(|output| String::from_utf8(output.stdout).ok())
.map_or(false, |version| version.contains("nightly") || version.contains("dev"))
.is_some_and(|version| version.contains("nightly") || version.contains("dev"))
}

0 comments on commit c810b2a

Please sign in to comment.