about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-05-08 15:12:45 -0700
committerMichael Howell <michael@notriddle.com>2023-05-25 08:15:04 -0700
commita12f50ddc4ed73cbca436827ae3958a104d915d3 (patch)
treeceed17a4ced20016d35dfbd4c7676402f7184500
parentb537c1f1756b43228c3c392a54ddec91b0f1d205 (diff)
downloadrust-a12f50ddc4ed73cbca436827ae3958a104d915d3.tar.gz
rust-a12f50ddc4ed73cbca436827ae3958a104d915d3.zip
rustc_metadata: use configurable AtomicBool for privateness flag
This switches to using a `Cell` for single-threaded rustc.
-rw-r--r--compiler/rustc_data_structures/src/sync.rs14
-rw-r--r--compiler/rustc_metadata/src/rmeta/decoder.rs4
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs
index 6c3197d8ec2..df8285cc729 100644
--- a/compiler/rustc_data_structures/src/sync.rs
+++ b/compiler/rustc_data_structures/src/sync.rs
@@ -143,6 +143,20 @@ cfg_if! {
                 self.0.set(val);
                 result
             }
+            pub fn fetch_update(
+                &self,
+                _order_set: Ordering,
+                _order_get: Ordering,
+                mut f: impl FnMut(bool) -> Option<bool>,
+            ) -> Result<bool, bool> {
+                let prev = self.0.get();
+                if let Some(next) = f(prev) {
+                    self.0.set(next);
+                    Ok(prev)
+                } else {
+                    Err(prev)
+                }
+            }
         }
 
         impl<T: Copy + PartialEq> Atomic<T> {
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs
index ae8423af112..325ffcae7e9 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -9,7 +9,7 @@ use rustc_data_structures::captures::Captures;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::owned_slice::OwnedSlice;
 use rustc_data_structures::svh::Svh;
-use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc, OnceCell};
+use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
 use rustc_data_structures::unhash::UnhashMap;
 use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
 use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
@@ -40,7 +40,7 @@ use proc_macro::bridge::client::ProcMacro;
 use std::iter::TrustedLen;
 use std::num::NonZeroUsize;
 use std::path::Path;
-use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::atomic::Ordering;
 use std::{io, iter, mem};
 
 pub(super) use cstore_impl::provide;