Skip to content

Commit d690743

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustdoc/doctest.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,16 @@ 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
415+
rustflags.split_whitespace().map(|flag| flag.trim()).filter(|flag| !flag.is_empty())
416+
{
417+
compiler.arg(flag);
418+
}
419+
}
410420

411421
if scraped_test.no_run(rustdoc_options)
412422
&& !langstr.compile_fail

0 commit comments

Comments
 (0)