From 4a2f72fabffee4b20bdd07e4069133734b1272cc Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 15 Jan 2022 01:13:31 +0100 Subject: [PATCH] Remove unnecessary label messages --- src/eval/error.rs | 28 +++++++++------------------- src/files/error.rs | 12 +++++------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/eval/error.rs b/src/eval/error.rs index c78a131..d2cd7dd 100644 --- a/src/eval/error.rs +++ b/src/eval/error.rs @@ -102,9 +102,7 @@ impl<'a, F: Files<'a>> Eprint<'a, F> for Error { let prev_str = Self::fmt_date_time(*prev, *prev_time); Diagnostic::error() .with_message("Delta step resulted in invalid date") - .with_labels(vec![ - Label::primary(*index, span).with_message("At this step") - ]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![ format!("Date before applying delta: {start_str}"), format!("Date before applying this step: {prev_str}"), @@ -117,9 +115,7 @@ impl<'a, F: Files<'a>> Eprint<'a, F> for Error { prev, } => Diagnostic::error() .with_message("Time-based delta step applied to date without time") - .with_labels(vec![ - Label::primary(*index, span).with_message("At this step") - ]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![ format!("Date before applying delta: {start}"), format!("Date before applying this step: {prev}"), @@ -131,7 +127,7 @@ impl<'a, F: Files<'a>> Eprint<'a, F> for Error { to, } => Diagnostic::error() .with_message("Repeat delta did not move forwards") - .with_labels(vec![Label::primary(*index, span).with_message("This delta")]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![format!("Moved from {from} to {to}")]), Error::RemindDidNotMoveBackwards { index, @@ -140,25 +136,21 @@ impl<'a, F: Files<'a>> Eprint<'a, F> for Error { to, } => Diagnostic::error() .with_message("Remind delta did not move backwards") - .with_labels(vec![Label::primary(*index, span).with_message("This delta")]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![format!("Moved from {from} to {to}")]), Error::MoveWithoutSource { index, span } => Diagnostic::error() .with_message("Tried to move nonexistent entry") - .with_labels(vec![Label::primary(*index, span).with_message("Here")]), + .with_labels(vec![Label::primary(*index, span)]), Error::TimedMoveWithoutTime { index, span } => Diagnostic::error() .with_message("Tried to move un-timed entry to new time") - .with_labels(vec![Label::primary(*index, span).with_message("Here")]), + .with_labels(vec![Label::primary(*index, span)]), Error::DivByZero { index, span, date } => Diagnostic::error() .with_message("Tried to divide by zero") - .with_labels(vec![ - Label::primary(*index, span).with_message("This expression") - ]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![format!("At date: {date}")]), Error::ModByZero { index, span, date } => Diagnostic::error() .with_message("Tried to modulo by zero") - .with_labels(vec![ - Label::primary(*index, span).with_message("This expression") - ]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![format!("At date: {date}")]), Error::Easter { index, @@ -167,9 +159,7 @@ impl<'a, F: Files<'a>> Eprint<'a, F> for Error { msg, } => Diagnostic::error() .with_message("Failed to calculate easter") - .with_labels(vec![ - Label::primary(*index, span).with_message("This expression") - ]) + .with_labels(vec![Label::primary(*index, span)]) .with_notes(vec![format!("At date: {date}"), format!("Reason: {msg}")]), }; Self::eprint_diagnostic(files, config, &diagnostic); diff --git a/src/files/error.rs b/src/files/error.rs index aabd582..f0ad33e 100644 --- a/src/files/error.rs +++ b/src/files/error.rs @@ -154,9 +154,7 @@ impl<'a> Eprint<'a, Files> for Error { } => { let diagnostic = Diagnostic::error() .with_message(format!("Could not resolve time zone {tz}")) - .with_labels(vec![ - Label::primary(*file, span).with_message("Time zone defined here") - ]) + .with_labels(vec![Label::primary(*file, span)]) .with_notes(vec![format!("{error}")]); Self::eprint_diagnostic(files, config, &diagnostic); } @@ -178,8 +176,8 @@ impl<'a> Eprint<'a, Files> for Error { let diagnostic = Diagnostic::error() .with_message(format!("Time zone conflict between {tz1} and {tz2}")) .with_labels(vec![ - Label::primary(*file1, span1).with_message("Time zone defined here"), - Label::primary(*file2, span2).with_message("Time zone defined here"), + Label::primary(*file1, span1), + Label::primary(*file2, span2), ]) .with_notes(vec![ "All TIMEZONE commands must set the same time zone.".to_string() @@ -213,8 +211,8 @@ impl<'a> Eprint<'a, Files> for Error { let diagnostic = Diagnostic::error() .with_message(format!("Duplicate log entries for {date}")) .with_labels(vec![ - Label::primary(*file1, span1).with_message("Log defined here"), - Label::primary(*file2, span2).with_message("Log defined here"), + Label::primary(*file1, span1), + Label::primary(*file2, span2), ]) .with_notes(vec!["A day can have at most one LOG entry.".to_string()]); Self::eprint_diagnostic(files, config, &diagnostic);