Skip to content

Commit 169663d

Browse files
authored
Rollup merge of #123055 - onur-ozkan:miri-rustdoc, r=RalfJung
enable cargo miri test doctests This was the cleanest solution that came to my mind so far. cc `@RalfJung` Resolves #123028
2 parents dfb5b89 + ff2ef05 commit 169663d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ binaries, and as such worth documenting:
505505
* `MIRI_LOCAL_CRATES` is set by `cargo-miri` to tell the Miri driver which
506506
crates should be given special treatment in diagnostics, in addition to the
507507
crate currently being compiled.
508+
* `MIRI_ORIG_RUSTDOC` is set and read by different phases of `cargo-miri` to remember the
509+
value of `RUSTDOC` from before it was overwritten.
508510
* `MIRI_VERBOSE` when set to any value tells the various `cargo-miri` phases to
509511
perform verbose logging.
510512
* `MIRI_HOST_SYSROOT` is set by bootstrap to tell `cargo-miri` which sysroot to use for *host*

cargo-miri/src/phases.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
202202
cmd.env("MIRI_BE_RUSTC", "target"); // we better remember to *unset* this in the other phases!
203203

204204
// Set rustdoc to us as well, so we can run doctests.
205+
if let Some(orig_rustdoc) = env::var_os("RUSTDOC") {
206+
cmd.env("MIRI_ORIG_RUSTDOC", orig_rustdoc);
207+
}
205208
cmd.env("RUSTDOC", &cargo_miri_path);
206209

207210
cmd.env("MIRI_LOCAL_CRATES", local_crates(&metadata));
@@ -581,9 +584,10 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
581584
let verbose = std::env::var("MIRI_VERBOSE")
582585
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
583586

584-
// 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");
587+
// phase_cargo_miri sets the RUSTDOC env var to ourselves, and puts a backup
588+
// of the old value into MIRI_ORIG_RUSTDOC. So that's what we have to invoke now.
589+
let rustdoc = env::var("MIRI_ORIG_RUSTDOC").unwrap_or("rustdoc".to_string());
590+
let mut cmd = Command::new(rustdoc);
587591

588592
let extern_flag = "--extern";
589593
let runtool_flag = "--runtool";

0 commit comments

Comments
 (0)