Skip to content

Commit a12f50d

Browse files
committed
rustc_metadata: use configurable AtomicBool for privateness flag
This switches to using a `Cell` for single-threaded rustc.
1 parent b537c1f commit a12f50d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler/rustc_data_structures/src/sync.rs

+14
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,20 @@ cfg_if! {
143143
self.0.set(val);
144144
result
145145
}
146+
pub fn fetch_update(
147+
&self,
148+
_order_set: Ordering,
149+
_order_get: Ordering,
150+
mut f: impl FnMut(bool) -> Option<bool>,
151+
) -> Result<bool, bool> {
152+
let prev = self.0.get();
153+
if let Some(next) = f(prev) {
154+
self.0.set(next);
155+
Ok(prev)
156+
} else {
157+
Err(prev)
158+
}
159+
}
146160
}
147161

148162
impl<T: Copy + PartialEq> Atomic<T> {

compiler/rustc_metadata/src/rmeta/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_data_structures::captures::Captures;
99
use rustc_data_structures::fx::FxHashMap;
1010
use rustc_data_structures::owned_slice::OwnedSlice;
1111
use rustc_data_structures::svh::Svh;
12-
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc, OnceCell};
12+
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
1313
use rustc_data_structures::unhash::UnhashMap;
1414
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
1515
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
@@ -40,7 +40,7 @@ use proc_macro::bridge::client::ProcMacro;
4040
use std::iter::TrustedLen;
4141
use std::num::NonZeroUsize;
4242
use std::path::Path;
43-
use std::sync::atomic::{AtomicBool, Ordering};
43+
use std::sync::atomic::Ordering;
4444
use std::{io, iter, mem};
4545

4646
pub(super) use cstore_impl::provide;

0 commit comments

Comments
 (0)