Remove unnecessary label messages

This commit is contained in:
Joscha 2022-01-15 01:13:31 +01:00
parent f82b368fe1
commit 4a2f72fabf
2 changed files with 14 additions and 26 deletions

View file

@ -102,9 +102,7 @@ impl<'a, F: Files<'a>> Eprint<'a, F> for Error<F::FileId> {
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<F::FileId> {
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<F::FileId> {
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<F::FileId> {
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<F::FileId> {
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);

View file

@ -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);