1
Fork 0

Add Span::{line, column}

This commit is contained in:
Jacob Pratt 2023-05-14 18:30:18 -04:00
parent 87ec0738ab
commit a1cd8c3a28
No known key found for this signature in database
GPG key ID: 6E2E55C5F9ABB247
4 changed files with 38 additions and 0 deletions

View file

@ -656,6 +656,16 @@ impl server::Span for Rustc<'_, '_> {
span.shrink_to_hi()
}
fn line(&mut self, span: Self::Span) -> usize {
let loc = self.sess().source_map().lookup_char_pos(span.lo());
loc.line
}
fn column(&mut self, span: Self::Span) -> usize {
let loc = self.sess().source_map().lookup_char_pos(span.lo());
loc.col.to_usize() + 1
}
fn join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span> {
let self_loc = self.sess().source_map().lookup_char_pos(first.lo());
let other_loc = self.sess().source_map().lookup_char_pos(second.lo());