Skip to content

Commit

Permalink
Use faster thread_local! init where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Feb 17, 2025
1 parent 40cf00a commit fde471b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type LocalStream = Arc<Mutex<Vec<u8>>>;

thread_local! {
/// Used by the test crate to capture the output of the print macros and panics.
static OUTPUT_CAPTURE: Cell<Option<LocalStream>> = {
static OUTPUT_CAPTURE: Cell<Option<LocalStream>> = const {
Cell::new(None)
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sync/mpmc/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ impl Drop for SyncWaker {
pub fn current_thread_id() -> usize {
// `u8` is not drop so this variable will be available during thread destruction,
// whereas `thread::current()` would not be
thread_local! { static DUMMY: u8 = 0 }
thread_local! { static DUMMY: u8 = const { 0 } }
DUMMY.with(|x| (x as *const u8).addr())
}

0 comments on commit fde471b

Please # to comment.