Skip to content

Commit 8a3dc83

Browse files
Rollup merge of rust-lang#120976 - matthiaskrgr:constify_TL_statics, r=lcnr
constify a couple thread_local statics
2 parents 7606c13 + d0873c7 commit 8a3dc83

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
@@ -209,7 +209,7 @@ impl<'a> scoped_cell::ApplyL<'a> for BridgeStateL {
209209

210210
thread_local! {
211211
static BRIDGE_STATE: scoped_cell::ScopedCell<BridgeStateL> =
212-
scoped_cell::ScopedCell::new(BridgeState::NotConnected);
212+
const { scoped_cell::ScopedCell::new(BridgeState::NotConnected) };
213213
}
214214

215215
impl BridgeState<'_> {

library/proc_macro/src/bridge/server.rs

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

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

0 commit comments

Comments
 (0)