File tree 3 files changed +20
-0
lines changed
compiler/rustc_expand/src
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -738,6 +738,12 @@ impl server::Span for Rustc<'_> {
738
738
let loc = self . sess . source_map ( ) . lookup_char_pos ( span. hi ( ) ) ;
739
739
LineColumn { line : loc. line , column : loc. col . to_usize ( ) }
740
740
}
741
+ fn before ( & mut self , span : Self :: Span ) -> Self :: Span {
742
+ span. shrink_to_lo ( )
743
+ }
744
+ fn after ( & mut self , span : Self :: Span ) -> Self :: Span {
745
+ span. shrink_to_hi ( )
746
+ }
741
747
fn join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
742
748
let self_loc = self . sess . source_map ( ) . lookup_char_pos ( first. lo ( ) ) ;
743
749
let other_loc = self . sess . source_map ( ) . lookup_char_pos ( second. lo ( ) ) ;
Original file line number Diff line number Diff line change @@ -160,6 +160,8 @@ macro_rules! with_api {
160
160
fn source( $self: $S:: Span ) -> $S:: Span ;
161
161
fn start( $self: $S:: Span ) -> LineColumn ;
162
162
fn end( $self: $S:: Span ) -> LineColumn ;
163
+ fn before( $self: $S:: Span ) -> $S:: Span ;
164
+ fn after( $self: $S:: Span ) -> $S:: Span ;
163
165
fn join( $self: $S:: Span , other: $S:: Span ) -> Option <$S:: Span >;
164
166
fn resolved_at( $self: $S:: Span , at: $S:: Span ) -> $S:: Span ;
165
167
fn source_text( $self: $S:: Span ) -> Option <String >;
Original file line number Diff line number Diff line change @@ -358,6 +358,18 @@ impl Span {
358
358
self . 0 . end ( )
359
359
}
360
360
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
+
361
373
/// Creates a new span encompassing `self` and `other`.
362
374
///
363
375
/// Returns `None` if `self` and `other` are from different files.
You can’t perform that action at this time.
0 commit comments