Skip to content

Commit 9298449

Browse files
committed
Add proc_macro::Span::{before, after}.
1 parent 741cca3 commit 9298449

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

proc_macro/src/bridge/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ macro_rules! with_api {
160160
fn source($self: $S::Span) -> $S::Span;
161161
fn start($self: $S::Span) -> LineColumn;
162162
fn end($self: $S::Span) -> LineColumn;
163+
fn before($self: $S::Span) -> $S::Span;
164+
fn after($self: $S::Span) -> $S::Span;
163165
fn join($self: $S::Span, other: $S::Span) -> Option<$S::Span>;
164166
fn resolved_at($self: $S::Span, at: $S::Span) -> $S::Span;
165167
fn source_text($self: $S::Span) -> Option<String>;

proc_macro/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,18 @@ impl Span {
358358
self.0.end()
359359
}
360360

361+
/// Creates an empty span pointing to directly before this span.
362+
#[unstable(feature = "proc_macro_span_shrink", issue = "none")]
363+
pub fn before(&self) -> Span {
364+
Span(self.0.before())
365+
}
366+
367+
/// Creates an empty span pointing to directly after this span.
368+
#[unstable(feature = "proc_macro_span_shrink", issue = "none")]
369+
pub fn after(&self) -> Span {
370+
Span(self.0.after())
371+
}
372+
361373
/// Creates a new span encompassing `self` and `other`.
362374
///
363375
/// Returns `None` if `self` and `other` are from different files.

0 commit comments

Comments
 (0)