diff --git a/build/probe.rs b/build/probe.rs index 2c4947a..79c8ae2 100644 --- a/build/probe.rs +++ b/build/probe.rs @@ -13,6 +13,22 @@ pub fn byte_range(this: &Span) -> Range { this.byte_range() } +pub fn start(this: &Span) -> Span { + this.start() +} + +pub fn end(this: &Span) -> Span { + this.end() +} + +pub fn line(this: &Span) -> usize { + this.line() +} + +pub fn column(this: &Span) -> usize { + this.column() +} + pub fn join(this: &Span, other: Span) -> Option { this.join(other) } diff --git a/src/wrapper.rs b/src/wrapper.rs index 87e348d..29481c1 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -477,6 +477,12 @@ impl Span { #[cfg(span_locations)] pub fn start(&self) -> LineColumn { match self { + #[cfg(proc_macro_span)] + Span::Compiler(s) => LineColumn { + line: s.line(), + column: s.column().saturating_sub(1), + }, + #[cfg(not(proc_macro_span))] Span::Compiler(_) => LineColumn { line: 0, column: 0 }, Span::Fallback(s) => s.start(), } @@ -485,6 +491,15 @@ impl Span { #[cfg(span_locations)] pub fn end(&self) -> LineColumn { match self { + #[cfg(proc_macro_span)] + Span::Compiler(s) => { + let end = s.end(); + LineColumn { + line: end.line(), + column: end.column().saturating_sub(1), + } + } + #[cfg(not(proc_macro_span))] Span::Compiler(_) => LineColumn { line: 0, column: 0 }, Span::Fallback(s) => s.end(), }