added byte position range for proc_macro::Span

This commit is contained in:
Michael van Straten
2023-03-10 21:16:35 +01:00
parent 35a0961bbc
commit b8c6d2211e
3 changed files with 19 additions and 2 deletions

View File

@@ -44,7 +44,7 @@ mod diagnostic;
pub use diagnostic::{Diagnostic, Level, MultiSpan};
use std::cmp::Ordering;
use std::ops::RangeBounds;
use std::ops::{Range, RangeBounds};
use std::path::PathBuf;
use std::str::FromStr;
use std::{error, fmt, iter};
@@ -488,6 +488,12 @@ impl Span {
Span(self.0.source())
}
/// Returns the spans byte position range in the source file.
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn position(&self) -> Range<u32> {
self.0.position()
}
/// Gets the starting line/column in the source file for this span.
#[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn start(&self) -> LineColumn {