Expose Span::join on nightly
diff --git a/src/fallback.rs b/src/fallback.rs
index f49318c..92722af 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -1,6 +1,6 @@
#[cfg(span_locations)]
use std::cell::RefCell;
-#[cfg(procmacro2_semver_exempt)]
+#[cfg(span_locations)]
use std::cmp;
use std::fmt;
use std::iter;
@@ -407,7 +407,12 @@
})
}
- #[cfg(procmacro2_semver_exempt)]
+ #[cfg(not(span_locations))]
+ pub fn join(&self, _other: Span) -> Option<Span> {
+ Some(Span {})
+ }
+
+ #[cfg(span_locations)]
pub fn join(&self, other: Span) -> Option<Span> {
SOURCE_MAP.with(|cm| {
let cm = cm.borrow();
diff --git a/src/lib.rs b/src/lib.rs
index 93e0523..0932131 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -420,8 +420,11 @@
///
/// Returns `None` if `self` and `other` are from different files.
///
- /// This method is semver exempt and not exposed by default.
- #[cfg(procmacro2_semver_exempt)]
+ /// Warning: the underlying [`proc_macro::Span::join`] method is
+ /// nightly-only. When called from within a procedural macro not using a
+ /// nightly compiler, this method will always return `None`.
+ ///
+ /// [`proc_macro::Span::join`]: https://doc.rust-lang.org/proc_macro/struct.Span.html#method.join
pub fn join(&self, other: Span) -> Option<Span> {
self.inner.join(other.inner).map(Span::_new)
}
diff --git a/src/wrapper.rs b/src/wrapper.rs
index 16a0849..af234ae 100644
--- a/src/wrapper.rs
+++ b/src/wrapper.rs
@@ -479,9 +479,9 @@
}
}
- #[cfg(super_unstable)]
pub fn join(&self, other: Span) -> Option<Span> {
let ret = match (self, other) {
+ #[cfg(proc_macro_span)]
(Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.join(b)?),
(Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.join(b)?),
_ => return None,