From f601ea30a721bacd75af00f4feb76ce1294f3163 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 2 Dec 2021 11:40:28 +0100 Subject: [PATCH 1/2] Fix usage of proc_macro::is_available() In #300 I made a mistake with the #[cfg] causing proc_macro::is_available() to never actually be used. I have now double checked that it is actually used on Rust 1.57+. --- src/detection.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection.rs b/src/detection.rs index c963abd7..3aa33f80 100644 --- a/src/detection.rs +++ b/src/detection.rs @@ -24,7 +24,7 @@ pub(crate) fn unforce_fallback() { initialize(); } -#[cfg(feature = "is_available")] +#[cfg(is_available)] fn initialize() { let available = proc_macro::is_available(); WORKS.store(available as usize + 1, Ordering::SeqCst); @@ -54,7 +54,7 @@ fn initialize() { // here. For now, if a user needs to guarantee that this failure mode does // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from // the main thread before launching any other threads. -#[cfg(not(feature = "is_available"))] +#[cfg(not(is_available))] fn initialize() { type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static; From a4beb269616d85bb7f33ec317ba3392a47292e0a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 2 Dec 2021 11:43:53 +0100 Subject: [PATCH 2/2] Fix warning when is_available() is used --- src/detection.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection.rs b/src/detection.rs index 3aa33f80..77ec41b3 100644 --- a/src/detection.rs +++ b/src/detection.rs @@ -1,3 +1,4 @@ +#[cfg(not(is_available))] use std::panic::{self, PanicInfo}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Once;