Skip to content

Commit 1e6db34

Browse files
committed
Auto merge of rust-lang#113214 - GuillaumeGomez:try-run-fix, r=ozkanonur,jyn514
Don't fail early if `try_run` returns an error Fixes rust-lang#113208. Follow-up of rust-lang#112962. r? `@jyn514`
2 parents da1d099 + 98336f8 commit 1e6db34

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

Diff for: src/bootstrap/download.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Config {
188188
patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]);
189189
}
190190

191-
self.try_run(patchelf.arg(fname)).unwrap();
191+
let _ = self.try_run(patchelf.arg(fname));
192192
}
193193

194194
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {

Diff for: src/bootstrap/run.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ impl Step for ExpandYamlAnchors {
2727
try_run(
2828
builder,
2929
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
30-
)
31-
.unwrap();
30+
);
3231
}
3332

3433
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -40,17 +39,17 @@ impl Step for ExpandYamlAnchors {
4039
}
4140
}
4241

43-
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> {
42+
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
4443
if !builder.fail_fast {
45-
if let Err(e) = builder.try_run(cmd) {
44+
if builder.try_run(cmd).is_err() {
4645
let mut failures = builder.delayed_failures.borrow_mut();
4746
failures.push(format!("{:?}", cmd));
48-
return Err(e);
47+
return false;
4948
}
5049
} else {
5150
builder.run(cmd);
5251
}
53-
Ok(())
52+
true
5453
}
5554

5655
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]

Diff for: src/bootstrap/test.rs

+16-20
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ const MIR_OPT_BLESS_TARGET_MAPPING: &[(&str, &str)] = &[
4848
// build for, so there is no entry for "aarch64-apple-darwin" here.
4949
];
5050

51-
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> {
51+
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
5252
if !builder.fail_fast {
53-
if let Err(e) = builder.try_run(cmd) {
53+
if builder.try_run(cmd).is_err() {
5454
let mut failures = builder.delayed_failures.borrow_mut();
5555
failures.push(format!("{:?}", cmd));
56-
return Err(e);
56+
return false;
5757
}
5858
} else {
5959
builder.run(cmd);
6060
}
61-
Ok(())
61+
true
6262
}
6363

6464
fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
@@ -187,8 +187,7 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
187187
try_run(
188188
builder,
189189
builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
190-
)
191-
.unwrap();
190+
);
192191
}
193192

194193
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -241,8 +240,7 @@ impl Step for HtmlCheck {
241240
builder.default_doc(&[]);
242241
builder.ensure(crate::doc::Rustc::new(builder.top_stage, self.target, builder));
243242

244-
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)))
245-
.unwrap();
243+
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
246244
}
247245
}
248246

@@ -288,8 +286,7 @@ impl Step for Cargotest {
288286
.args(builder.config.test_args())
289287
.env("RUSTC", builder.rustc(compiler))
290288
.env("RUSTDOC", builder.rustdoc(compiler)),
291-
)
292-
.unwrap();
289+
);
293290
}
294291
}
295292

@@ -855,7 +852,7 @@ impl Step for RustdocTheme {
855852
util::lld_flag_no_threads(self.compiler.host.contains("windows")),
856853
);
857854
}
858-
try_run(builder, &mut cmd).unwrap();
855+
try_run(builder, &mut cmd);
859856
}
860857
}
861858

@@ -1106,7 +1103,7 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
11061103
}
11071104

11081105
builder.info("tidy check");
1109-
try_run(builder, &mut cmd).unwrap();
1106+
try_run(builder, &mut cmd);
11101107

11111108
builder.ensure(ExpandYamlAnchors);
11121109

@@ -1154,8 +1151,7 @@ impl Step for ExpandYamlAnchors {
11541151
try_run(
11551152
builder,
11561153
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
1157-
)
1158-
.unwrap();
1154+
);
11591155
}
11601156

11611157
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1948,7 +1944,7 @@ impl BookTest {
19481944
compiler.host,
19491945
);
19501946
let _time = util::timeit(&builder);
1951-
let toolstate = if try_run(builder, &mut rustbook_cmd).is_ok() {
1947+
let toolstate = if try_run(builder, &mut rustbook_cmd) {
19521948
ToolState::TestPass
19531949
} else {
19541950
ToolState::TestFail
@@ -2106,7 +2102,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
21062102
cmd.arg("--test-args").arg(test_args);
21072103

21082104
if builder.config.verbose_tests {
2109-
try_run(builder, &mut cmd).is_ok()
2105+
try_run(builder, &mut cmd)
21102106
} else {
21112107
try_run_quiet(builder, &mut cmd)
21122108
}
@@ -2134,7 +2130,7 @@ impl Step for RustcGuide {
21342130

21352131
let src = builder.src.join(relative_path);
21362132
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
2137-
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)).is_ok() {
2133+
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
21382134
ToolState::TestPass
21392135
} else {
21402136
ToolState::TestFail
@@ -2684,7 +2680,7 @@ impl Step for Bootstrap {
26842680
.current_dir(builder.src.join("src/bootstrap/"));
26852681
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
26862682
// Use `python -m unittest` manually if you want to pass arguments.
2687-
try_run(builder, &mut check_bootstrap).unwrap();
2683+
try_run(builder, &mut check_bootstrap);
26882684

26892685
let host = builder.config.build;
26902686
let compiler = builder.compiler(0, host);
@@ -2756,7 +2752,7 @@ impl Step for TierCheck {
27562752
}
27572753

27582754
builder.info("platform support check");
2759-
try_run(builder, &mut cargo.into()).unwrap();
2755+
try_run(builder, &mut cargo.into());
27602756
}
27612757
}
27622758

@@ -2836,7 +2832,7 @@ impl Step for RustInstaller {
28362832
cmd.env("CARGO", &builder.initial_cargo);
28372833
cmd.env("RUSTC", &builder.initial_rustc);
28382834
cmd.env("TMP_DIR", &tmpdir);
2839-
try_run(builder, &mut cmd).unwrap();
2835+
try_run(builder, &mut cmd);
28402836
}
28412837

28422838
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

0 commit comments

Comments
 (0)