Don't call diag_span_note_once
for suppressed lints
This commit is contained in:
parent
846df20578
commit
0b86782058
1 changed files with 24 additions and 20 deletions
|
@ -666,6 +666,30 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
|
|||
(Level::Forbid, None) => sess.struct_err(msg),
|
||||
};
|
||||
|
||||
// Check for future incompatibility lints and issue a stronger warning.
|
||||
let lints = sess.lint_store.borrow();
|
||||
let lint_id = LintId::of(lint);
|
||||
let future_incompatible = lints.future_incompatible(lint_id);
|
||||
|
||||
// If this code originates in a foreign macro, aka something that this crate
|
||||
// did not itself author, then it's likely that there's nothing this crate
|
||||
// can do about it. We probably want to skip the lint entirely.
|
||||
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
|
||||
// Any suggestions made here are likely to be incorrect, so anything we
|
||||
// emit shouldn't be automatically fixed by rustfix.
|
||||
err.allow_suggestions(false);
|
||||
|
||||
// If this is a future incompatible lint it'll become a hard error, so
|
||||
// we have to emit *something*. Also allow lints to whitelist themselves
|
||||
// on a case-by-case basis for emission in a foreign macro.
|
||||
if future_incompatible.is_none() && !lint.report_in_external_macro {
|
||||
err.cancel();
|
||||
// Don't continue further, since we don't want to have
|
||||
// `diag_span_note_once` called for a diagnostic that isn't emitted.
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
let name = lint.name_lower();
|
||||
match src {
|
||||
LintSource::Default => {
|
||||
|
@ -715,10 +739,6 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
|
|||
|
||||
err.code(DiagnosticId::Lint(name));
|
||||
|
||||
// Check for future incompatibility lints and issue a stronger warning.
|
||||
let lints = sess.lint_store.borrow();
|
||||
let lint_id = LintId::of(lint);
|
||||
let future_incompatible = lints.future_incompatible(lint_id);
|
||||
if let Some(future_incompatible) = future_incompatible {
|
||||
const STANDARD_MESSAGE: &str =
|
||||
"this was previously accepted by the compiler but is being phased out; \
|
||||
|
@ -743,22 +763,6 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
|
|||
err.note(&citation);
|
||||
}
|
||||
|
||||
// If this code originates in a foreign macro, aka something that this crate
|
||||
// did not itself author, then it's likely that there's nothing this crate
|
||||
// can do about it. We probably want to skip the lint entirely.
|
||||
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
|
||||
// Any suggestions made here are likely to be incorrect, so anything we
|
||||
// emit shouldn't be automatically fixed by rustfix.
|
||||
err.allow_suggestions(false);
|
||||
|
||||
// If this is a future incompatible lint it'll become a hard error, so
|
||||
// we have to emit *something*. Also allow lints to whitelist themselves
|
||||
// on a case-by-case basis for emission in a foreign macro.
|
||||
if future_incompatible.is_none() && !lint.report_in_external_macro {
|
||||
err.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue