Skip to content

Commit fd7e1f8

Browse files
committed
enable cargo miri test doctests for stage > 0 builds
Signed-off-by: onur-ozkan <[email protected]>
1 parent 42198bf commit fd7e1f8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/bootstrap/src/core/build_steps/test.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,16 @@ impl Step for Miri {
680680
.arg("--manifest-path")
681681
.arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml"));
682682
cargo.arg("--target").arg(target.rustc_target_arg());
683-
cargo.arg("--tests"); // don't run doctests, they are too confused by the staging
683+
684+
if stage == 0 {
685+
builder.info("INFO: miri/test-cargo-miri doctests are ignored on stage 0.");
686+
// Don't run doctests on stage0, stage0 rustdoc is incompatible with the miri sysroot
687+
cargo.arg("--tests");
688+
} else {
689+
// Miri doesn't know which rustdoc to use by default, so tell which one it should use.
690+
cargo.env("RUSTDOC_REAL", builder.rustdoc(compiler));
691+
}
692+
684693
cargo.arg("--").args(builder.config.test_args());
685694

686695
// Tell `cargo miri` where to find things.

src/tools/miri/cargo-miri/src/phases.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,10 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
582582
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
583583

584584
// phase_cargo_miri sets the RUSTDOC env var to ourselves, so we can't use that here;
585-
// just default to a straight-forward invocation for now:
586-
let mut cmd = Command::new("rustdoc");
585+
// If available, use the one provided by bootstrap; otherwise, simply default to a straightforward
586+
// invocation for now:
587+
let rustdoc = env::var("RUSTDOC_REAL").unwrap_or("rustdoc".to_string());
588+
let mut cmd = Command::new(rustdoc);
587589

588590
let extern_flag = "--extern";
589591
let runtool_flag = "--runtool";

0 commit comments

Comments
 (0)