Force warnings even when can_emit_warnings == false
This commit is contained in:
@@ -145,8 +145,9 @@ impl AnnotateSnippetEmitterWriter {
|
||||
title: Some(Annotation {
|
||||
label: Some(&message),
|
||||
id: code.as_ref().map(|c| match c {
|
||||
DiagnosticId::Error(val)
|
||||
| DiagnosticId::Lint { name: val, has_future_breakage: _ } => val.as_str(),
|
||||
DiagnosticId::Error(val) | DiagnosticId::Lint { name: val, .. } => {
|
||||
val.as_str()
|
||||
}
|
||||
}),
|
||||
annotation_type: annotation_type_for_level(*level),
|
||||
}),
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct Diagnostic {
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
|
||||
pub enum DiagnosticId {
|
||||
Error(String),
|
||||
Lint { name: String, has_future_breakage: bool },
|
||||
Lint { name: String, has_future_breakage: bool, is_force_warn: bool },
|
||||
}
|
||||
|
||||
/// A "sub"-diagnostic attached to a parent diagnostic.
|
||||
@@ -109,6 +109,13 @@ impl Diagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_force_warn(&self) -> bool {
|
||||
match self.code {
|
||||
Some(DiagnosticId::Lint { is_force_warn, .. }) => is_force_warn,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Cancel the diagnostic (a structured diagnostic must either be emitted or
|
||||
/// canceled or it will panic when dropped).
|
||||
pub fn cancel(&mut self) {
|
||||
|
||||
@@ -559,7 +559,7 @@ impl DiagnosticCode {
|
||||
s.map(|s| {
|
||||
let s = match s {
|
||||
DiagnosticId::Error(s) => s,
|
||||
DiagnosticId::Lint { name, has_future_breakage: _ } => name,
|
||||
DiagnosticId::Lint { name, .. } => name,
|
||||
};
|
||||
let je_result =
|
||||
je.registry.as_ref().map(|registry| registry.try_find_description(&s)).unwrap();
|
||||
|
||||
@@ -802,7 +802,10 @@ impl HandlerInner {
|
||||
self.future_breakage_diagnostics.push(diagnostic.clone());
|
||||
}
|
||||
|
||||
if diagnostic.level == Warning && !self.flags.can_emit_warnings {
|
||||
if diagnostic.level == Warning
|
||||
&& !self.flags.can_emit_warnings
|
||||
&& !diagnostic.is_force_warn()
|
||||
{
|
||||
if diagnostic.has_future_breakage() {
|
||||
(*TRACK_DIAGNOSTICS)(diagnostic);
|
||||
}
|
||||
@@ -874,7 +877,7 @@ impl HandlerInner {
|
||||
|
||||
match (errors.len(), warnings.len()) {
|
||||
(0, 0) => return,
|
||||
(0, _) => self.emit_diagnostic(&Diagnostic::new(Level::Warning, &warnings)),
|
||||
(0, _) => self.emitter.emit_diagnostic(&Diagnostic::new(Level::Warning, &warnings)),
|
||||
(_, 0) => {
|
||||
let _ = self.fatal(&errors);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user