about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-07-24 04:31:07 +0900
committerGitHub <noreply@github.com>2021-07-24 04:31:07 +0900
commit1a2b90bc9183fdebdb9e6588bced4fbdf1b5a85f (patch)
tree7a6cd03bed42a3f87d552374acfb7f616579c176
parentaca83f1ab84f43bb3f7345baf84719eb2da4644b (diff)
parent6cba79851adbc88f75e50b0eed456f74967ff19c (diff)
downloadrust-1a2b90bc9183fdebdb9e6588bced4fbdf1b5a85f.tar.gz
rust-1a2b90bc9183fdebdb9e6588bced4fbdf1b5a85f.zip
Rollup merge of #87255 - RalfJung:miri-test-libcore, r=Mark-Simulacrum
better support for running libcore tests with Miri

See https://github.com/rust-lang/miri-test-libstd/issues/4 for a description of the problem that this fixes.
Thanks to `@hyd-dev` for suggesting this patch!
-rw-r--r--library/alloc/src/lib.rs4
-rw-r--r--library/core/src/lib.rs4
2 files changed, 8 insertions, 0 deletions
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index e8bd4bcb01f..fa1f361a5b6 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -56,6 +56,10 @@
 //! [`Rc`]: rc
 //! [`RefCell`]: core::cell
 
+// To run liballoc tests without x.py without ending up with two copies of liballoc, Miri needs to be
+// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
+// rustc itself never sets the feature, so this line has no affect there.
+#![cfg(any(not(feature = "miri-test-libstd"), 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 540cdf124ee..6d87a7ab055 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -49,6 +49,10 @@
 //
 // This cfg won't affect doc tests.
 #![cfg(not(test))]
+// To run libcore tests without x.py without ending up with two copies of libcore, Miri needs to be
+// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
+// rustc itself never sets the feature, so this line has no affect there.
+#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
 #![stable(feature = "core", since = "1.6.0")]
 #![doc(
     html_playground_url = "https://play.rust-lang.org/",