Skip to content

Commit d0873c7

Browse files
committed
constify a couple thread_local statics
1 parent ed19532 commit d0873c7

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

compiler/rustc_data_structures/src/sync/worker_local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct Registry(Arc<RegistryData>);
4242
thread_local! {
4343
/// The registry associated with the thread.
4444
/// This allows the `WorkerLocal` type to clone the registry in its constructor.
45-
static REGISTRY: OnceCell<Registry> = OnceCell::new();
45+
static REGISTRY: OnceCell<Registry> = const { OnceCell::new() };
4646
}
4747

4848
struct ThreadData {

compiler/rustc_errors/src/markdown/term.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const DEFAULT_COLUMN_WIDTH: usize = 140;
99

1010
thread_local! {
1111
/// Track the position of viewable characters in our buffer
12-
static CURSOR: Cell<usize> = Cell::new(0);
12+
static CURSOR: Cell<usize> = const { Cell::new(0) };
1313
/// Width of the terminal
14-
static WIDTH: Cell<usize> = Cell::new(DEFAULT_COLUMN_WIDTH);
14+
static WIDTH: Cell<usize> = const { Cell::new(DEFAULT_COLUMN_WIDTH) };
1515
}
1616

1717
/// Print to terminal output to a buffer

library/proc_macro/src/bridge/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'a> scoped_cell::ApplyL<'a> for BridgeStateL {
284284

285285
thread_local! {
286286
static BRIDGE_STATE: scoped_cell::ScopedCell<BridgeStateL> =
287-
scoped_cell::ScopedCell::new(BridgeState::NotConnected);
287+
const { scoped_cell::ScopedCell::new(BridgeState::NotConnected) };
288288
}
289289

290290
impl BridgeState<'_> {

library/proc_macro/src/bridge/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ thread_local! {
152152
/// This is required as the thread-local state in the proc_macro client does
153153
/// not handle being re-entered, and will invalidate all `Symbol`s when
154154
/// entering a nested macro.
155-
static ALREADY_RUNNING_SAME_THREAD: Cell<bool> = Cell::new(false);
155+
static ALREADY_RUNNING_SAME_THREAD: Cell<bool> = const { Cell::new(false) };
156156
}
157157

158158
/// Keep `ALREADY_RUNNING_SAME_THREAD` (see also its documentation)

0 commit comments

Comments
 (0)