Skip to content

Commit 36edc44

Browse files
Fix invalid argument in compile_merged_doctest_and_caller_binary and return earlier on
1 parent 6961413 commit 36edc44

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/librustdoc/doctest.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,11 @@ fn compile_merged_doctest_and_caller_binary(
568568
compiler_args: Vec<String>,
569569
test_code: &str,
570570
instant: Instant,
571-
is_compile_fail: bool,
571+
should_panic: bool,
572572
) -> Result<process::Output, (Duration, Result<(), RustdocResult>)> {
573573
// compile-fail tests never get merged, so this should always pass
574574
let output = child.wait_with_output().expect("Failed to wait");
575-
if is_compile_fail && !output.status.success() {
575+
if !output.status.success() {
576576
return Ok(output);
577577
}
578578

@@ -583,7 +583,7 @@ fn compile_merged_doctest_and_caller_binary(
583583
runner_compiler.env("RUSTC_BOOTSTRAP", "1");
584584
runner_compiler.args(compiler_args);
585585
runner_compiler.args(["--crate-type=bin", "-o"]).arg(output_file);
586-
let base_name = if is_compile_fail {
586+
let base_name = if should_panic {
587587
format!("rust_out")
588588
} else {
589589
format!("doctest_bundle_{edition}", edition = doctest.edition)
@@ -611,7 +611,7 @@ fn compile_merged_doctest_and_caller_binary(
611611
extern_path.push(&output_bundle_file);
612612
runner_compiler.arg(&extern_path);
613613

614-
if is_compile_fail {
614+
if should_panic {
615615
add_rustdoc_env_vars(&mut runner_compiler, doctest);
616616
runner_compiler.stderr(Stdio::piped());
617617
runner_compiler.stdin(Stdio::piped());
@@ -635,17 +635,13 @@ fn compile_merged_doctest_and_caller_binary(
635635
}
636636
debug!("compiler invocation for doctest runner: {runner_compiler:?}");
637637

638-
let output = if !output.status.success() {
639-
output
640-
} else {
641-
let mut child_runner = runner_compiler.spawn().expect("Failed to spawn rustc process");
642-
if is_compile_fail {
643-
let stdin = child_runner.stdin.as_mut().expect("Failed to open stdin");
644-
stdin.write_all(test_code.as_bytes()).expect("could write out test sources");
645-
}
646-
child_runner.wait_with_output().expect("Failed to wait")
647-
};
648-
if is_compile_fail {
638+
let mut child_runner = runner_compiler.spawn().expect("Failed to spawn rustc process");
639+
if should_panic {
640+
let stdin = child_runner.stdin.as_mut().expect("Failed to open stdin");
641+
stdin.write_all(test_code.as_bytes()).expect("could write out test sources");
642+
}
643+
let output = child_runner.wait_with_output().expect("Failed to wait");
644+
if should_panic {
649645
Ok(output)
650646
} else {
651647
Ok(process::Output { status: output.status, stdout: Vec::new(), stderr: Vec::new() })

0 commit comments

Comments
 (0)