File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,22 @@ pub fn byte_range(this: &Span) -> Range<usize> {
13
13
this. byte_range ( )
14
14
}
15
15
16
+ pub fn start ( this : & Span ) -> Span {
17
+ this. start ( )
18
+ }
19
+
20
+ pub fn end ( this : & Span ) -> Span {
21
+ this. end ( )
22
+ }
23
+
24
+ pub fn line ( this : & Span ) -> usize {
25
+ this. line ( )
26
+ }
27
+
28
+ pub fn column ( this : & Span ) -> usize {
29
+ this. column ( )
30
+ }
31
+
16
32
pub fn join ( this : & Span , other : Span ) -> Option < Span > {
17
33
this. join ( other)
18
34
}
Original file line number Diff line number Diff line change @@ -477,6 +477,12 @@ impl Span {
477
477
#[ cfg( span_locations) ]
478
478
pub fn start ( & self ) -> LineColumn {
479
479
match self {
480
+ #[ cfg( proc_macro_span) ]
481
+ Span :: Compiler ( s) => LineColumn {
482
+ line : s. line ( ) ,
483
+ column : s. column ( ) . saturating_sub ( 1 ) ,
484
+ } ,
485
+ #[ cfg( not( proc_macro_span) ) ]
480
486
Span :: Compiler ( _) => LineColumn { line : 0 , column : 0 } ,
481
487
Span :: Fallback ( s) => s. start ( ) ,
482
488
}
@@ -485,6 +491,15 @@ impl Span {
485
491
#[ cfg( span_locations) ]
486
492
pub fn end ( & self ) -> LineColumn {
487
493
match self {
494
+ #[ cfg( proc_macro_span) ]
495
+ Span :: Compiler ( s) => {
496
+ let end = s. end ( ) ;
497
+ LineColumn {
498
+ line : end. line ( ) ,
499
+ column : end. column ( ) . saturating_sub ( 1 ) ,
500
+ }
501
+ }
502
+ #[ cfg( not( proc_macro_span) ) ]
488
503
Span :: Compiler ( _) => LineColumn { line : 0 , column : 0 } ,
489
504
Span :: Fallback ( s) => s. end ( ) ,
490
505
}
You can’t perform that action at this time.
0 commit comments