From 3d4af01930279e9d8d2ee61c88e002f064c2b663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sat, 18 Mar 2023 16:07:14 +0100 Subject: [PATCH] Rename diagnostic span methods in accordance with their usage patterns Diagnostic:: * labeled_primary_span -> span * labeled_secondary_span -> label * primary_span -> unlabeled_span * secondary_span -> unlabeled_secondary_span + made private * labeled_primary_spans -> spans * primary_spans -> unlabeled_spans --- compiler/diagnostics/src/format/test.rs | 86 ++++++++++--------- compiler/diagnostics/src/lib.rs | 54 +++++------- compiler/diagnostics/src/reporter.rs | 3 + compiler/driver/src/lib.rs | 4 +- compiler/hir/src/special.rs | 10 +-- compiler/lowerer/src/lib.rs | 67 +++++++-------- compiler/metadata/src/lexer.rs | 6 +- compiler/metadata/src/lib.rs | 6 +- compiler/metadata/src/parser.rs | 10 +-- compiler/package/src/error.rs | 4 +- compiler/package/src/lib.rs | 34 ++++---- compiler/package/src/manifest.rs | 6 +- compiler/parser/src/base.rs | 10 +-- compiler/parser/src/lib.rs | 11 +-- compiler/resolver/src/lib.rs | 63 ++++++-------- compiler/server/src/lib.rs | 4 +- compiler/typer/src/lib.rs | 22 ++--- compiler/utilities/src/lib.rs | 2 +- .../syntaxes/lushui.tmLanguage.json | 2 +- test/ui/framework/src/failure.rs | 4 +- 20 files changed, 192 insertions(+), 216 deletions(-) diff --git a/compiler/diagnostics/src/format/test.rs b/compiler/diagnostics/src/format/test.rs index a388001b..d31d8f0e 100644 --- a/compiler/diagnostics/src/format/test.rs +++ b/compiler/diagnostics/src/format/test.rs @@ -32,7 +32,7 @@ fn format_single_line_primary_highlight() { let diagnostic = Diagnostic::error() .message("message") - .primary_span(span(8, 11)); + .unlabeled_span(span(8, 11)); assert_format( &diagnostic, @@ -51,7 +51,7 @@ fn format_two_line_primary_highlight() { let mut map = SourceMap::default(); map.add_str(Anonymous, "alpha\nbeta\n"); - let diagnostic = Diagnostic::error().primary_span(span(1, 9)); + let diagnostic = Diagnostic::error().unlabeled_span(span(1, 9)); assert_format( &diagnostic, @@ -75,7 +75,7 @@ fn format_multi_line_primary_highlight() { let diagnostic = Diagnostic::error() .code(ErrorCode::E000) .message("explanation") - .primary_span(span(9, 23)); + .unlabeled_span(span(9, 23)); assert_format( &diagnostic, @@ -106,7 +106,7 @@ fn format_triple_digit_line_number() { let diagnostic = Diagnostic::warning() .message("this is a sentence") - .primary_span(span(124, 133)); + .unlabeled_span(span(124, 133)); assert_format( &diagnostic, @@ -128,9 +128,9 @@ fn format_primary_secondary_highlights() { let diagnostic = Diagnostic::error() .code(ErrorCode::E001) .message("important") - .primary_span(span(7, 11)) - .secondary_span(span(1, 4)) - .secondary_span(span(15, 17)); + .unlabeled_span(span(7, 11)) + .unlabeled_secondary_span(span(1, 4)) + .unlabeled_secondary_span(span(15, 17)); assert_format( &diagnostic, @@ -161,8 +161,8 @@ fn format_primary_secondary_highlight_differing_line_number_widths() { let diagnostic = Diagnostic::bug() .message("placeholder") - .primary_span(span(3, 7)) - .secondary_span(span(19, 28)); + .unlabeled_span(span(3, 7)) + .unlabeled_secondary_span(span(19, 28)); assert_format( &diagnostic, @@ -188,8 +188,8 @@ fn format_highlights_in_different_files() { map.add_str("TWO", "zyx"); let diagnostic = Diagnostic::debug() - .primary_span(span(4, 5)) - .secondary_span(span(11, 13)); + .unlabeled_span(span(4, 5)) + .unlabeled_secondary_span(span(11, 13)); assert_format( &diagnostic, @@ -215,8 +215,8 @@ fn format_highlights_same_line() { let diagnostic = Diagnostic::error() .message("tag") - .primary_span(span(1, 6)) - .secondary_span(span(5, 9)); + .unlabeled_span(span(1, 6)) + .unlabeled_secondary_span(span(5, 9)); assert_format( &diagnostic, @@ -242,10 +242,10 @@ fn format_labeled_highlights() { let diagnostic = Diagnostic::error() .message("labels") - .labeled_primary_span(span(2, 4), "pointer") - .labeled_secondary_span(span(7, 11), "content") - .labeled_primary_span(span(12, 23), "explanation") - .labeled_secondary_span(span(28, 33), "message"); + .span(span(2, 4), "pointer") + .label(span(7, 11), "content") + .span(span(12, 23), "explanation") + .label(span(28, 33), "message"); assert_format( &diagnostic, @@ -285,10 +285,10 @@ fn format_multi_line_labeled_highlights() { let diagnostic = Diagnostic::error() .message("multi-line labels") - .labeled_primary_span(span(2, 4), "pointer\ncontext\nfiller") - .labeled_secondary_span(span(7, 11), "content\n indented") - .labeled_primary_span(span(12, 23), "explanation\naddendum") - .labeled_secondary_span(span(28, 33), "message\n\nbottom"); + .span(span(2, 4), "pointer\ncontext\nfiller") + .label(span(7, 11), "content\n indented") + .span(span(12, 23), "explanation\naddendum") + .label(span(28, 33), "message\n\nbottom"); assert_format( &diagnostic, @@ -334,10 +334,10 @@ fn format_multi_line_labeled_highlights_no_trailing_line_break() { let diagnostic = Diagnostic::error() .message("multi-line labels") - .labeled_primary_span(span(2, 4), "pointer\ncontext\nfiller") - .labeled_secondary_span(span(7, 11), "content\n indented") - .labeled_primary_span(span(12, 23), "explanation\naddendum") - .labeled_secondary_span(span(28, 33), "message\n\nbottom"); + .span(span(2, 4), "pointer\ncontext\nfiller") + .label(span(7, 11), "content\n indented") + .span(span(12, 23), "explanation\naddendum") + .label(span(28, 33), "message\n\nbottom"); assert_format( &diagnostic, @@ -403,7 +403,7 @@ fn format_subdiagnostics() { let diagnostic = Diagnostic::warning() .message("it") - .primary_span(span(5, 7)) + .unlabeled_span(span(5, 7)) .help("helpful") .help("less helpful"); @@ -429,7 +429,7 @@ fn format_subdiagnostics_two_digit_line_numbers() { let diagnostic = Diagnostic::warning() .message("it") - .primary_span(span(104, 106)) + .unlabeled_span(span(104, 106)) .help("helpful") .help("less helpful"); @@ -455,7 +455,7 @@ fn format_multi_line_subdiagnostics() { let diagnostic = Diagnostic::warning() .message("it") - .primary_span(span(5, 7)) + .unlabeled_span(span(5, 7)) .help("helpful\ntip\nhopefully") .help("less helpful\ntip\n"); @@ -482,7 +482,7 @@ fn format_multiple_primary_highlights() { let mut map = SourceMap::default(); map.add_str(Anonymous, "gamma\n"); - let diagnostic = Diagnostic::error().primary_spans([span(1, 2), span(3, 4), span(5, 6)]); + let diagnostic = Diagnostic::error().unlabeled_spans([span(1, 2), span(3, 4), span(5, 6)]); assert_format( &diagnostic, @@ -511,7 +511,9 @@ fn format_zero_length_highlight() { let mut map = SourceMap::default(); map.add_str(Anonymous, "sample\n"); - let diagnostic = Diagnostic::debug().message("nil").primary_span(span(3, 3)); + let diagnostic = Diagnostic::debug() + .message("nil") + .unlabeled_span(span(3, 3)); assert_format( &diagnostic, @@ -530,7 +532,9 @@ fn format_zero_length_highlight_start_of_line() { let mut map = SourceMap::default(); map.add_str(Anonymous, "sample\n"); - let diagnostic = Diagnostic::debug().message("nil").primary_span(span(1, 1)); + let diagnostic = Diagnostic::debug() + .message("nil") + .unlabeled_span(span(1, 1)); assert_format( &diagnostic, @@ -551,7 +555,7 @@ fn format_zero_length_secondary_highlight() { let diagnostic = Diagnostic::debug() .message("nil") - .secondary_span(span(3, 3)); + .unlabeled_secondary_span(span(3, 3)); assert_format( &diagnostic, @@ -573,7 +577,7 @@ fn format_highlight_line_break() { "This is a sentence.\nThis is a follow-up sentence.\n", ); - let diagnostic = Diagnostic::error().labeled_primary_span(span(20, 20), "EOL"); + let diagnostic = Diagnostic::error().span(span(20, 20), "EOL"); assert_format( &diagnostic, @@ -592,7 +596,7 @@ fn format_highlight_end_of_input() { let mut map = SourceMap::default(); map.add_str(Anonymous, "This is a sentence."); - let diagnostic = Diagnostic::error().labeled_primary_span(span(20, 20), "EOI"); + let diagnostic = Diagnostic::error().span(span(20, 20), "EOI"); assert_format( &diagnostic, @@ -613,7 +617,7 @@ fn format_highlight_end_of_input_with_trailing_line_break() { let mut map = SourceMap::default(); map.add_str(Anonymous, "This is a sentence.\n"); - let diagnostic = Diagnostic::error().labeled_primary_span(span(21, 21), "EOI"); + let diagnostic = Diagnostic::error().span(span(21, 21), "EOI"); assert_format( &diagnostic, @@ -638,7 +642,7 @@ fn format_highlight_containing_final_line_break() { let diagnostic = Diagnostic::warning() .message("weird corner case") - .primary_span(span(1, 21)); + .unlabeled_span(span(1, 21)); assert_format( &diagnostic, @@ -661,7 +665,7 @@ fn format_highlight_containing_final_end_of_input() { let mut map = SourceMap::default(); map.add_str(Anonymous, "EVERYTHING\n"); - let diagnostic = Diagnostic::bug().primary_span(span(1, 13)); + let diagnostic = Diagnostic::bug().unlabeled_span(span(1, 13)); assert_format( &diagnostic, @@ -682,7 +686,7 @@ fn format_highlight_in_empty_file() { let diagnostic = Diagnostic::error() .message("this file has to contain something reasonable") - .primary_span(span(1, 1)); + .unlabeled_span(span(1, 1)); assert_format( &diagnostic, @@ -733,7 +737,7 @@ fn format_path_together_with_highlight() { let diagnostic = Diagnostic::error() .message("this file is not acceptable") .path("problematic.txt".into()) - .labeled_primary_span(span(20, 25), "because you set this"); + .span(span(20, 25), "because you set this"); assert_format( &diagnostic, @@ -774,7 +778,7 @@ fn format_two_line_break_highlight_containing_first() { let mut map = SourceMap::default(); map.add_str(Anonymous, "alpha\nbeta\n\ngamma"); - let diagnostic = Diagnostic::bug().primary_span(span(1, 12)); + let diagnostic = Diagnostic::bug().unlabeled_span(span(1, 12)); // @Note I don't actually know how it should be rendered assert_format( @@ -798,7 +802,7 @@ fn format_two_line_breaks_highlight_containing_second() { let mut map = SourceMap::default(); map.add_str(Anonymous, "alpha\n\n"); - let diagnostic = Diagnostic::bug().primary_span(span(1, 8)); + let diagnostic = Diagnostic::bug().unlabeled_span(span(1, 8)); // @Note I don't actually know how it should be rendered assert_format( diff --git a/compiler/diagnostics/src/lib.rs b/compiler/diagnostics/src/lib.rs index fcc4e1c3..15479f0e 100644 --- a/compiler/diagnostics/src/lib.rs +++ b/compiler/diagnostics/src/lib.rs @@ -1,17 +1,5 @@ //! The diagnostics system. -//! -//! # Unimplemented Features -//! -//! * (maybe) subdiagnostics with a span -//! * display style: rich (current system) <-> short -//! * a rust script (in /misc) that finds the lowest [`ErrorCode`] that can be used -//! as well as any unused error codes (searching `compiler/`) -#![feature( - adt_const_params, - anonymous_lifetime_in_impl_trait, - associated_type_bounds, - default_free_fn -)] +#![feature(adt_const_params, associated_type_bounds, default_free_fn)] #![allow(incomplete_features)] // adt_const_params pub use code::{Code, ErrorCode, LintCode}; @@ -59,7 +47,7 @@ impl Diagnostic { self } - fn span(mut self, spanning: impl Spanning, label: Option, role: Role) -> Self { + fn _span(mut self, spanning: impl Spanning, label: Option, role: Role) -> Self { self.untagged.highlights.insert(Highlight { span: spanning.span(), label: label.map(Into::into), @@ -68,27 +56,27 @@ impl Diagnostic { self } - /// Reference a code snippet as one of the focal points of the diagnostic. - pub fn primary_span(self, spanning: impl Spanning) -> Self { - self.span(spanning, None, Role::Primary) - } - /// Reference and label a code snippet as one of the focal points of the diagnostic. - pub fn labeled_primary_span(self, spanning: impl Spanning, label: impl Into) -> Self { - self.span(spanning, Some(label.into()), Role::Primary) + pub fn span(self, spanning: impl Spanning, label: impl Into) -> Self { + self._span(spanning, Some(label.into()), Role::Primary) } - /// Reference a code snippet as auxiliary information for the diagnostic. - pub fn secondary_span(self, spanning: impl Spanning) -> Self { - self.span(spanning, None, Role::Secondary) + /// Reference a code snippet as one of the focal points of the diagnostic. + pub fn unlabeled_span(self, spanning: impl Spanning) -> Self { + self._span(spanning, None, Role::Primary) } /// Reference and label a code snippet as auxiliary information for the diagnostic. - pub fn labeled_secondary_span(self, spanning: impl Spanning, label: impl Into) -> Self { - self.span(spanning, Some(label.into()), Role::Secondary) + pub fn label(self, spanning: impl Spanning, label: impl Into) -> Self { + self._span(spanning, Some(label.into()), Role::Secondary) + } + + #[cfg(test)] + fn unlabeled_secondary_span(self, spanning: impl Spanning) -> Self { + self._span(spanning, None, Role::Secondary) } - fn spans(mut self, spannings: I, label: Option, role: Role) -> Self + fn _spans(mut self, spannings: I, label: Option, role: Role) -> Self where I: Iterator, { @@ -101,20 +89,20 @@ impl Diagnostic { self } - /// Reference several equally important code snippets. - pub fn primary_spans(self, spannings: I) -> Self + /// Reference and label several very and equally important code snippets. + pub fn spans(self, spannings: I, label: impl Into) -> Self where I: IntoIterator, { - self.spans(spannings.into_iter(), None, Role::Primary) + self._spans(spannings.into_iter(), Some(label.into()), Role::Primary) } - /// Reference and label several very and equally important code snippets. - pub fn labeled_primary_spans(self, spannings: I, label: impl Into) -> Self + /// Reference several equally important code snippets. + pub fn unlabeled_spans(self, spannings: I) -> Self where I: IntoIterator, { - self.spans(spannings.into_iter(), Some(label.into()), Role::Primary) + self._spans(spannings.into_iter(), None, Role::Primary) } fn subdiagnostic(mut self, severity: Subseverity, message: Str) -> Self { diff --git a/compiler/diagnostics/src/reporter.rs b/compiler/diagnostics/src/reporter.rs index 731f3c6f..a8eb532d 100644 --- a/compiler/diagnostics/src/reporter.rs +++ b/compiler/diagnostics/src/reporter.rs @@ -13,6 +13,9 @@ use std::{ }; use utilities::{pluralize, Conjunction, ListingExt}; +// @Task diagnostic formatting options +// like display style: verbose (current default) vs. terse + /// A diagnostic reporter. pub struct Reporter { kind: ReporterKind, diff --git a/compiler/driver/src/lib.rs b/compiler/driver/src/lib.rs index 7ce2b84c..2461e474 100644 --- a/compiler/driver/src/lib.rs +++ b/compiler/driver/src/lib.rs @@ -295,7 +295,7 @@ fn build_unit( Diagnostic::error() .message(message) .path(path.bare.into()) - .primary_span(path) + .unlabeled_span(path) .note(error.format()) .report(session.reporter()) })?; @@ -381,7 +381,7 @@ fn build_unit( unit.name, Session::PROGRAM_ENTRY_IDENTIFIER, )) - .primary_span(&session.shared_map()[file]) + .unlabeled_span(&session.shared_map()[file]) .report(session.reporter())); } diff --git a/compiler/hir/src/special.rs b/compiler/hir/src/special.rs index e0ab9d7f..35ee1930 100644 --- a/compiler/hir/src/special.rs +++ b/compiler/hir/src/special.rs @@ -520,13 +520,13 @@ impl Bindings { style.as_path(&binder), kind.article() )) - .primary_span(match style { + .unlabeled_span(match style { DefinitionStyle::Implicit { .. } => binder.span(), DefinitionStyle::Explicit { name } => name.span(), }) .with(|error| match style { DefinitionStyle::Implicit { .. } => error - .labeled_secondary_span( + .label( attribute, match kind { Kind::Intrinsic => { @@ -563,8 +563,8 @@ impl Bindings { .message(format!( "the {kind} binding ‘{special}’ is defined multiple times" )) - .labeled_primary_span(binder, "redefinition") - .labeled_secondary_span(previous, "previous definition")); + .span(binder, "redefinition") + .label(previous, "previous definition")); } self.insert_unchecked(special, binder); @@ -655,7 +655,7 @@ fn missing_binding_error(special: Binding, user: Option) -> Diagnostic { .message(format!("the {kind} binding ‘{special}’ is not defined")) .with(|error| match user { // @Task label - Some(user) => error.labeled_primary_span(user, "the type of this expression"), + Some(user) => error.span(user, "the type of this expression"), None => error, }) } diff --git a/compiler/lowerer/src/lib.rs b/compiler/lowerer/src/lib.rs index 7352b1a5..36aed027 100644 --- a/compiler/lowerer/src/lib.rs +++ b/compiler/lowerer/src/lib.rs @@ -248,7 +248,7 @@ impl<'a> Lowerer<'a> { "‘{}’ is defined multiple times in this scope", constructor.binder )) - .labeled_primary_span(&body, "conflicting definition") + .span(&body, "conflicting definition") .note( "the body of the constructor is implied but it also has a body introduced by ‘= ?value’", ).handle(&mut *self); @@ -311,7 +311,7 @@ impl<'a> Lowerer<'a> { .code(ErrorCode::E016) .message(format!("could not load the module ‘{}’", module.binder)) .path(path) - .primary_span(span) + .unlabeled_span(span) .note(error.format()) .handle(&mut *self); } @@ -359,7 +359,7 @@ impl<'a> Lowerer<'a> { let _: ErasedReportedError = Diagnostic::error() .code(ErrorCode::E041) .message("the module header has to be the first declaration of the module") - .primary_span(&declaration) + .unlabeled_span(&declaration) .with(|error| { if has_header { // @Task make this a note with a span/highlight! @@ -556,14 +556,14 @@ impl<'a> Lowerer<'a> { // @Beacon @Task add UI test for this ast::Quantifier::Sigma => Diagnostic::error() .message("sigma-type expressions are not supported yet") - .primary_span(expression.span) + .unlabeled_span(expression.span) .handle(&mut *self), }, Application(application) => { if let Some(binder) = &application.binder { let _: ErasedReportedError = Diagnostic::error() .message("named arguments are not supported yet") - .primary_span(binder) + .unlabeled_span(binder) .handle(&mut *self); } @@ -591,13 +591,13 @@ impl<'a> Lowerer<'a> { } TypedHole(_hole) => Diagnostic::error() .message("typed holes are not supported yet") - .primary_span(expression.span) + .unlabeled_span(expression.span) .handle(&mut *self), // @Task avoid re-boxing! Path(path) => lowered_ast::Expression::new(attributes, expression.span, (*path).into()), Projection(_projection) => Diagnostic::error() .message("record field projections are not supported yet") - .primary_span(expression.span) + .unlabeled_span(expression.span) .handle(&mut *self), LambdaLiteral(lambda) => { // @Task transfer expression.attributes to lowered form in some way or the other. @@ -648,7 +648,7 @@ impl<'a> Lowerer<'a> { Diagnostic::error() .code(ErrorCode::E012) .message(format!("the let-binding ‘{binder}’ does not have a body")) - .labeled_primary_span(span, "missing definition") + .span(span, "missing definition") .suggest( span, "provide a definition for the let-binding", @@ -718,7 +718,7 @@ impl<'a> Lowerer<'a> { } UseBinding(_binding) => Diagnostic::error() .message("use-bindings are not supported yet") - .primary_span(expression.span) + .unlabeled_span(expression.span) .handle(&mut *self), CaseAnalysis(analysis) => { let mut cases = Vec::new(); @@ -740,7 +740,7 @@ impl<'a> Lowerer<'a> { } DoBlock(_block) => Diagnostic::error() .message("do blocks are not supported yet") - .primary_span(expression.span) + .unlabeled_span(expression.span) .handle(&mut *self), SequenceLiteral(sequence) => lowered_ast::Expression::new( attributes, @@ -779,7 +779,7 @@ impl<'a> Lowerer<'a> { if let Some(binder) = &application.binder { let _: ErasedReportedError = Diagnostic::error() .message("named arguments are not supported yet") - .primary_span(binder) + .unlabeled_span(binder) .handle(&mut *self); } @@ -847,8 +847,8 @@ impl<'a> Lowerer<'a> { attribute.bare.name(), target.name() )) - .labeled_primary_span(&attribute, "misplaced attribute") - .labeled_secondary_span(target, "incompatible item") + .span(&attribute, "misplaced attribute") + .label(target, "incompatible item") .note(format!( "attribute ‘{}’ can only be ascribed to {}", attribute.bare.name(), @@ -891,10 +891,7 @@ impl<'a> Lowerer<'a> { let _: ErasedReportedError = Diagnostic::error() .code(ErrorCode::E006) .message(format!("multiple ‘{}’ attributes", first.bare.name())) - .labeled_primary_spans( - homonymous_attributes, - "duplicate or conflicting attribute", - ) + .spans(homonymous_attributes, "duplicate or conflicting attribute") .handle(&mut *self); } } @@ -916,7 +913,7 @@ impl<'a> Lowerer<'a> { "the attribute ‘{}’ is not supported yet", attribute.bare.name() )) - .primary_span(attribute) + .unlabeled_span(attribute) .handle(&mut *self); } @@ -929,7 +926,7 @@ impl<'a> Lowerer<'a> { "the attribute ‘{}’ is an internal feature", attribute.bare.name() )) - .primary_span(attribute) + .unlabeled_span(attribute) .handle(&mut *self); } } @@ -949,7 +946,7 @@ impl<'a> Lowerer<'a> { let _: ErasedReportedError = Diagnostic::error() .code(ErrorCode::E014) .message(format!("attributes {listing} are mutually exclusive")) - .labeled_primary_spans(attributes, "conflicting attribute") + .spans(attributes, "conflicting attribute") .handle(self); } } @@ -1107,8 +1104,8 @@ the body containing a set of constructors .message(format!( "the declaration ‘{binder}’ marked as ‘intrinsic’ has a body", )) - .labeled_primary_span(body_span, body_label) - .labeled_secondary_span( + .span(body_span, body_label) + .label( intrinsic, "marks the declaration as being defined outside of the language", ) @@ -1117,7 +1114,7 @@ the body containing a set of constructors (None, None) => Diagnostic::error() .code(ErrorCode::E012) .message(format!("the declaration ‘{binder}’ does not have a body")) - .labeled_primary_span(missing_definition_span, "missing definition") + .span(missing_definition_span, "missing definition") .suggest( missing_definition_span, "provide a definition for the declaration", @@ -1189,7 +1186,7 @@ impl BareAttributeExt for lowered_ast::BareAttribute { Diagnostic::error() .code(ErrorCode::E019) .message("too few attribute arguments provided") - .primary_span(span) + .unlabeled_span(span) .report(reporter), ) })?; @@ -1261,7 +1258,7 @@ impl BareAttributeExt for lowered_ast::BareAttribute { return Err(AttributeParsingError::Erased( Diagnostic::error() .message("the attribute ‘if’ is not supported yet") - .primary_span(attribute) + .unlabeled_span(attribute) .report(session.reporter()), )); } @@ -1304,7 +1301,7 @@ impl BareAttributeExt for lowered_ast::BareAttribute { "attribute argument does not fit integer interval \ {NAT32_INTERVAL_REPRESENTATION}", )) - .primary_span(depth) + .unlabeled_span(depth) .report(session.reporter()), ) })?; @@ -1319,7 +1316,7 @@ impl BareAttributeExt for lowered_ast::BareAttribute { return Err(AttributeParsingError::Erased( Diagnostic::error() .message("the attribute ‘unstable’ is not supported yet") - .primary_span(attribute) + .unlabeled_span(attribute) .report(session.reporter()), )); } @@ -1336,7 +1333,7 @@ impl BareAttributeExt for lowered_ast::BareAttribute { let error = Diagnostic::error() .code(ErrorCode::E019) .message("too many attribute arguments provided") - .primary_span(argument.span.merge(arguments.last())) + .unlabeled_span(argument.span.merge(arguments.last())) .report(session.reporter()); health.taint(error); } @@ -1347,7 +1344,7 @@ impl BareAttributeExt for lowered_ast::BareAttribute { AttributeParsingError::UndefinedAttribute(binder) => Diagnostic::error() .code(ErrorCode::E011) .message(format!("the attribute ‘{binder}’ is not defined")) - .primary_span(&binder) + .unlabeled_span(&binder) .report(session.reporter()), AttributeParsingError::Erased(error) => error, }) @@ -1538,7 +1535,7 @@ impl LintExt for lowered_ast::attribute::Lint { Diagnostic::error() .code(ErrorCode::E018) .message(format!("the lint ‘{binder}’ is not defined")) - .primary_span(binder.span()) + .unlabeled_span(binder.span()) .report(reporter), )) } @@ -1548,7 +1545,7 @@ fn invalid_unnamed_path_hanger(hanger: ast::Hanger) -> Diagnostic { Diagnostic::error() .code(ErrorCode::E025) .message(format!("path ‘{hanger}’ is not bound to an identifier")) - .primary_span(hanger) + .unlabeled_span(hanger) .note("a use-declaration has to introduce at least one new binder") .help("bind the path to a name with ‘as’") } @@ -1557,7 +1554,7 @@ fn incorrectly_positioned_path_hanger(hanger: ast::Hanger) -> Diagnostic { Diagnostic::error() .code(ErrorCode::E026) .message(format!("path ‘{hanger}’ not allowed in this position")) - .primary_span(hanger) + .unlabeled_span(hanger) .help("consider moving this path to a separate use-declaration") } @@ -1571,7 +1568,7 @@ fn unexpected_named_attribute_argument_error( .message(format!( "found named argument ‘{actual}’ but expected ‘{expected}’" )) - .primary_span(actual) + .unlabeled_span(actual) } // @Temporary signature @@ -1582,7 +1579,7 @@ fn invalid_attribute_argument_type_error( Diagnostic::error() .code(ErrorCode::E027) .message(format!("found {actual} but expected {expected}")) - .primary_span(actual) + .unlabeled_span(actual) } fn missing_mandatory_type_annotation_error( @@ -1606,7 +1603,7 @@ fn missing_mandatory_type_annotation_error( Diagnostic::error() .code(ErrorCode::E015) .message(format!("the {target} does not have a type annotation")) - .labeled_primary_span(span, "missing mandatory type annotation") + .span(span, "missing mandatory type annotation") .suggest( span, format!("annotate the {} with a type", target.name()), diff --git a/compiler/metadata/src/lexer.rs b/compiler/metadata/src/lexer.rs index f3f33378..ed54f397 100644 --- a/compiler/metadata/src/lexer.rs +++ b/compiler/metadata/src/lexer.rs @@ -365,12 +365,12 @@ impl From for Diagnostic { Diagnostic::error() .message(message) - .labeled_primary_span(token, "unexpected token") + .span(token, "unexpected token") } // @Task improve message, mention closing it with quotes Error::UnterminatedText(span) => Diagnostic::error() .message("unterminated text") - .primary_span(span), + .unlabeled_span(span), Error::NumberExceedsSizeLimit(parse_error) => { use std::num::IntErrorKind::*; @@ -381,7 +381,7 @@ impl From for Diagnostic { NegOverflow => error.note("numbers must not be smaller than -2^63"), _ => error, }) - .primary_span(parse_error) + .unlabeled_span(parse_error) } } } diff --git a/compiler/metadata/src/lib.rs b/compiler/metadata/src/lib.rs index 88051f4f..2f8fc291 100644 --- a/compiler/metadata/src/lib.rs +++ b/compiler/metadata/src/lib.rs @@ -205,7 +205,7 @@ pub fn convert>( .message(format!( "expected type ‘{expected}’ but got type ‘{actual}’", )) - .labeled_primary_span(value.span, "has the wrong type") + .span(value.span, "has the wrong type") .report(reporter) })?, )) @@ -230,7 +230,7 @@ impl<'r> RecordWalker<'r> { None => Err(Diagnostic::error() .code(ErrorCode::E802) .message(format!("the record does not contain the entry ‘{key}’")) - .primary_span(&self.record) + .unlabeled_span(&self.record) .report(self.reporter)), } } @@ -252,7 +252,7 @@ impl<'r> RecordWalker<'r> { Diagnostic::error() .code(ErrorCode::E801) .message(format!("the record contains the unknown entry ‘{key}’")) - .primary_span(key) + .unlabeled_span(key) .report(self.reporter); } diff --git a/compiler/metadata/src/parser.rs b/compiler/metadata/src/parser.rs index af8671b8..8056f26f 100644 --- a/compiler/metadata/src/parser.rs +++ b/compiler/metadata/src/parser.rs @@ -81,7 +81,7 @@ impl<'a> Parser<'a> { } else { Err(Diagnostic::error() .message(format!("found {token} but expected {expected}")) - .primary_span(token) + .unlabeled_span(token) .report(self.reporter)) } } @@ -188,7 +188,7 @@ impl<'a> Parser<'a> { } _ => Err(Diagnostic::error() .message(format!("found {} but expected value", self.current_token())) - .primary_span(span) + .unlabeled_span(span) .report(self.reporter)), } } @@ -251,8 +251,8 @@ impl<'a> Parser<'a> { let error = Diagnostic::error() .code(ErrorCode::E803) .message(format!("the entry ‘{key}’ is defined multiple times")) - .labeled_primary_span(key.span, "redefinition") - .labeled_secondary_span(previous_key.span, "previous definition") + .span(key.span, "redefinition") + .label(previous_key.span, "previous definition") .report(self.reporter); self.health.taint(error); } else { @@ -316,7 +316,7 @@ impl<'a> Parser<'a> { token => { return Err(Diagnostic::error() .message(format!("found {token} but expected record key")) - .primary_span(span) + .unlabeled_span(span) .report(self.reporter)); } }; diff --git a/compiler/package/src/error.rs b/compiler/package/src/error.rs index 25ae4df0..383be1b3 100644 --- a/compiler/package/src/error.rs +++ b/compiler/package/src/error.rs @@ -25,7 +25,7 @@ pub(crate) fn undefined_component(name: Spanned<&Word>, package: &Word) -> Diagn .message(format!( "the package ‘{package}’ does not contain a component called ‘{name}’" )) - .primary_span(name) + .unlabeled_span(name) } pub(crate) fn non_library_dependency( @@ -37,6 +37,6 @@ pub(crate) fn non_library_dependency( .message(format!( "the component ‘{name}’ in package ‘{package}’ is not a library", )) - .primary_span(name) + .unlabeled_span(name) .note(format!("one cannot depend on {type_} components")) } diff --git a/compiler/package/src/lib.rs b/compiler/package/src/lib.rs index 4b0b7791..30441a22 100644 --- a/compiler/package/src/lib.rs +++ b/compiler/package/src/lib.rs @@ -189,7 +189,7 @@ impl BuildQueue { { let error = Diagnostic::error() .message(format!("the component type ‘{type_}’ is not supported yet")) - .primary_span(type_) + .unlabeled_span(type_) .report(&self.reporter); health.taint(error); } @@ -198,7 +198,7 @@ impl BuildQueue { if let Some(public) = component.bare.public { let error = Diagnostic::error() .message("setting the component exposure is not supported yet") - .primary_span(public) + .unlabeled_span(public) .report(&self.reporter); health.taint(error); } @@ -248,7 +248,7 @@ impl BuildQueue { pluralize!(cycle.len(), "component"), pluralize!(cycle.len(), "is", "are"), )) - .primary_spans(cycle) + .unlabeled_spans(cycle) .report(&self.reporter); } @@ -377,7 +377,7 @@ impl BuildQueue { if let Some(version) = &declaration.bare.version { return Err(Diagnostic::error() .message("version requirements are not supported yet") - .primary_span(version) + .unlabeled_span(version) .report(&self.reporter) .into()); } @@ -386,7 +386,7 @@ impl BuildQueue { if let Some(public) = &declaration.bare.public { return Err(Diagnostic::error() .message("setting the dependency exposure is not supported yet") - .primary_span(public) + .unlabeled_span(public) .report(&self.reporter) .into()); } @@ -462,7 +462,7 @@ impl BuildQueue { "the components ‘{dependent_component_name}’ and ‘{component_endonym}’ are circular", )) // @Task add the span of "the" counterpart component - .primary_span(component_exonym) + .unlabeled_span(component_exonym) .report(&self.reporter), )) // @Task this should definitely not be fatal fatal since we wanna catch separate cycles (eg. {{a,b,c}, {a,sep}}) @@ -486,7 +486,7 @@ impl BuildQueue { "could not load the dependency ‘{component_exonym}’", )) .path(manifest_path_unchecked) - .primary_span(match &declaration.bare.path { + .unlabeled_span(match &declaration.bare.path { Some(path) => path.span, None => component_exonym.span, }) @@ -531,7 +531,7 @@ impl BuildQueue { return Err( Diagnostic::error() .message("declared package name does not match actual one") - .primary_span(package_name) + .unlabeled_span(package_name) .report(&self.reporter) .into() ); @@ -638,7 +638,7 @@ impl BuildQueue { return Err(Diagnostic::error() .message("@Task") .with(|error| match declaration.provider { - Some(provider) => error.primary_span(provider), + Some(provider) => error.unlabeled_span(provider), None => error, }) .report(&self.reporter)); @@ -651,9 +651,9 @@ impl BuildQueue { // @Question can we point at the field/key `path` instead of its value? return Err(Diagnostic::error() .message("@Task") - .primary_span(path) + .unlabeled_span(path) .with(|error| match declaration.provider { - Some(provider) => error.primary_span(provider), + Some(provider) => error.unlabeled_span(provider), None => error, }) .report(&self.reporter)); @@ -667,12 +667,10 @@ impl BuildQueue { // @Task improve message None => Err(Diagnostic::error() .message("dependency declaration does not have entry ‘path’") - .primary_span(span) + .unlabeled_span(span) .with(|error| match declaration.provider.as_ref() { // Currently always present in this branch. - Some(provider) => { - error.labeled_secondary_span(provider, "required by this") - } + Some(provider) => error.label(provider, "required by this"), None => error, }) .report(&self.reporter)), @@ -692,10 +690,8 @@ impl BuildQueue { )) // @Task better label! say how it was inferred!! .with(|error| match declaration.provider { - Some(provider) => error.primary_span(provider), - None => { - error.labeled_primary_span(span, format!("implies provider ‘{provider}’")) - } + Some(provider) => error.unlabeled_span(provider), + None => error.span(span, format!("implies provider ‘{provider}’")), }) .report(&self.reporter)), } diff --git a/compiler/package/src/manifest.rs b/compiler/package/src/manifest.rs index 7e947e8b..4b28e484 100644 --- a/compiler/package/src/manifest.rs +++ b/compiler/package/src/manifest.rs @@ -69,7 +69,7 @@ fn parse_name( Diagnostic::error() .code(ErrorCode::E036) .message(format!("the {kind} name ‘{name}’ is not a valid word")) - .primary_span(span) + .unlabeled_span(span) .report(reporter) }) } @@ -160,7 +160,7 @@ fn parse_component_type( // fine-tuned suggestion Diagnostic::error() .message(format!("‘{type_}’ is not a valid component type")) - .primary_span(span) + .unlabeled_span(span) .note(format!( "valid component types are {}", ComponentType::elements() @@ -214,7 +214,7 @@ fn parse_dependencies( // fine-tuned suggestion Diagnostic::error() .message(format!("‘{name}’ is not a valid dependency provider")) - .primary_span(span) + .unlabeled_span(span) .note(format!( "valid dependency providers are {}", DependencyProvider::elements() diff --git a/compiler/parser/src/base.rs b/compiler/parser/src/base.rs index 6ab73956..4a397588 100644 --- a/compiler/parser/src/base.rs +++ b/compiler/parser/src/base.rs @@ -200,7 +200,7 @@ impl Expected { Diagnostic::error() .code(ErrorCode::E010) .message(format!("found {actual} but expected {self}")) - .labeled_primary_span(actual, "unexpected token") + .span(actual, "unexpected token") } } @@ -296,7 +296,7 @@ impl LexerErrorExt for lexer::Error { "invalid indentation consisting of {} spaces", difference.0 )) - .primary_span(self.span) + .unlabeled_span(self.span) .note(match error { IndentationError::Misaligned => { format!("indentation needs to be a multiple of {}", INDENTATION.0) @@ -312,12 +312,12 @@ impl LexerErrorExt for lexer::Error { // @Task code Diagnostic::error() .message(message) - .labeled_primary_span(self.span, "unexpected token") + .span(self.span, "unexpected token") } UnbalancedBracket(bracket) => Diagnostic::error() .code(ErrorCode::E044) .message(format!("unbalanced {} bracket", bracket.kind)) - .labeled_primary_span( + .span( self.span, format!( "has no matching {} {} bracket", @@ -328,7 +328,7 @@ impl LexerErrorExt for lexer::Error { UnterminatedTextLiteral => Diagnostic::error() .code(ErrorCode::E047) .message("unterminated text literal") - .primary_span(self.span), + .unlabeled_span(self.span), } } } diff --git a/compiler/parser/src/lib.rs b/compiler/parser/src/lib.rs index e0ee9a20..b62062b1 100644 --- a/compiler/parser/src/lib.rs +++ b/compiler/parser/src/lib.rs @@ -920,10 +920,7 @@ impl Parser<'_> { return Err( expected_one_of![Expected::Parameter, ThinArrowRight, DoubleAsterisk] .but_actual_is(self.token()) - .labeled_secondary_span( - span, - "while parsing this quantified type starting here", - ) + .label(span, "while parsing this quantified type starting here") .report(self.reporter), ); } @@ -1429,8 +1426,8 @@ impl Parser<'_> { } else if let Some(explicitness) = explicitness { return Err(Expected::Category("function argument") .but_actual_is(self.token()) - .labeled_secondary_span(&callee, "while parsing this function application") - .labeled_secondary_span( + .label(&callee, "while parsing this function application") + .label( explicitness, "this apostrophe marks the start of an implicit argument", ) @@ -1617,7 +1614,7 @@ impl Parser<'_> { _ => { return Err(expected_one_of![Word, OpeningRoundBracket] .but_actual_is(self.token()) - .labeled_secondary_span(span, "while parsing this attribute starting here") + .label(span, "while parsing this attribute starting here") .report(self.reporter)); } } diff --git a/compiler/resolver/src/lib.rs b/compiler/resolver/src/lib.rs index accf913b..708739fb 100644 --- a/compiler/resolver/src/lib.rs +++ b/compiler/resolver/src/lib.rs @@ -64,7 +64,7 @@ pub fn resolve_declarations( "‘{}’ is defined multiple times in this scope", resolver.session[binder].source, )) - .labeled_primary_spans(naming_conflicts, "conflicting definition") + .spans(naming_conflicts, "conflicting definition") .report(resolver.session.reporter()); } @@ -651,7 +651,7 @@ impl<'sess, 'ctx> ResolverMut<'sess, 'ctx> { pluralize!(cycle.len(), "declaration"), pluralize!(cycle.len(), "is", "are"), )) - .primary_spans( + .unlabeled_spans( cycle .into_iter() .map(|&index| self.session[index].source.span()), @@ -702,14 +702,8 @@ impl<'sess, 'ctx> ResolverMut<'sess, 'ctx> { "re-export of the more private binding ‘{}’", self.session.index_to_path(target_index) )) - .labeled_primary_span( - &entity.source, - "re-exporting binding with greater exposure", - ) - .labeled_secondary_span( - &target.source, - "re-exported binding with lower exposure", - ) + .span(&entity.source, "re-exporting binding with greater exposure") + .label(&target.source, "re-exported binding with lower exposure") .note(format!( "\ expected the exposure of ‘{}’ @@ -837,7 +831,7 @@ impl<'a> Resolver<'a> { UseBinding => { return Err(Diagnostic::error() .message("use-bindings are not supported yet") - .primary_span(&expression) + .unlabeled_span(&expression) .report(self.session.reporter())); } CaseAnalysis(analysis) => { @@ -1011,7 +1005,7 @@ impl<'a> Resolver<'a> { .message(format!( "number literal ‘{literal}’ does not fit type ‘{type_}’", )) - .primary_span(literal) + .unlabeled_span(literal) .note(format!( "values of this type must fit integer interval {}", type_.interval(), @@ -1078,7 +1072,7 @@ impl<'a> Resolver<'a> { let path = sequence.bare.path.as_ref().ok_or_else(|| { Diagnostic::error() .message("sequence literals without explicit type are not supported yet") - .primary_span(&sequence.bare.elements) + .unlabeled_span(&sequence.bare.elements) .help("consider prefixing the literal with a path to a type followed by a ‘.’") .report(self.session.reporter()) })?; @@ -1119,7 +1113,7 @@ impl<'a> Resolver<'a> { element types cannot be inferred and\n\ have to be manually supplied as the first “element”", ) - .primary_span(span) + .unlabeled_span(span) .report(self.session.reporter())); }; @@ -1210,7 +1204,7 @@ impl<'a> Resolver<'a> { element types cannot be inferred and\n\ have to be manually supplied as the first “element”", ) - .primary_span(span) + .unlabeled_span(span) .report(self.session.reporter())); }; @@ -1311,7 +1305,7 @@ impl<'a> Resolver<'a> { element types cannot be inferred and\n\ have to be manually supplied to the left of each element", ) - .primary_span(elements.span) + .unlabeled_span(elements.span) .report(self.session.reporter())); } @@ -1407,8 +1401,8 @@ impl<'a> Resolver<'a> { "a {name} literal is not a valid constructor for type ‘{}’", self.session[type_.bare].source )) - .labeled_primary_span(literal, "this literal may not construct the type") - .labeled_secondary_span(type_, "the data type") + .span(literal, "this literal may not construct the type") + .label(type_, "the data type") } fn resolve_path_of_literal( @@ -1429,11 +1423,8 @@ impl<'a> Resolver<'a> { return Err(Diagnostic::error() .message(format!("binding ‘{path}’ is not a data type")) // @Task future-proof a/an - .labeled_primary_span(path, format!("a {}", entity.kind.name())) - .labeled_secondary_span( - literal, - "literal requires a data type as its namespace", - ) + .span(path, format!("a {}", entity.kind.name())) + .label(literal, "literal requires a data type as its namespace") .report(self.session.reporter())); } } @@ -1457,7 +1448,7 @@ impl<'a> Resolver<'a> { // @Task improve the error message, code return Err(Diagnostic::error() .message("path ‘extern’ is used in isolation") - .primary_span(hanger) + .unlabeled_span(hanger) .note("the path segment ‘extern’ is only to be used indirectly to refer to specific component") .report(self.session.reporter()).into()); }; @@ -1470,7 +1461,7 @@ impl<'a> Resolver<'a> { .message(format!( "the component name ‘{component}’ is not a valid word" )) - .primary_span(component) + .unlabeled_span(component) .report(self.session.reporter()) })?; @@ -1490,7 +1481,7 @@ impl<'a> Resolver<'a> { // @Task better phrasing return Err(Diagnostic::error() .message(format!("the component ‘{component}’ is not defined")) - .primary_span(component) + .unlabeled_span(component) .report(self.session.reporter()) .into()); }; @@ -1571,7 +1562,7 @@ impl<'a> Resolver<'a> { Diagnostic::error() .code(ErrorCode::E021) // @Question use a dedicated code? .message("the root module does not have a parent module") - .primary_span(hanger) + .unlabeled_span(hanger) .report(self.session.reporter()) }) } @@ -1618,7 +1609,7 @@ impl<'a> Resolver<'a> { Diagnostic::warning() .code(LintCode::Deprecated) .message(message) - .primary_span(identifier) + .unlabeled_span(identifier) .report(self.session.reporter()); } @@ -1654,7 +1645,7 @@ impl<'a> Resolver<'a> { "binding ‘{}’ is private", self.session.index_to_path(index) )) - .primary_span(identifier) + .unlabeled_span(identifier) .report(self.session.reporter()) .into()); } @@ -1716,7 +1707,7 @@ impl<'a> Resolver<'a> { return Err(Diagnostic::error() .code(ErrorCode::E037) .message("exposure can only be restricted to ancestor modules") - .primary_span(path) + .unlabeled_span(path) .report(self.session.reporter())); } @@ -1949,7 +1940,7 @@ impl<'a> Resolver<'a> { Diagnostic::error() .code(ErrorCode::E021) .message(message) - .primary_span(&identifier) + .unlabeled_span(&identifier) .with( |error| match lookalike_finder(identifier.as_str(), namespace) { Some(lookalike) => error.help(format!( @@ -1973,7 +1964,7 @@ impl<'a> Resolver<'a> { "exposure reach ‘{}’ is circular", self.session.index_to_path(binder) )) - .primary_span(extra) + .unlabeled_span(extra) .report(self.session.reporter()) } } @@ -2007,8 +1998,8 @@ impl<'a> Resolver<'a> { Diagnostic::error() .code(ErrorCode::E017) .message(format!("binding ‘{binder}’ is not a namespace")) - .labeled_primary_span(binder, format!("not a namespace but a {}", kind.name())) - .labeled_secondary_span( + .span(binder, format!("not a namespace but a {}", kind.name())) + .label( // the subbinder together with the leading dot // @Task trim_start_matches ascii_whitespace binder.span().end().merge(subbinder), @@ -2324,7 +2315,7 @@ fn module_used_as_a_value_error(module: Spanned) -> Diagnosti Diagnostic::error() .code(ErrorCode::E023) .message(format!("module ‘{module}’ is used as a value")) - .primary_span(module) + .unlabeled_span(module) .help("modules are not first-class citizens, consider utilizing records for such cases instead") } @@ -2453,7 +2444,7 @@ mod target { return Err(Diagnostic::error() .code(ErrorCode::E022) .message(format!("binding ‘{identifier}’ is not a module")) - .primary_span(identifier)); + .unlabeled_span(identifier)); } Ok(()) diff --git a/compiler/server/src/lib.rs b/compiler/server/src/lib.rs index 44d6d5b8..85bc2782 100644 --- a/compiler/server/src/lib.rs +++ b/compiler/server/src/lib.rs @@ -306,7 +306,7 @@ fn build_unit(unit: BuildUnit, session: &mut Session<'_>) -> Result) -> Result Typer<'sess, 'ctx> { .code(ErrorCode::E032) // @Task put back some more information into the message: use `_`s to shorten the type .message("type mismatch") - .labeled_primary_span(actual_value, "has the wrong type") + .span(actual_value, "has the wrong type") .with(|error| match expectation_cause { - Some(cause) => error.labeled_secondary_span(cause, "expected due to this"), + Some(cause) => error.label(cause, "expected due to this"), None => error, }) .note(format!( @@ -540,8 +540,8 @@ expected type ‘{}’ .code(ErrorCode::E032) // @Task put back some more information into the message: use `_`s to shorten the type .message("type mismatch") - .labeled_primary_span(&application.argument, "has the wrong type") - .labeled_secondary_span(&expected, "expected due to this") + .span(&application.argument, "has the wrong type") + .label(&expected, "expected due to this") .note(format!( "\ expected type ‘{}’ @@ -570,8 +570,8 @@ expected type ‘{}’ .code(ErrorCode::E031) // @Task put back some more information into the message: use `_`s to shorten the type .message("type mismatch") - .labeled_primary_span(&application.callee, "has wrong type") - .labeled_secondary_span(&application.argument, "applied to this") + .span(&application.callee, "has wrong type") + .label(&application.argument, "applied to this") .note(format!( "\ expected type ‘_ -> _’ @@ -609,7 +609,7 @@ expected type ‘_ -> _’ return Err(Diagnostic::error() .code(ErrorCode::E035) .message("attempt to analyze a type") - .primary_span(expression.span) + .unlabeled_span(expression.span) .note("forbidden to uphold parametricity and type erasure") .report(self.session.reporter()) .into()); @@ -701,7 +701,7 @@ expected type ‘_ -> _’ "binder ‘{}’ used in callee position inside pattern", binder.0 )) - .primary_span(&binder.0) + .unlabeled_span(&binder.0) .help("consider referring to a concrete binding") .report(self.session.reporter()) .into()); @@ -751,8 +751,8 @@ expected type ‘_ -> _’ .code(ErrorCode::E032) // @Task put back some more information into the message: use `_`s to shorten the type .message("type mismatch") - .labeled_primary_span(pattern, "has the wrong type") - .labeled_secondary_span(scrutinee, "expected due to this") + .span(pattern, "has the wrong type") + .label(scrutinee, "expected due to this") .note(format!( "\ expected type ‘{}’ @@ -872,7 +872,7 @@ but got type ‘{}’", self.display(&result_type), self.display(&type_), )) - .primary_span(result_type.span) + .unlabeled_span(result_type.span) .report(self.session.reporter())) } } diff --git a/compiler/utilities/src/lib.rs b/compiler/utilities/src/lib.rs index f056baee..aa53dbe3 100644 --- a/compiler/utilities/src/lib.rs +++ b/compiler/utilities/src/lib.rs @@ -163,7 +163,7 @@ impl fmt::Display for Conjunction { } } -/// Use the singular or form the plural of the given word depending on the given amount. +/// Use the singular or the plural form of the given word depending on the given amount. /// /// # Examples /// diff --git a/project/editor/vscode/fmease.lushui-0.0.1/syntaxes/lushui.tmLanguage.json b/project/editor/vscode/fmease.lushui-0.0.1/syntaxes/lushui.tmLanguage.json index 0d15b4cf..2f8ead34 100644 --- a/project/editor/vscode/fmease.lushui-0.0.1/syntaxes/lushui.tmLanguage.json +++ b/project/editor/vscode/fmease.lushui-0.0.1/syntaxes/lushui.tmLanguage.json @@ -82,7 +82,7 @@ }, { "match": "(? error, }) .with(|error| match span { - Some(span) => error.primary_span(span), + Some(span) => error.unlabeled_span(span), None => error, }); @@ -100,7 +100,7 @@ impl FailedTest { // @Temporary let diagnostic = Diagnostic::error() .message(error.message.clone()) - .primary_span(error.span); + .unlabeled_span(error.span); write!(sink, "{}", diagnostic.format(Some(map))) }