Skip to content

Commit 782d228

Browse files
Use RUSTFLAGS environment variable when compiling doctests
1 parent 6a2cd0d commit 782d228

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustdoc/doctest.rs

+8
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,14 @@ fn run_test(
407407
compiler.arg("-W").arg("unused_crate_dependencies");
408408
compiler.arg("-Z").arg("unstable-options");
409409
}
410+
// If arguments are passed to `RUSTFLAGS` environment variable, let's add them when compiling
411+
// the doctest.
412+
if let Ok(rustflags) = std::env::var("RUSTFLAGS") {
413+
// Very simple parsing implementation. Might be a good idea to correctly handle strings.
414+
for flag in rustflags.split(' ').map(|flag| flag.trim()).filter(|flag| !flag.is_empty()) {
415+
compiler.arg(flag);
416+
}
417+
}
410418

411419
if scraped_test.no_run(rustdoc_options)
412420
&& !langstr.compile_fail

0 commit comments

Comments
 (0)