Automatically use rich API on 1.30.0+
This commit detects the rustc version in the build script of proc-macro2
to determine whether the compiler supports the necessary backend APIs.
This should hopefully allow the crate to compile on stable by default
but have a better implementation on 1.30.0+ compilers.
diff --git a/src/lib.rs b/src/lib.rs
index 39ab87a..9eac7d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -45,7 +45,7 @@
// Proc-macro2 types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/proc-macro2/0.4.13")]
#![cfg_attr(
- feature = "nightly",
+ super_unstable,
feature(proc_macro_raw_ident, proc_macro_span)
)]
@@ -65,10 +65,10 @@
mod strnom;
mod stable;
-#[cfg(not(feature = "nightly"))]
+#[cfg(not(wrap_proc_macro))]
use stable as imp;
#[path = "unstable.rs"]
-#[cfg(feature = "nightly")]
+#[cfg(wrap_proc_macro)]
mod imp;
/// An abstract stream of tokens, or more concretely a sequence of token trees.
@@ -328,7 +328,7 @@
}
/// This method is only available when the `"nightly"` feature is enabled.
- #[cfg(all(feature = "nightly", use_proc_macro))]
+ #[cfg(super_unstable)]
pub fn unstable(self) -> proc_macro::Span {
self.inner.unstable()
}