Skip to content

Commit

Permalink
Make core_miri_test and alloc_miri_test empty when not collecting…
Browse files Browse the repository at this point in the history
… doctests
  • Loading branch information
hyd-dev committed Jul 18, 2021
1 parent 65a1fe7 commit ee0fd6c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions alloc_miri_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ edition = "2018"
name = "alloc_miri_test"
path = "../liballoc/src/lib.rs"

[features]
# Set `cfg(feature = "miri-test")` to make the crate empty unless rustdoc is collecting doctests.
default = ["miri-test"]
miri-test = []

[dependencies]

[dev-dependencies]
Expand Down
5 changes: 5 additions & 0 deletions core_miri_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ path = "../libcore/src/lib.rs"
test = false
bench = false

[features]
# Set `cfg(feature = "miri-test")` to make the crate empty unless rustdoc is collecting doctests.
default = ["miri-test"]
miri-test = []

[[test]]
name = "coretests"
path = "../libcore/tests/lib.rs"
Expand Down
24 changes: 24 additions & 0 deletions rust-src.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index e8bd4bcb..cc518cc4 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -56,6 +56,7 @@
//! [`Rc`]: rc
//! [`RefCell`]: core::cell

+#![cfg(any(not(feature = "miri-test"), doctest))]
#![allow(unused_attributes)]
#![stable(feature = "alloc", since = "1.36.0")]
#![doc(
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 3557dbad..6c089b0c 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -49,6 +49,7 @@
//
// This cfg won't affect doc tests.
#![cfg(not(test))]
+#![cfg(any(not(feature = "miri-test"), doctest))]
#![stable(feature = "core", since = "1.6.0")]
#![doc(
html_playground_url = "https://play.rust-lang.org/",

0 comments on commit ee0fd6c

Please sign in to comment.