From a3ad045ea49b0613505e02bb0036575d1fc0c99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 2 Sep 2023 01:28:04 +0200 Subject: [PATCH] Rename `Freeze` to `FreezeLock` --- compiler/rustc_data_structures/src/sync.rs | 2 +- compiler/rustc_data_structures/src/sync/freeze.rs | 14 +++++++------- compiler/rustc_interface/src/queries.rs | 6 ++++-- compiler/rustc_session/src/cstore.rs | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index a8f42e0ed0e..8eda9043e35 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -62,7 +62,7 @@ mod vec; mod freeze; -pub use freeze::{Freeze, FreezeReadGuard, FreezeWriteGuard}; +pub use freeze::{FreezeLock, FreezeReadGuard, FreezeWriteGuard}; mod mode { use super::Ordering; diff --git a/compiler/rustc_data_structures/src/sync/freeze.rs b/compiler/rustc_data_structures/src/sync/freeze.rs index e9ad6ee8394..ea75dcc4151 100644 --- a/compiler/rustc_data_structures/src/sync/freeze.rs +++ b/compiler/rustc_data_structures/src/sync/freeze.rs @@ -12,7 +12,7 @@ /// /// Unlike `RwLock`, it can be used to prevent mutation past a point. #[derive(Default)] -pub struct Freeze { +pub struct FreezeLock { data: UnsafeCell, frozen: AtomicBool, @@ -21,9 +21,9 @@ pub struct Freeze { } #[cfg(parallel_compiler)] -unsafe impl DynSync for Freeze {} +unsafe impl DynSync for FreezeLock {} -impl Freeze { +impl FreezeLock { #[inline] pub fn new(value: T) -> Self { Self { data: UnsafeCell::new(value), frozen: AtomicBool::new(false), lock: RwLock::new(()) } @@ -71,8 +71,8 @@ pub fn freeze(&self) -> &T { } } -/// A guard holding shared access to a `Freeze` which is in a locked state or frozen. -#[must_use = "if unused the Freeze may immediately unlock"] +/// A guard holding shared access to a `FreezeLock` which is in a locked state or frozen. +#[must_use = "if unused the FreezeLock may immediately unlock"] pub struct FreezeReadGuard<'a, T> { _lock_guard: Option>, data: &'a T, @@ -86,8 +86,8 @@ fn deref(&self) -> &T { } } -/// A guard holding mutable access to a `Freeze` which is in a locked state or frozen. -#[must_use = "if unused the Freeze may immediately unlock"] +/// A guard holding mutable access to a `FreezeLock` which is in a locked state or frozen. +#[must_use = "if unused the FreezeLock may immediately unlock"] pub struct FreezeWriteGuard<'a, T> { _lock_guard: WriteGuard<'a, ()>, data: &'a mut T, diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index a7c63680747..e0d9998d919 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -7,7 +7,9 @@ use rustc_codegen_ssa::CodegenResults; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; -use rustc_data_structures::sync::{AppendOnlyIndexVec, Freeze, Lrc, OnceLock, RwLock, WorkerLocal}; +use rustc_data_structures::sync::{ + AppendOnlyIndexVec, FreezeLock, Lrc, OnceLock, RwLock, WorkerLocal, +}; use rustc_hir::def_id::{StableCrateId, CRATE_DEF_ID, LOCAL_CRATE}; use rustc_hir::definitions::Definitions; use rustc_incremental::DepGraphFuture; @@ -197,7 +199,7 @@ pub fn global_ctxt(&'tcx self) -> Result> self.codegen_backend().metadata_loader(), stable_crate_id, )) as _); - let definitions = Freeze::new(Definitions::new(stable_crate_id)); + let definitions = FreezeLock::new(Definitions::new(stable_crate_id)); let source_span = AppendOnlyIndexVec::new(); let _id = source_span.push(krate.spans.inner_span); debug_assert_eq!(_id, CRATE_DEF_ID); diff --git a/compiler/rustc_session/src/cstore.rs b/compiler/rustc_session/src/cstore.rs index a86363b9cae..90f57be9324 100644 --- a/compiler/rustc_session/src/cstore.rs +++ b/compiler/rustc_session/src/cstore.rs @@ -7,7 +7,7 @@ use crate::Session; use rustc_ast as ast; use rustc_data_structures::owned_slice::OwnedSlice; -use rustc_data_structures::sync::{self, AppendOnlyIndexVec, Freeze, RwLock}; +use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock, RwLock}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, StableCrateId, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions}; use rustc_span::hygiene::{ExpnHash, ExpnId}; @@ -261,5 +261,5 @@ pub struct Untracked { pub cstore: RwLock>, /// Reference span for definitions. pub source_span: AppendOnlyIndexVec, - pub definitions: Freeze, + pub definitions: FreezeLock, }