Skip to content

Commit c629503

Browse files
timfennisclaude
andcommitted
Remove redundant span_to_range wrapper, use Span::range() directly
Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 3eec49f commit c629503

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

ndc_bin/src/diagnostic.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ use codespan_reporting::files;
33
use codespan_reporting::term;
44
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
55
use ndc_interpreter::InterpreterError;
6-
use ndc_lexer::{SourceDb, SourceId, Span};
6+
use ndc_lexer::{SourceDb, SourceId};
77
use std::ops::Range;
88

9-
fn span_to_range(span: Span) -> Range<usize> {
10-
span.offset()..span.end()
11-
}
12-
139
struct DiagnosticFiles<'a>(&'a SourceDb);
1410

1511
impl<'a> files::Files<'a> for DiagnosticFiles<'a> {
@@ -64,7 +60,7 @@ fn into_diagnostic(err: InterpreterError) -> Diagnostic<SourceId> {
6460
.with_code("lexer")
6561
.with_message(cause.to_string())
6662
.with_labels(vec![
67-
Label::primary(span.source_id(), span_to_range(span)).with_message("here"),
63+
Label::primary(span.source_id(), span.range()).with_message("here"),
6864
]);
6965
if let Some(help) = cause.help_text() {
7066
d = d.with_notes(vec![help.to_owned()]);
@@ -77,7 +73,7 @@ fn into_diagnostic(err: InterpreterError) -> Diagnostic<SourceId> {
7773
.with_code("parser")
7874
.with_message(cause.to_string())
7975
.with_labels(vec![
80-
Label::primary(span.source_id(), span_to_range(span)).with_message("here"),
76+
Label::primary(span.source_id(), span.range()).with_message("here"),
8177
]);
8278
if let Some(help) = cause.help_text() {
8379
d = d.with_notes(vec![help.to_owned()]);
@@ -90,8 +86,7 @@ fn into_diagnostic(err: InterpreterError) -> Diagnostic<SourceId> {
9086
.with_code("resolver")
9187
.with_message(cause.to_string())
9288
.with_labels(vec![
93-
Label::primary(span.source_id(), span_to_range(span))
94-
.with_message("related to this"),
89+
Label::primary(span.source_id(), span.range()).with_message("related to this"),
9590
])
9691
}
9792
InterpreterError::Compiler { cause } => {
@@ -100,8 +95,7 @@ fn into_diagnostic(err: InterpreterError) -> Diagnostic<SourceId> {
10095
.with_code("compiler")
10196
.with_message(cause.to_string())
10297
.with_labels(vec![
103-
Label::primary(span.source_id(), span_to_range(span))
104-
.with_message("related to this"),
98+
Label::primary(span.source_id(), span.range()).with_message("related to this"),
10599
])
106100
}
107101
InterpreterError::Vm(err) => {
@@ -110,8 +104,7 @@ fn into_diagnostic(err: InterpreterError) -> Diagnostic<SourceId> {
110104
.with_message(&err.message);
111105
if let Some(span) = err.span {
112106
d = d.with_labels(vec![
113-
Label::primary(span.source_id(), span_to_range(span))
114-
.with_message("related to this"),
107+
Label::primary(span.source_id(), span.range()).with_message("related to this"),
115108
]);
116109
}
117110
d

0 commit comments

Comments
 (0)