From c83eba92518166b9e40f43b40683d74c919af0ed Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Fri, 8 Sep 2023 14:14:57 +0200 Subject: Add Freeze::clone --- compiler/rustc_data_structures/src/sync/freeze.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'compiler/rustc_data_structures/src/sync') diff --git a/compiler/rustc_data_structures/src/sync/freeze.rs b/compiler/rustc_data_structures/src/sync/freeze.rs index ad71ae1af51..58ab91237f4 100644 --- a/compiler/rustc_data_structures/src/sync/freeze.rs +++ b/compiler/rustc_data_structures/src/sync/freeze.rs @@ -45,6 +45,16 @@ impl FreezeLock { } } + /// Clones the inner value along with the frozen state. + #[inline] + pub fn clone(&self) -> Self + where + T: Clone, + { + let lock = self.read(); + Self::with(lock.clone(), self.is_frozen()) + } + #[inline] pub fn is_frozen(&self) -> bool { self.frozen.load(Ordering::Acquire) -- cgit 1.4.1-3-g733a5