Skip to content

Commit dc95810

Browse files
committed
Expose span of LexError via public method
1 parent b28af16 commit dc95810

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/fallback.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ impl LexError {
4747
span: Span::call_site(),
4848
}
4949
}
50+
51+
pub(crate) fn span(&self) -> Span {
52+
self.span
53+
}
5054
}
5155

5256
impl TokenStream {

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ impl Debug for TokenStream {
250250
}
251251
}
252252

253+
impl LexError {
254+
pub fn span(&self) -> Span {
255+
Span::_new(self.inner.span())
256+
}
257+
}
258+
253259
impl Debug for LexError {
254260
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
255261
Debug::fmt(&self.inner, f)

src/wrapper.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ impl Debug for TokenStream {
243243
}
244244
}
245245

246+
impl LexError {
247+
pub(crate) fn span(&self) -> Span {
248+
match self {
249+
LexError::Compiler(_) => Span::call_site(),
250+
LexError::Fallback(e) => Span::Fallback(e.span()),
251+
}
252+
}
253+
}
254+
246255
impl From<proc_macro::LexError> for LexError {
247256
fn from(e: proc_macro::LexError) -> LexError {
248257
LexError::Compiler(e)

0 commit comments

Comments
 (0)