Skip to content

Commit 8d27fe7

Browse files
committedJan 7, 2024
Auto merge of #3495 - samueltardieu:question-mark, r=JohnTitor
Simplify build.rs by using the question mark operator The `question_mark` clippy lint currently overlooks some patterns that could be replaced by the question mark operator. This will be fixed shortly by rust-lang/rust-clippy#11994.
2 parents 9af603f + 426ad68 commit 8d27fe7

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed
 

‎build.rs

+6-20
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,14 @@ fn rustc_minor_nightly() -> (u32, bool) {
233233
}
234234

235235
fn which_freebsd() -> Option<i32> {
236-
let output = std::process::Command::new("freebsd-version").output().ok();
237-
if output.is_none() {
238-
return None;
239-
}
240-
let output = output.unwrap();
236+
let output = std::process::Command::new("freebsd-version")
237+
.output()
238+
.ok()?;
241239
if !output.status.success() {
242240
return None;
243241
}
244242

245-
let stdout = String::from_utf8(output.stdout).ok();
246-
if stdout.is_none() {
247-
return None;
248-
}
249-
let stdout = stdout.unwrap();
243+
let stdout = String::from_utf8(output.stdout).ok()?;
250244

251245
match &stdout {
252246
s if s.starts_with("10") => Some(10),
@@ -263,20 +257,12 @@ fn emcc_version_code() -> Option<u64> {
263257
let output = std::process::Command::new("emcc")
264258
.arg("-dumpversion")
265259
.output()
266-
.ok();
267-
if output.is_none() {
268-
return None;
269-
}
270-
let output = output.unwrap();
260+
.ok()?;
271261
if !output.status.success() {
272262
return None;
273263
}
274264

275-
let stdout = String::from_utf8(output.stdout).ok();
276-
if stdout.is_none() {
277-
return None;
278-
}
279-
let version = stdout.unwrap();
265+
let version = String::from_utf8(output.stdout).ok()?;
280266

281267
// Some Emscripten versions come with `-git` attached, so split the
282268
// version string also on the `-` char.

0 commit comments

Comments
 (0)