Skip to content

Commit 54214c8

Browse files
committed
Use a simpler atomic operation than the compare_exchange hammer
1 parent 300901b commit 54214c8

File tree

2 files changed

+9
-3
lines changed
  • compiler

2 files changed

+9
-3
lines changed

compiler/rustc_data_structures/src/sync.rs

+8
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ cfg_if! {
107107
}
108108
}
109109

110+
impl Atomic<bool> {
111+
pub fn fetch_or(&self, val: bool, _: Ordering) -> bool {
112+
let result = self.0.get() | val;
113+
self.0.set(val);
114+
result
115+
}
116+
}
117+
110118
impl<T: Copy + PartialEq> Atomic<T> {
111119
#[inline]
112120
pub fn compare_exchange(&self,

compiler/rustc_parse/src/parser/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1541,11 +1541,9 @@ pub(crate) fn make_unclosed_delims_error(
15411541
}
15421542

15431543
pub fn emit_unclosed_delims(unclosed_delims: &mut Vec<UnmatchedDelim>, sess: &ParseSess) {
1544-
let _ = sess.reached_eof.compare_exchange(
1545-
false,
1544+
let _ = sess.reached_eof.fetch_or(
15461545
unclosed_delims.iter().any(|unmatched_delim| unmatched_delim.found_delim.is_none()),
15471546
Ordering::Relaxed,
1548-
Ordering::Relaxed,
15491547
);
15501548
for unmatched in unclosed_delims.drain(..) {
15511549
if let Some(mut e) = make_unclosed_delims_error(unmatched, sess) {

0 commit comments

Comments
 (0)