File tree 4 files changed +38
-0
lines changed
compiler/rustc_expand/src
src/tools/rust-analyzer/crates/proc-macro-srv/src
4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -656,6 +656,16 @@ impl server::Span for Rustc<'_, '_> {
656
656
span. shrink_to_hi ( )
657
657
}
658
658
659
+ fn line ( & mut self , span : Self :: Span ) -> usize {
660
+ let loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
661
+ loc. line
662
+ }
663
+
664
+ fn column ( & mut self , span : Self :: Span ) -> usize {
665
+ let loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
666
+ loc. col . to_usize ( ) + 1
667
+ }
668
+
659
669
fn join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
660
670
let self_loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( first. lo ( ) ) ;
661
671
let other_loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( second. lo ( ) ) ;
Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ macro_rules! with_api {
97
97
fn byte_range( $self: $S:: Span ) -> Range <usize >;
98
98
fn start( $self: $S:: Span ) -> $S:: Span ;
99
99
fn end( $self: $S:: Span ) -> $S:: Span ;
100
+ fn line( $self: $S:: Span ) -> usize ;
101
+ fn column( $self: $S:: Span ) -> usize ;
100
102
fn join( $self: $S:: Span , other: $S:: Span ) -> Option <$S:: Span >;
101
103
fn subspan( $self: $S:: Span , start: Bound <usize >, end: Bound <usize >) -> Option <$S:: Span >;
102
104
fn resolved_at( $self: $S:: Span , at: $S:: Span ) -> $S:: Span ;
Original file line number Diff line number Diff line change @@ -505,6 +505,22 @@ impl Span {
505
505
Span ( self . 0 . end ( ) )
506
506
}
507
507
508
+ /// The one-indexed line of the source file where the span starts.
509
+ ///
510
+ /// To obtain the line of the span's end, use `span.end().line()`.
511
+ #[ unstable( feature = "proc_macro_span" , issue = "54725" ) ]
512
+ pub fn line ( & self ) -> usize {
513
+ self . 0 . line ( )
514
+ }
515
+
516
+ /// The one-indexed column of the source file where the span starts.
517
+ ///
518
+ /// To obtain the column of the span's end, use `span.end().column()`.
519
+ #[ unstable( feature = "proc_macro_span" , issue = "54725" ) ]
520
+ pub fn column ( & self ) -> usize {
521
+ self . 0 . column ( )
522
+ }
523
+
508
524
/// Creates a new span encompassing `self` and `other`.
509
525
///
510
526
/// Returns `None` if `self` and `other` are from different files.
Original file line number Diff line number Diff line change @@ -329,6 +329,16 @@ impl server::Span for RustAnalyzer {
329
329
fn start ( & mut self , _self_ : Self :: Span ) -> Self :: Span {
330
330
tt:: TokenId :: unspecified ( )
331
331
}
332
+
333
+ fn line ( & mut self , _span : Self :: Span ) -> usize {
334
+ // FIXME handle line
335
+ 0
336
+ }
337
+
338
+ fn column ( & mut self , _span : Self :: Span ) -> usize {
339
+ // FIXME handle column
340
+ 0
341
+ }
332
342
}
333
343
334
344
impl server:: Symbol for RustAnalyzer {
You can’t perform that action at this time.
0 commit comments