From 892f176d899dd218285d82489603fa700a1ed6f6 Mon Sep 17 00:00:00 2001 From: Daria Sukhonina Date: Thu, 23 Apr 2026 16:06:24 +0300 Subject: [PATCH] Const initialize `LOCK_LATCH` thread local --- compiler/rustc_thread_pool/src/latch.rs | 2 +- compiler/rustc_thread_pool/src/registry.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_thread_pool/src/latch.rs b/compiler/rustc_thread_pool/src/latch.rs index 29c85146e4f17..da3937a5ff415 100644 --- a/compiler/rustc_thread_pool/src/latch.rs +++ b/compiler/rustc_thread_pool/src/latch.rs @@ -220,7 +220,7 @@ pub(super) struct LockLatch { impl LockLatch { #[inline] - pub(super) fn new() -> LockLatch { + pub(super) const fn new() -> LockLatch { LockLatch { m: Mutex::new(false), v: Condvar::new() } } diff --git a/compiler/rustc_thread_pool/src/registry.rs b/compiler/rustc_thread_pool/src/registry.rs index 92bb8961e7dfc..9510c1842f86a 100644 --- a/compiler/rustc_thread_pool/src/registry.rs +++ b/compiler/rustc_thread_pool/src/registry.rs @@ -524,7 +524,7 @@ impl Registry { OP: FnOnce(&WorkerThread, bool) -> R + Send, R: Send, { - thread_local!(static LOCK_LATCH: LockLatch = LockLatch::new()); + thread_local!(static LOCK_LATCH: LockLatch = const { LockLatch::new() }); LOCK_LATCH.with(|l| { // This thread isn't a member of *any* thread pool, so just block.