From 52bd82f522c4f3d9bd0dc534c06169285afbc23b Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 25 May 2023 15:18:05 -0700 Subject: [PATCH] rustc_data_structures: sync and atomic consistency Co-authored-by: @lukas-code --- compiler/rustc_data_structures/src/sync.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index 96dc187611d..25a08237346 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -139,14 +139,14 @@ cfg_if! { impl Atomic { pub fn fetch_or(&self, val: bool, _: Ordering) -> bool { - let result = self.0.get() | val; - self.0.set(val); - result + let old = self.0.get(); + self.0.set(val | old); + old } pub fn fetch_and(&self, val: bool, _: Ordering) -> bool { - let result = self.0.get() & val; - self.0.set(val); - result + let old = self.0.get(); + self.0.set(val & old); + old } }