about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-02-12 16:24:31 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2024-02-12 16:25:39 +0100
commitd0873c7a11e71a46ad58c1d152fb0599281d98df (patch)
tree58de90de657d19c50055b7a762bc7208e4b6c29e
parented195328689e052b5270b25d0e410b491914fc71 (diff)
downloadrust-d0873c7a11e71a46ad58c1d152fb0599281d98df.tar.gz
rust-d0873c7a11e71a46ad58c1d152fb0599281d98df.zip
constify a couple thread_local statics
-rw-r--r--compiler/rustc_data_structures/src/sync/worker_local.rs2
-rw-r--r--compiler/rustc_errors/src/markdown/term.rs4
-rw-r--r--library/proc_macro/src/bridge/client.rs2
-rw-r--r--library/proc_macro/src/bridge/server.rs2
4 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_data_structures/src/sync/worker_local.rs b/compiler/rustc_data_structures/src/sync/worker_local.rs
index b34d3dd9044..ba9f88b912e 100644
--- a/compiler/rustc_data_structures/src/sync/worker_local.rs
+++ b/compiler/rustc_data_structures/src/sync/worker_local.rs
@@ -42,7 +42,7 @@ pub struct Registry(Arc<RegistryData>);
 thread_local! {
     /// The registry associated with the thread.
     /// This allows the `WorkerLocal` type to clone the registry in its constructor.
-    static REGISTRY: OnceCell<Registry> = OnceCell::new();
+    static REGISTRY: OnceCell<Registry> = const { OnceCell::new() };
 }
 
 struct ThreadData {
diff --git a/compiler/rustc_errors/src/markdown/term.rs b/compiler/rustc_errors/src/markdown/term.rs
index 88c3c8b9ff2..06c1333d93d 100644
--- a/compiler/rustc_errors/src/markdown/term.rs
+++ b/compiler/rustc_errors/src/markdown/term.rs
@@ -9,9 +9,9 @@ const DEFAULT_COLUMN_WIDTH: usize = 140;
 
 thread_local! {
     /// Track the position of viewable characters in our buffer
-    static CURSOR: Cell<usize> = Cell::new(0);
+    static CURSOR: Cell<usize> = const { Cell::new(0) };
     /// Width of the terminal
-    static WIDTH: Cell<usize> = Cell::new(DEFAULT_COLUMN_WIDTH);
+    static WIDTH: Cell<usize> = const { Cell::new(DEFAULT_COLUMN_WIDTH) };
 }
 
 /// Print to terminal output to a buffer
diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs
index 9255c3abc8a..b6a75f72c74 100644
--- a/library/proc_macro/src/bridge/client.rs
+++ b/library/proc_macro/src/bridge/client.rs
@@ -284,7 +284,7 @@ impl<'a> scoped_cell::ApplyL<'a> for BridgeStateL {
 
 thread_local! {
     static BRIDGE_STATE: scoped_cell::ScopedCell<BridgeStateL> =
-        scoped_cell::ScopedCell::new(BridgeState::NotConnected);
+        const { scoped_cell::ScopedCell::new(BridgeState::NotConnected) };
 }
 
 impl BridgeState<'_> {
diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs
index 2ea87d866ff..eee64e69b37 100644
--- a/library/proc_macro/src/bridge/server.rs
+++ b/library/proc_macro/src/bridge/server.rs
@@ -152,7 +152,7 @@ thread_local! {
     /// This is required as the thread-local state in the proc_macro client does
     /// not handle being re-entered, and will invalidate all `Symbol`s when
     /// entering a nested macro.
-    static ALREADY_RUNNING_SAME_THREAD: Cell<bool> = Cell::new(false);
+    static ALREADY_RUNNING_SAME_THREAD: Cell<bool> = const { Cell::new(false) };
 }
 
 /// Keep `ALREADY_RUNNING_SAME_THREAD` (see also its documentation)