diff options
Diffstat (limited to 'library/proc_macro/src')
-rw-r--r-- | library/proc_macro/src/bridge/mod.rs | 10 | ||||
-rw-r--r-- | library/proc_macro/src/lib.rs | 8 |
2 files changed, 17 insertions, 1 deletions
diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs index 4c1e196b5..caecda1bc 100644 --- a/library/proc_macro/src/bridge/mod.rs +++ b/library/proc_macro/src/bridge/mod.rs @@ -14,6 +14,7 @@ use std::hash::Hash; use std::marker; use std::mem; use std::ops::Bound; +use std::ops::Range; use std::panic; use std::sync::atomic::AtomicUsize; use std::sync::Once; @@ -93,6 +94,7 @@ macro_rules! with_api { fn source_file($self: $S::Span) -> $S::SourceFile; fn parent($self: $S::Span) -> Option<$S::Span>; fn source($self: $S::Span) -> $S::Span; + fn byte_range($self: $S::Span) -> Range<usize>; fn start($self: $S::Span) -> LineColumn; fn end($self: $S::Span) -> LineColumn; fn before($self: $S::Span) -> $S::Span; @@ -335,6 +337,8 @@ pub enum LitKind { StrRaw(u8), ByteStr, ByteStrRaw(u8), + CStr, + CStrRaw(u8), Err, } @@ -348,6 +352,8 @@ rpc_encode_decode!( StrRaw(n), ByteStr, ByteStrRaw(n), + CStr, + CStrRaw(n), Err, } ); @@ -519,3 +525,7 @@ pub struct ExpnGlobals<Span> { compound_traits!( struct ExpnGlobals<Span> { def_site, call_site, mixed_site } ); + +compound_traits!( + struct Range<T> { start, end } +); diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 9d081c8b8..c64665b6a 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -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}; @@ -488,6 +488,12 @@ impl Span { Span(self.0.source()) } + /// Returns the span's byte position range in the source file. + #[unstable(feature = "proc_macro_span", issue = "54725")] + pub fn byte_range(&self) -> Range<usize> { + self.0.byte_range() + } + /// Gets the starting line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn start(&self) -> LineColumn { |