about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-01-12 06:52:37 +0100
committerGitHub <noreply@github.com>2023-01-12 06:52:37 +0100
commitdb8301b7f873114ab95ce27bd8e9c4ab476cb458 (patch)
treef25b81fa5a68e372f2b8e86f626e270c834d8178 /library/std/src
parent890bc3ca903df5178ab401075d6d01a8b2e12987 (diff)
parentad79b2043f2402859f80a82c3b20e16b1cf7c9da (diff)
downloadrust-db8301b7f873114ab95ce27bd8e9c4ab476cb458.tar.gz
rust-db8301b7f873114ab95ce27bd8e9c4ab476cb458.zip
Rollup merge of #106638 - RalfJung:realstd, r=thomcc
std tests: use __OsLocalKeyInner from realstd

This is basically the same as https://github.com/rust-lang/rust/pull/100201, but for __OsLocalKeyInner:

Some std tests are failing in Miri on Windows because [this static](https://github.com/rust-lang/rust/blob/a377893da2cd7124e5a18c7116cbb70e16dd5541/library/std/src/sys/windows/thread_local_key.rs#L234-L239) is getting duplicated, and Miri does not handle that properly -- Miri does not support this magic `.CRT$XLB` linker section, but instead just looks up this particular hard-coded static in the standard library. This PR lets the test suite use the std static instead of having its own copy.

Fixes https://github.com/rust-lang/miri/issues/2754
r? `@thomcc`
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/thread/mod.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs
index 7acda8e98f1..692ff0cbca6 100644
--- a/library/std/src/thread/mod.rs
+++ b/library/std/src/thread/mod.rs
@@ -177,6 +177,12 @@ use crate::sys_common::thread_parking::Parker;
 use crate::sys_common::{AsInner, IntoInner};
 use crate::time::Duration;
 
+#[stable(feature = "scoped_threads", since = "1.63.0")]
+mod scoped;
+
+#[stable(feature = "scoped_threads", since = "1.63.0")]
+pub use scoped::{scope, Scope, ScopedJoinHandle};
+
 ////////////////////////////////////////////////////////////////////////////////
 // Thread-local storage
 ////////////////////////////////////////////////////////////////////////////////
@@ -184,12 +190,6 @@ use crate::time::Duration;
 #[macro_use]
 mod local;
 
-#[stable(feature = "scoped_threads", since = "1.63.0")]
-mod scoped;
-
-#[stable(feature = "scoped_threads", since = "1.63.0")]
-pub use scoped::{scope, Scope, ScopedJoinHandle};
-
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::local::{AccessError, LocalKey};
 
@@ -209,7 +209,6 @@ pub use self::local::{AccessError, LocalKey};
 ))]
 #[doc(hidden)]
 pub use self::local::fast::Key as __FastLocalKeyInner;
-
 // when building for tests, use real std's type
 #[unstable(feature = "libstd_thread_internals", issue = "none")]
 #[cfg(test)]
@@ -220,12 +219,21 @@ pub use self::local::fast::Key as __FastLocalKeyInner;
 pub use realstd::thread::__FastLocalKeyInner;
 
 #[unstable(feature = "libstd_thread_internals", issue = "none")]
+#[cfg(not(test))]
 #[cfg(all(
     not(target_thread_local),
     not(all(target_family = "wasm", not(target_feature = "atomics"))),
 ))]
 #[doc(hidden)]
 pub use self::local::os::Key as __OsLocalKeyInner;
+// when building for tests, use real std's type
+#[unstable(feature = "libstd_thread_internals", issue = "none")]
+#[cfg(test)]
+#[cfg(all(
+    not(target_thread_local),
+    not(all(target_family = "wasm", not(target_feature = "atomics"))),
+))]
+pub use realstd::thread::__OsLocalKeyInner;
 
 #[unstable(feature = "libstd_thread_internals", issue = "none")]
 #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))]