Skip to content

Commit 76a3329

Browse files
committed
Auto merge of #1913 - RalfJung:rustdoc-miri, r=RalfJung
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.
2 parents a8b976e + a15539e commit 76a3329

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

cargo-miri/bin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,8 @@ fn phase_rustdoc(fst_arg: &str, mut args: env::Args) {
10081008

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

10121014
// Make rustdoc call us back.
10131015
let cargo_miri_path = std::env::current_exe().expect("current executable path invalid");

test-cargo-miri/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ pub fn make_true() -> bool {
1616
issue_1691::use_me()
1717
}
1818

19+
/// ```rust
20+
/// cargo_miri_test::miri_only_fn();
21+
/// ```
22+
#[cfg(miri)]
23+
pub fn miri_only_fn() {}
24+
1925
pub fn main() {
2026
println!("imported main");
2127
}

test-cargo-miri/test.default.stdout.ref

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ running 7 tests
1010
test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
1111

1212

13-
running 3 tests
14-
...
15-
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
13+
running 4 tests
14+
....
15+
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
1616

test-cargo-miri/test.filter.stdout.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out
1313

1414
running 0 tests
1515

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

0 commit comments

Comments
 (0)