Skip to content

Commit ee0fd6c

Browse files
author
hyd-dev
committed
Make core_miri_test and alloc_miri_test empty when not collecting doctests
1 parent 65a1fe7 commit ee0fd6c

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

alloc_miri_test/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ edition = "2018"
1010
name = "alloc_miri_test"
1111
path = "../liballoc/src/lib.rs"
1212

13+
[features]
14+
# Set `cfg(feature = "miri-test")` to make the crate empty unless rustdoc is collecting doctests.
15+
default = ["miri-test"]
16+
miri-test = []
17+
1318
[dependencies]
1419

1520
[dev-dependencies]

core_miri_test/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ path = "../libcore/src/lib.rs"
1212
test = false
1313
bench = false
1414

15+
[features]
16+
# Set `cfg(feature = "miri-test")` to make the crate empty unless rustdoc is collecting doctests.
17+
default = ["miri-test"]
18+
miri-test = []
19+
1520
[[test]]
1621
name = "coretests"
1722
path = "../libcore/tests/lib.rs"

rust-src.diff

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
2+
index e8bd4bcb..cc518cc4 100644
3+
--- a/library/alloc/src/lib.rs
4+
+++ b/library/alloc/src/lib.rs
5+
@@ -56,6 +56,7 @@
6+
//! [`Rc`]: rc
7+
//! [`RefCell`]: core::cell
8+
9+
+#![cfg(any(not(feature = "miri-test"), doctest))]
10+
#![allow(unused_attributes)]
11+
#![stable(feature = "alloc", since = "1.36.0")]
12+
#![doc(
13+
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
14+
index 3557dbad..6c089b0c 100644
15+
--- a/library/core/src/lib.rs
16+
+++ b/library/core/src/lib.rs
17+
@@ -49,6 +49,7 @@
18+
//
19+
// This cfg won't affect doc tests.
20+
#![cfg(not(test))]
21+
+#![cfg(any(not(feature = "miri-test"), doctest))]
22+
#![stable(feature = "core", since = "1.6.0")]
23+
#![doc(
24+
html_playground_url = "https://play.rust-lang.org/",

0 commit comments

Comments
 (0)