about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys_common/thread_info.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs
index cd570dca0ff..b8f2e658214 100644
--- a/library/std/src/sys_common/thread_info.rs
+++ b/library/std/src/sys_common/thread_info.rs
@@ -34,7 +34,9 @@ impl ThreadInfo {
 ///
 /// This can be used as a non-null usize-sized ID.
 pub fn current_thread_unique_ptr() -> usize {
-    THREAD_INFO.with(|info| <*const _>::addr(info))
+    // Use a non-drop type to make sure it's still available during thread destruction.
+    thread_local! { static X: u8 = 0 }
+    X.with(|x| <*const _>::addr(x))
 }
 
 pub fn current_thread() -> Option<Thread> {