From 6cba79851adbc88f75e50b0eed456f74967ff19c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 18 Jul 2021 17:21:59 +0200 Subject: [PATCH] better support for running libcore and liballoc tests with Miri --- library/alloc/src/lib.rs | 4 ++++ library/core/src/lib.rs | 4 ++++ 2 files changed, 8 insertions(+) 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 . +// 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 8bbce7e552c..23e022b7413 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 . +// 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/",