Skip to content

Commit a8bb3bc

Browse files
committed
Use const {} for the THREAD_INFO thread local
This makes accesses to it cheaper
1 parent f78cd44 commit a8bb3bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/std/src/sys_common/thread_info.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(dead_code)] // stack_guard isn't used right now on all platforms
2+
#![allow(unused_unsafe)] // thread_local with `const {}` triggers this liny
23

34
use crate::cell::RefCell;
45
use crate::sys::thread::guard::Guard;
@@ -9,7 +10,7 @@ struct ThreadInfo {
910
thread: Thread,
1011
}
1112

12-
thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None) }
13+
thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = const { RefCell::new(None) } }
1314

1415
impl ThreadInfo {
1516
fn with<R, F>(f: F) -> Option<R>

0 commit comments

Comments
 (0)