Skip to content

Commit

Permalink
Merge pull request #312 from dtolnay/detection
Browse files Browse the repository at this point in the history
Ordering::Relaxed for the proc_macro detection
  • Loading branch information
dtolnay authored Dec 20, 2021
2 parents a2b4ff3 + 5dc441c commit 988cf40
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static WORKS: AtomicUsize = AtomicUsize::new(0);
static INIT: Once = Once::new();

pub(crate) fn inside_proc_macro() -> bool {
match WORKS.load(Ordering::SeqCst) {
match WORKS.load(Ordering::Relaxed) {
1 => return false,
2 => return true,
_ => {}
Expand All @@ -16,7 +16,7 @@ pub(crate) fn inside_proc_macro() -> bool {
}

pub(crate) fn force_fallback() {
WORKS.store(1, Ordering::SeqCst);
WORKS.store(1, Ordering::Relaxed);
}

pub(crate) fn unforce_fallback() {
Expand All @@ -26,7 +26,7 @@ pub(crate) fn unforce_fallback() {
#[cfg(not(no_is_available))]
fn initialize() {
let available = proc_macro::is_available();
WORKS.store(available as usize + 1, Ordering::SeqCst);
WORKS.store(available as usize + 1, Ordering::Relaxed);
}

// Swap in a null panic hook to avoid printing "thread panicked" to stderr,
Expand Down Expand Up @@ -65,7 +65,7 @@ fn initialize() {
panic::set_hook(null_hook);

let works = panic::catch_unwind(proc_macro::Span::call_site).is_ok();
WORKS.store(works as usize + 1, Ordering::SeqCst);
WORKS.store(works as usize + 1, Ordering::Relaxed);

let hopefully_null_hook = panic::take_hook();
panic::set_hook(original_hook);
Expand Down

0 comments on commit 988cf40

Please sign in to comment.