use crate::{ProcMacro, ProcMacroExt};
pub trait Span: ProcMacro<Span = Self> + Copy {
fn call_site() -> Self;
fn mixed_site() -> Self;
fn resolved_at(&self, other: Self) -> Self;
fn located_at(&self, other: Self) -> Self;
fn source_text(&self) -> Option<String>;
}
pub trait SpanExt: ProcMacroExt<SpanExt = Self> + Span {}
macro_rules! impl_span {
($($pm:ident: $feature:literal),*) => { $(
#[cfg(feature = $feature)]
impl Span for $pm::Span {
#[inline]
fn call_site() -> Self {
Self::call_site()
}
#[inline]
fn mixed_site() -> Self {
Self::mixed_site()
}
#[inline]
fn resolved_at(&self, other: Self) -> Self {
self.resolved_at(other)
}
#[inline]
fn located_at(&self, other: Self) -> Self {
self.located_at(other)
}
#[inline]
fn source_text(&self) -> Option<String> {
self.source_text()
}
}
#[cfg(feature = $feature)]
impl SpanExt for $pm::Span {}
)* };
}
impl_span!(proc_macro: "proc-macro", proc_macro2: "proc-macro2");