Skip to content

Commit a91e97c

Browse files
Fix 2024 edition doctest panic output
1 parent 0b4a81a commit a91e97c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/librustdoc/doctest/runner.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl DocTestRunner {
113113
mod __doctest_mod {{
114114
use std::sync::OnceLock;
115115
use std::path::PathBuf;
116+
use std::process::ExitCode;
116117
117118
pub static BINARY_PATH: OnceLock<PathBuf> = OnceLock::new();
118119
pub const RUN_OPTION: &str = \"RUSTDOC_DOCTEST_RUN_NB_TEST\";
@@ -123,16 +124,17 @@ mod __doctest_mod {{
123124
}}
124125
125126
#[allow(unused)]
126-
pub fn doctest_runner(bin: &std::path::Path, test_nb: usize) -> Result<(), String> {{
127+
pub fn doctest_runner(bin: &std::path::Path, test_nb: usize) -> ExitCode {{
127128
let out = std::process::Command::new(bin)
128129
.env(self::RUN_OPTION, test_nb.to_string())
129130
.args(std::env::args().skip(1).collect::<Vec<_>>())
130131
.output()
131132
.expect(\"failed to run command\");
132133
if !out.status.success() {{
133-
Err(String::from_utf8_lossy(&out.stderr).to_string())
134+
eprintln!(\"{{}}\", String::from_utf8_lossy(&out.stderr));
135+
ExitCode::FAILURE
134136
}} else {{
135-
Ok(())
137+
ExitCode::SUCCESS
136138
}}
137139
}}
138140
}}

0 commit comments

Comments
 (0)