diff options
Diffstat (limited to 'tvix/eval/src/spans.rs')
-rw-r--r-- | tvix/eval/src/spans.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/tvix/eval/src/spans.rs b/tvix/eval/src/spans.rs index c17ad2102ccf..9998e438b220 100644 --- a/tvix/eval/src/spans.rs +++ b/tvix/eval/src/spans.rs @@ -16,23 +16,22 @@ impl ToSpan for Span { } } +impl ToSpan for rnix::TextRange { + fn span_for(&self, file: &File) -> Span { + file.span + .subspan(u32::from(self.start()) as u64, u32::from(self.end()) as u64) + } +} + impl ToSpan for rnix::SyntaxToken { fn span_for(&self, file: &File) -> Span { - let rowan_span = self.text_range(); - file.span.subspan( - u32::from(rowan_span.start()) as u64, - u32::from(rowan_span.end()) as u64, - ) + self.text_range().span_for(file) } } impl ToSpan for rnix::SyntaxNode { fn span_for(&self, file: &File) -> Span { - let rowan_span = self.text_range(); - file.span.subspan( - u32::from(rowan_span.start()) as u64, - u32::from(rowan_span.end()) as u64, - ) + self.text_range().span_for(file) } } |