Better panic on Span::unstable outside of proc macro
diff --git a/src/lib.rs b/src/lib.rs
index 347b937..c71afd7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -337,6 +337,12 @@
///
/// This method is available when building with a nightly compiler, or when
/// building with rustc 1.29+ *without* semver exempt features.
+ ///
+ /// # Panics
+ ///
+ /// Panics if called from outside of a procedural macro. Unlike
+ /// `proc_macro2::Span`, the `proc_macro::Span` type can only exist within
+ /// the context of a procedural macro invocation.
#[cfg(wrap_proc_macro)]
pub fn unstable(self) -> proc_macro::Span {
self.inner.unstable()
diff --git a/src/unstable.rs b/src/unstable.rs
index c4cf11a..57488dd 100644
--- a/src/unstable.rs
+++ b/src/unstable.rs
@@ -473,7 +473,9 @@
pub fn unstable(self) -> proc_macro::Span {
match self {
Span::Nightly(s) => s,
- Span::Stable(_) => mismatch(),
+ Span::Stable(_) => {
+ panic!("proc_macro::Span is only available in procedural macros")
+ }
}
}