Add OnceHelp lint level (same as OnceNote, except for help)
This commit is contained in:
parent
bf1e3f31f9
commit
eba5b44729
3 changed files with 14 additions and 4 deletions
|
@ -91,7 +91,7 @@ fn annotation_type_for_level(level: Level) -> AnnotationType {
|
||||||
}
|
}
|
||||||
Level::Warning(_) => AnnotationType::Warning,
|
Level::Warning(_) => AnnotationType::Warning,
|
||||||
Level::Note | Level::OnceNote => AnnotationType::Note,
|
Level::Note | Level::OnceNote => AnnotationType::Note,
|
||||||
Level::Help => AnnotationType::Help,
|
Level::Help | Level::OnceHelp => AnnotationType::Help,
|
||||||
// FIXME(#59346): Not sure how to map this level
|
// FIXME(#59346): Not sure how to map this level
|
||||||
Level::FailureNote => AnnotationType::Error,
|
Level::FailureNote => AnnotationType::Error,
|
||||||
Level::Allow => panic!("Should not call with Allow"),
|
Level::Allow => panic!("Should not call with Allow"),
|
||||||
|
|
|
@ -270,6 +270,7 @@ impl Diagnostic {
|
||||||
| Level::Note
|
| Level::Note
|
||||||
| Level::OnceNote
|
| Level::OnceNote
|
||||||
| Level::Help
|
| Level::Help
|
||||||
|
| Level::OnceHelp
|
||||||
| Level::Allow
|
| Level::Allow
|
||||||
| Level::Expect(_) => false,
|
| Level::Expect(_) => false,
|
||||||
}
|
}
|
||||||
|
@ -532,6 +533,13 @@ impl Diagnostic {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Prints the span with a help above it.
|
||||||
|
/// This is like [`Diagnostic::help()`], but it gets its own span.
|
||||||
|
pub fn help_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self {
|
||||||
|
self.sub(Level::OnceHelp, msg, MultiSpan::new(), None);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Add a help message attached to this diagnostic with a customizable highlighted message.
|
/// Add a help message attached to this diagnostic with a customizable highlighted message.
|
||||||
pub fn highlighted_help(&mut self, msg: Vec<(String, Style)>) -> &mut Self {
|
pub fn highlighted_help(&mut self, msg: Vec<(String, Style)>) -> &mut Self {
|
||||||
self.sub_with_highlights(Level::Help, msg, MultiSpan::new(), None);
|
self.sub_with_highlights(Level::Help, msg, MultiSpan::new(), None);
|
||||||
|
|
|
@ -1390,7 +1390,7 @@ impl HandlerInner {
|
||||||
debug!(?self.emitted_diagnostics);
|
debug!(?self.emitted_diagnostics);
|
||||||
let already_emitted_sub = |sub: &mut SubDiagnostic| {
|
let already_emitted_sub = |sub: &mut SubDiagnostic| {
|
||||||
debug!(?sub);
|
debug!(?sub);
|
||||||
if sub.level != Level::OnceNote {
|
if sub.level != Level::OnceNote && sub.level != Level::OnceHelp {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let mut hasher = StableHasher::new();
|
let mut hasher = StableHasher::new();
|
||||||
|
@ -1792,6 +1792,8 @@ pub enum Level {
|
||||||
/// A note that is only emitted once.
|
/// A note that is only emitted once.
|
||||||
OnceNote,
|
OnceNote,
|
||||||
Help,
|
Help,
|
||||||
|
/// A help that is only emitted once.
|
||||||
|
OnceHelp,
|
||||||
FailureNote,
|
FailureNote,
|
||||||
Allow,
|
Allow,
|
||||||
Expect(LintExpectationId),
|
Expect(LintExpectationId),
|
||||||
|
@ -1816,7 +1818,7 @@ impl Level {
|
||||||
Note | OnceNote => {
|
Note | OnceNote => {
|
||||||
spec.set_fg(Some(Color::Green)).set_intense(true);
|
spec.set_fg(Some(Color::Green)).set_intense(true);
|
||||||
}
|
}
|
||||||
Help => {
|
Help | OnceHelp => {
|
||||||
spec.set_fg(Some(Color::Cyan)).set_intense(true);
|
spec.set_fg(Some(Color::Cyan)).set_intense(true);
|
||||||
}
|
}
|
||||||
FailureNote => {}
|
FailureNote => {}
|
||||||
|
@ -1831,7 +1833,7 @@ impl Level {
|
||||||
Fatal | Error { .. } => "error",
|
Fatal | Error { .. } => "error",
|
||||||
Warning(_) => "warning",
|
Warning(_) => "warning",
|
||||||
Note | OnceNote => "note",
|
Note | OnceNote => "note",
|
||||||
Help => "help",
|
Help | OnceHelp => "help",
|
||||||
FailureNote => "failure-note",
|
FailureNote => "failure-note",
|
||||||
Allow => panic!("Shouldn't call on allowed error"),
|
Allow => panic!("Shouldn't call on allowed error"),
|
||||||
Expect(_) => panic!("Shouldn't call on expected error"),
|
Expect(_) => panic!("Shouldn't call on expected error"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue