@@ -3,13 +3,9 @@ use codespan_reporting::files;
33use codespan_reporting:: term;
44use codespan_reporting:: term:: termcolor:: { ColorChoice , StandardStream } ;
55use ndc_interpreter:: InterpreterError ;
6- use ndc_lexer:: { SourceDb , SourceId , Span } ;
6+ use ndc_lexer:: { SourceDb , SourceId } ;
77use std:: ops:: Range ;
88
9- fn span_to_range ( span : Span ) -> Range < usize > {
10- span. offset ( ) ..span. end ( )
11- }
12-
139struct DiagnosticFiles < ' a > ( & ' a SourceDb ) ;
1410
1511impl < ' 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