Filter OnceNote in diagnostic infra.

This commit is contained in:
Camille GILLOT
2022-03-20 20:02:18 +01:00
parent 056951d628
commit 0b49d05ea3
29 changed files with 183 additions and 282 deletions

View File

@@ -135,7 +135,12 @@ impl Diagnostic {
| Level::Error { .. }
| Level::FailureNote => true,
Level::Warning | Level::Note | Level::Help | Level::Allow | Level::Expect(_) => false,
Level::Warning
| Level::Note
| Level::OnceNote
| Level::Help
| Level::Allow
| Level::Expect(_) => false,
}
}
@@ -333,6 +338,13 @@ impl Diagnostic {
self
}
/// Prints the span with a note above it.
/// This is like [`Diagnostic::note()`], but it gets its own span.
pub fn note_once(&mut self, msg: &str) -> &mut Self {
self.sub(Level::OnceNote, msg, MultiSpan::new(), None);
self
}
/// Prints the span with a note above it.
/// This is like [`Diagnostic::note()`], but it gets its own span.
pub fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
@@ -340,6 +352,13 @@ impl Diagnostic {
self
}
/// Prints the span with a note above it.
/// This is like [`Diagnostic::note()`], but it gets its own span.
pub fn span_note_once<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self {
self.sub(Level::OnceNote, msg, sp.into(), None);
self
}
/// Add a warning attached to this diagnostic.
pub fn warn(&mut self, msg: &str) -> &mut Self {
self.sub(Level::Warning, msg, MultiSpan::new(), None);