diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index a081f6189d7..eb1941cd889 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -188,7 +188,7 @@ fn fix_bin_or_dylib(&self, fname: &Path) { patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]); } - self.try_run(patchelf.arg(fname)).unwrap(); + let _ = self.try_run(patchelf.arg(fname)); } fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) { diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs index c97b7592737..70b91700043 100644 --- a/src/bootstrap/run.rs +++ b/src/bootstrap/run.rs @@ -27,8 +27,7 @@ fn run(self, builder: &Builder<'_>) { try_run( builder, &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src), - ) - .unwrap(); + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -40,17 +39,17 @@ fn make_run(run: RunConfig<'_>) { } } -fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> { +fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { - if let Err(e) = builder.try_run(cmd) { + if builder.try_run(cmd).is_err() { let mut failures = builder.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); - return Err(e); + return false; } } else { builder.run(cmd); } - Ok(()) + true } #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a34465ebffb..d7303427c3b 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -48,17 +48,17 @@ // build for, so there is no entry for "aarch64-apple-darwin" here. ]; -fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> { +fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { - if let Err(e) = builder.try_run(cmd) { + if builder.try_run(cmd).is_err() { let mut failures = builder.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); - return Err(e); + return false; } } else { builder.run(cmd); } - Ok(()) + true } fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { @@ -187,8 +187,7 @@ fn run(self, builder: &Builder<'_>) { try_run( builder, builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")), - ) - .unwrap(); + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -241,8 +240,7 @@ fn run(self, builder: &Builder<'_>) { builder.default_doc(&[]); builder.ensure(crate::doc::Rustc::new(builder.top_stage, self.target, builder)); - try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target))) - .unwrap(); + try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target))); } } @@ -288,8 +286,7 @@ fn run(self, builder: &Builder<'_>) { .args(builder.config.test_args()) .env("RUSTC", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)), - ) - .unwrap(); + ); } } @@ -855,7 +852,7 @@ fn run(self, builder: &Builder<'_>) { util::lld_flag_no_threads(self.compiler.host.contains("windows")), ); } - try_run(builder, &mut cmd).unwrap(); + try_run(builder, &mut cmd); } } @@ -1106,7 +1103,7 @@ fn run(self, builder: &Builder<'_>) { } builder.info("tidy check"); - try_run(builder, &mut cmd).unwrap(); + try_run(builder, &mut cmd); builder.ensure(ExpandYamlAnchors); @@ -1154,8 +1151,7 @@ fn run(self, builder: &Builder<'_>) { try_run( builder, &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src), - ) - .unwrap(); + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1948,7 +1944,7 @@ fn run_ext_doc(self, builder: &Builder<'_>) { compiler.host, ); let _time = util::timeit(&builder); - let toolstate = if try_run(builder, &mut rustbook_cmd).is_ok() { + let toolstate = if try_run(builder, &mut rustbook_cmd) { ToolState::TestPass } else { ToolState::TestFail @@ -2106,7 +2102,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> cmd.arg("--test-args").arg(test_args); if builder.config.verbose_tests { - try_run(builder, &mut cmd).is_ok() + try_run(builder, &mut cmd) } else { try_run_quiet(builder, &mut cmd) } @@ -2134,7 +2130,7 @@ fn run(self, builder: &Builder<'_>) { let src = builder.src.join(relative_path); let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); - let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)).is_ok() { + let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) { ToolState::TestPass } else { ToolState::TestFail @@ -2684,7 +2680,7 @@ fn run(self, builder: &Builder<'_>) { .current_dir(builder.src.join("src/bootstrap/")); // NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible. // Use `python -m unittest` manually if you want to pass arguments. - try_run(builder, &mut check_bootstrap).unwrap(); + try_run(builder, &mut check_bootstrap); let host = builder.config.build; let compiler = builder.compiler(0, host); @@ -2756,7 +2752,7 @@ fn run(self, builder: &Builder<'_>) { } builder.info("platform support check"); - try_run(builder, &mut cargo.into()).unwrap(); + try_run(builder, &mut cargo.into()); } } @@ -2836,7 +2832,7 @@ fn run(self, builder: &Builder<'_>) { cmd.env("CARGO", &builder.initial_cargo); cmd.env("RUSTC", &builder.initial_rustc); cmd.env("TMP_DIR", &tmpdir); - try_run(builder, &mut cmd).unwrap(); + try_run(builder, &mut cmd); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {