Skip to content

Commit 190047f

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

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler/rustc_data_structures/src/sync.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ cfg_if! {
106106
self.0.set(val);
107107
result
108108
}
109+
pub fn fetch_update(
110+
&self,
111+
_order_set: Ordering,
112+
_order_get: Ordering,
113+
mut f: impl FnMut(bool) -> Option<bool>,
114+
) -> Result<bool, bool> {
115+
let prev = self.0.get();
116+
if let Some(next) = f(prev) {
117+
self.0.set(next);
118+
Ok(prev)
119+
} else {
120+
Err(prev)
121+
}
122+
}
109123
}
110124

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

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_ast as ast;
88
use rustc_data_structures::captures::Captures;
99
use rustc_data_structures::fx::FxHashMap;
1010
use rustc_data_structures::svh::Svh;
11-
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc, OnceCell};
11+
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
1212
use rustc_data_structures::unhash::UnhashMap;
1313
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
1414
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
@@ -38,7 +38,7 @@ use proc_macro::bridge::client::ProcMacro;
3838
use std::iter::TrustedLen;
3939
use std::num::NonZeroUsize;
4040
use std::path::Path;
41-
use std::sync::atomic::{AtomicBool, Ordering};
41+
use std::sync::atomic::Ordering;
4242
use std::{io, iter, mem};
4343

4444
pub(super) use cstore_impl::provide;

0 commit comments

Comments
 (0)