Renamed to byte_range and changed Range generics [skip ci]

This commit is contained in:
Michael van Straten 2023-03-11 12:14:06 +01:00
parent 3a3ecbfae6
commit c67ae04aca
4 changed files with 6 additions and 7 deletions

View file

@ -634,8 +634,8 @@ impl server::Span for Rustc<'_, '_> {
span.source_callsite() span.source_callsite()
} }
fn position(&mut self, span: Self::Span) -> Range<u32> { fn byte_range(&mut self, span: Self::Span) -> Range<usize> {
Range { start: span.lo().0, end: span.hi().0 } Range { start: span.lo().0 as usize, end: span.hi().0 as usize }
} }
fn start(&mut self, span: Self::Span) -> LineColumn { fn start(&mut self, span: Self::Span) -> LineColumn {

View file

@ -94,7 +94,7 @@ macro_rules! with_api {
fn source_file($self: $S::Span) -> $S::SourceFile; fn source_file($self: $S::Span) -> $S::SourceFile;
fn parent($self: $S::Span) -> Option<$S::Span>; fn parent($self: $S::Span) -> Option<$S::Span>;
fn source($self: $S::Span) -> $S::Span; fn source($self: $S::Span) -> $S::Span;
fn position($self: $S::Span) -> Range<u32>; fn byte_range($self: $S::Span) -> Range<usize>;
fn start($self: $S::Span) -> LineColumn; fn start($self: $S::Span) -> LineColumn;
fn end($self: $S::Span) -> LineColumn; fn end($self: $S::Span) -> LineColumn;
fn before($self: $S::Span) -> $S::Span; fn before($self: $S::Span) -> $S::Span;
@ -295,7 +295,6 @@ mark_noop! {
&'_ str, &'_ str,
String, String,
u8, u8,
u32,
usize, usize,
Delimiter, Delimiter,
LitKind, LitKind,

View file

@ -490,8 +490,8 @@ impl Span {
/// Returns the span's byte position range in the source file. /// Returns the span's byte position range in the source file.
#[unstable(feature = "proc_macro_span", issue = "54725")] #[unstable(feature = "proc_macro_span", issue = "54725")]
pub fn position(&self) -> Range<u32> { pub fn byte_range(&self) -> Range<usize> {
self.0.position() self.0.byte_range()
} }
/// Gets the starting line/column in the source file for this span. /// Gets the starting line/column in the source file for this span.

View file

@ -298,7 +298,7 @@ impl server::Span for RustAnalyzer {
// FIXME handle span // FIXME handle span
span span
} }
fn position(&mut self, _span: Self::Span) -> Range<u32> { fn byte_range(&mut self, _span: Self::Span) -> Range<usize> {
// FIXME handle span // FIXME handle span
Range { start: 0, end: 0 } Range { start: 0, end: 0 }
} }