Filter OnceNote in diagnostic infra.
This commit is contained in:
parent
056951d628
commit
0b49d05ea3
29 changed files with 183 additions and 282 deletions
|
@ -12,7 +12,7 @@ use rustc_session::lint::{
|
|||
builtin::{self, FORBIDDEN_LINT_GROUPS},
|
||||
FutureIncompatibilityReason, Level, Lint, LintExpectationId, LintId,
|
||||
};
|
||||
use rustc_session::{DiagnosticMessageId, Session};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan};
|
||||
use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
|
||||
|
@ -245,7 +245,6 @@ impl<'a> LintDiagnosticBuilder<'a, ErrorGuaranteed> {
|
|||
}
|
||||
|
||||
pub fn explain_lint_level_source(
|
||||
sess: &Session,
|
||||
lint: &'static Lint,
|
||||
level: Level,
|
||||
src: LintLevelSource,
|
||||
|
@ -254,11 +253,7 @@ pub fn explain_lint_level_source(
|
|||
let name = lint.name_lower();
|
||||
match src {
|
||||
LintLevelSource::Default => {
|
||||
sess.diag_note_once(
|
||||
err,
|
||||
DiagnosticMessageId::from(lint),
|
||||
&format!("`#[{}({})]` on by default", level.as_str(), name),
|
||||
);
|
||||
err.note_once(&format!("`#[{}({})]` on by default", level.as_str(), name));
|
||||
}
|
||||
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
|
||||
let flag = match orig_level {
|
||||
|
@ -273,46 +268,29 @@ pub fn explain_lint_level_source(
|
|||
};
|
||||
let hyphen_case_lint_name = name.replace('_', "-");
|
||||
if lint_flag_val.as_str() == name {
|
||||
sess.diag_note_once(
|
||||
err,
|
||||
DiagnosticMessageId::from(lint),
|
||||
&format!(
|
||||
"requested on the command line with `{} {}`",
|
||||
flag, hyphen_case_lint_name
|
||||
),
|
||||
);
|
||||
err.note_once(&format!(
|
||||
"requested on the command line with `{} {}`",
|
||||
flag, hyphen_case_lint_name
|
||||
));
|
||||
} else {
|
||||
let hyphen_case_flag_val = lint_flag_val.as_str().replace('_', "-");
|
||||
sess.diag_note_once(
|
||||
err,
|
||||
DiagnosticMessageId::from(lint),
|
||||
&format!(
|
||||
"`{} {}` implied by `{} {}`",
|
||||
flag, hyphen_case_lint_name, flag, hyphen_case_flag_val
|
||||
),
|
||||
);
|
||||
err.note_once(&format!(
|
||||
"`{} {}` implied by `{} {}`",
|
||||
flag, hyphen_case_lint_name, flag, hyphen_case_flag_val
|
||||
));
|
||||
}
|
||||
}
|
||||
LintLevelSource::Node(lint_attr_name, src, reason) => {
|
||||
if let Some(rationale) = reason {
|
||||
err.note(rationale.as_str());
|
||||
}
|
||||
sess.diag_span_note_once(
|
||||
err,
|
||||
DiagnosticMessageId::from(lint),
|
||||
src,
|
||||
"the lint level is defined here",
|
||||
);
|
||||
err.span_note_once(src, "the lint level is defined here");
|
||||
if lint_attr_name.as_str() != name {
|
||||
let level_str = level.as_str();
|
||||
sess.diag_note_once(
|
||||
err,
|
||||
DiagnosticMessageId::from(lint),
|
||||
&format!(
|
||||
"`#[{}({})]` implied by `#[{}({})]`",
|
||||
level_str, name, level_str, lint_attr_name
|
||||
),
|
||||
);
|
||||
err.note_once(&format!(
|
||||
"`#[{}({})]` implied by `#[{}({})]`",
|
||||
level_str, name, level_str, lint_attr_name
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +390,7 @@ pub fn struct_lint_level<'s, 'd>(
|
|||
return;
|
||||
}
|
||||
|
||||
explain_lint_level_source(sess, lint, level, src, &mut err);
|
||||
explain_lint_level_source(lint, level, src, &mut err);
|
||||
|
||||
let name = lint.name_lower();
|
||||
let is_force_warn = matches!(level, Level::ForceWarn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue