File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
compiler/rustc_expand/src
src/tools/rust-analyzer/crates/proc-macro-srv/src Expand file tree Collapse file tree 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<'_, '_> {
656656 span. shrink_to_hi ( )
657657 }
658658
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+
659669 fn join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
660670 let self_loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( first. lo ( ) ) ;
661671 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 {
9797 fn byte_range( $self: $S:: Span ) -> Range <usize >;
9898 fn start( $self: $S:: Span ) -> $S:: Span ;
9999 fn end( $self: $S:: Span ) -> $S:: Span ;
100+ fn line( $self: $S:: Span ) -> usize ;
101+ fn column( $self: $S:: Span ) -> usize ;
100102 fn join( $self: $S:: Span , other: $S:: Span ) -> Option <$S:: Span >;
101103 fn subspan( $self: $S:: Span , start: Bound <usize >, end: Bound <usize >) -> Option <$S:: Span >;
102104 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 {
505505 Span ( self . 0 . end ( ) )
506506 }
507507
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+
508524 /// Creates a new span encompassing `self` and `other`.
509525 ///
510526 /// 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 {
329329 fn start ( & mut self , _self_ : Self :: Span ) -> Self :: Span {
330330 tt:: TokenId :: unspecified ( )
331331 }
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+ }
332342}
333343
334344impl server:: Symbol for RustAnalyzer {
You can’t perform that action at this time.
0 commit comments