Skip to content

Commit

Permalink
Auto merge of #1913 - RalfJung:rustdoc-miri, r=RalfJung
Browse files Browse the repository at this point in the history
run rustdoc with the miri cfg flag

This is important to be able to control which doctests run with `cargo miri test`. In particular, this is required for rust-lang/rust#90909 to work as intended.
  • Loading branch information
bors committed Nov 14, 2021
2 parents a8b976e + a15539e commit 76a3329
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cargo-miri/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,8 @@ fn phase_rustdoc(fst_arg: &str, mut args: env::Args) {

// rustdoc needs to know the right sysroot.
forward_miri_sysroot(&mut cmd);
// make sure the 'miri' flag is set for rustdoc
cmd.arg("--cfg").arg("miri");

// Make rustdoc call us back.
let cargo_miri_path = std::env::current_exe().expect("current executable path invalid");
Expand Down
6 changes: 6 additions & 0 deletions test-cargo-miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ pub fn make_true() -> bool {
issue_1691::use_me()
}

/// ```rust
/// cargo_miri_test::miri_only_fn();
/// ```
#[cfg(miri)]
pub fn miri_only_fn() {}

pub fn main() {
println!("imported main");
}
6 changes: 3 additions & 3 deletions test-cargo-miri/test.default.stdout.ref
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ running 7 tests
test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out


running 3 tests
...
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
running 4 tests
....
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

2 changes: 1 addition & 1 deletion test-cargo-miri/test.filter.stdout.ref
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out; finished in $TIME
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in $TIME

0 comments on commit 76a3329

Please sign in to comment.