about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-09-16 14:55:15 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2021-09-16 14:55:15 +0200
commita8bb3bcd38502e63c3b729ca215fdb18a0c70e77 (patch)
tree35d9b681b7480682073bb61030e5c649ec696d5e
parentf78cd44602fd8360657b9a205061ca7bf0592140 (diff)
downloadrust-a8bb3bcd38502e63c3b729ca215fdb18a0c70e77.tar.gz
rust-a8bb3bcd38502e63c3b729ca215fdb18a0c70e77.zip
Use const {} for the THREAD_INFO thread local
This makes accesses to it cheaper
-rw-r--r--library/std/src/sys_common/thread_info.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/sys_common/thread_info.rs b/library/std/src/sys_common/thread_info.rs
index a0dbdcd979a..1d2e2dd4361 100644
--- a/library/std/src/sys_common/thread_info.rs
+++ b/library/std/src/sys_common/thread_info.rs
@@ -1,4 +1,5 @@
 #![allow(dead_code)] // stack_guard isn't used right now on all platforms
+#![allow(unused_unsafe)] // thread_local with `const {}` triggers this liny
 
 use crate::cell::RefCell;
 use crate::sys::thread::guard::Guard;
@@ -9,7 +10,7 @@ struct ThreadInfo {
     thread: Thread,
 }
 
-thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None) }
+thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = const { RefCell::new(None) } }
 
 impl ThreadInfo {
     fn with<R, F>(f: F) -> Option<R>