Skip to content

Commit 284a419

Browse files
authored
Rollup merge of #57338 - QuietMisdreavus:doctest-file-name, r=GuillaumeGomez
rustdoc: force binary filename for compiled doctests Fixes #57317, needed for rust-lang/rust-by-example#1137 Right now, when building a doctest, rustdoc provides the compiler an output directory (a temp dir) but lets the compiler name the executable. If the doctest needs to be executed, it then tries to run a binary named `rust_out` from that directory. For the most part, this works fine. However, if the doctest sets its own crate name, the compiler uses that name for the output binary instead. This causes rustdoc to try to execute a nonexistent binary, causing the test to fail. This PR changes the paths rustdoc gives to the compiler when building doctests to force the output *filename* instead of just the *directory*.
2 parents a3afdd4 + 0b55c79 commit 284a419

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/librustdoc/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
278278
target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
279279
sess.parse_sess.config = cfg;
280280

281-
let out = Some(outdir.lock().unwrap().path().to_path_buf());
281+
let out = Some(outdir.lock().unwrap().path().join("rust_out"));
282282

283283
if no_run {
284284
control.after_analysis.stop = Compilation::Stop;
@@ -291,8 +291,8 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
291291
&cstore,
292292
&None,
293293
&input,
294-
&out,
295294
&None,
295+
&out,
296296
None,
297297
&control
298298
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// compile-flags:--test
2+
3+
//! ```
4+
//! #![crate_name="asdf"]
5+
//!
6+
//! println!("yo");
7+
//! ```

0 commit comments

Comments
 (0)