From e1af85d3dd6ad595cedc0c344418ab0a60f1ce72 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 27 Sep 2023 22:51:07 +0200 Subject: [PATCH] Very simple repair to Span::start() and Span::end() in proc_macro context --- src/wrapper.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wrapper.rs b/src/wrapper.rs index 860b6b7..59fa5b3 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -448,6 +448,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(), + }, + #[cfg(not(proc_macro_span))] Span::Compiler(_) => LineColumn { line: 0, column: 0 }, Span::Fallback(s) => s.start(), } @@ -456,6 +462,12 @@ impl Span { #[cfg(span_locations)] pub fn end(&self) -> LineColumn { match self { + #[cfg(proc_macro_span)] + Span::Compiler(s) => LineColumn { + line: s.end().line(), + column: s.end().column(), + }, + #[cfg(not(proc_macro_span))] Span::Compiler(_) => LineColumn { line: 0, column: 0 }, Span::Fallback(s) => s.end(), }