mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 06:48:00 +00:00
Resolve question_mark clippy lint in build script
warning: this `match` expression can be replaced with `?`
--> serde/build.rs:111:17
|
111 | let rustc = match env::var_os("RUSTC") {
| _________________^
112 | | Some(rustc) => rustc,
113 | | None => return None,
114 | | };
| |_____^ help: try instead: `env::var_os("RUSTC")?`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
= note: `-W clippy::question-mark` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::question_mark)]`
warning: this `match` expression can be replaced with `?`
--> serde/build.rs:131:16
|
131 | let next = match pieces.next() {
| ________________^
132 | | Some(next) => next,
133 | | None => return None,
134 | | };
| |_____^ help: try instead: `pieces.next()?`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
This commit is contained in:
+5
-23
@@ -1,6 +1,6 @@
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
use std::str::{self, FromStr};
|
||||
use std::str;
|
||||
|
||||
// The rustc-cfg strings below are *not* public API. Please let us know by
|
||||
// opening a GitHub issue if your build environment requires some way to enable
|
||||
@@ -108,30 +108,12 @@ fn main() {
|
||||
}
|
||||
|
||||
fn rustc_minor_version() -> Option<u32> {
|
||||
let rustc = match env::var_os("RUSTC") {
|
||||
Some(rustc) => rustc,
|
||||
None => return None,
|
||||
};
|
||||
|
||||
let output = match Command::new(rustc).arg("--version").output() {
|
||||
Ok(output) => output,
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
||||
let version = match str::from_utf8(&output.stdout) {
|
||||
Ok(version) => version,
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
||||
let rustc = env::var_os("RUSTC")?;
|
||||
let output = Command::new(rustc).arg("--version").output().ok()?;
|
||||
let version = str::from_utf8(&output.stdout).ok()?;
|
||||
let mut pieces = version.split('.');
|
||||
if pieces.next() != Some("rustc 1") {
|
||||
return None;
|
||||
}
|
||||
|
||||
let next = match pieces.next() {
|
||||
Some(next) => next,
|
||||
None => return None,
|
||||
};
|
||||
|
||||
u32::from_str(next).ok()
|
||||
pieces.next()?.parse().ok()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user