Don't pass lint back out of lint decorator
This commit is contained in:
parent
4d1bd0db7f
commit
7f565ed282
38 changed files with 50 additions and 116 deletions
|
@ -2800,7 +2800,7 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels {
|
|||
NAMED_ASM_LABELS,
|
||||
Some(target_spans),
|
||||
fluent::lint_builtin_asm_labels,
|
||||
|lint| lint,
|
||||
|_| {},
|
||||
BuiltinLintDiagnostics::NamedAsmLabel(
|
||||
"only local labels of the form `<number>:` should be used in inline asm"
|
||||
.to_string(),
|
||||
|
|
|
@ -530,9 +530,7 @@ pub trait LintContext {
|
|||
lint: &'static Lint,
|
||||
span: Option<impl Into<MultiSpan>>,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
diagnostic: BuiltinLintDiagnostics,
|
||||
) {
|
||||
// We first generate a blank diagnostic.
|
||||
|
@ -995,9 +993,7 @@ pub trait LintContext {
|
|||
lint: &'static Lint,
|
||||
span: Option<S>,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
);
|
||||
|
||||
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
|
||||
|
@ -1008,7 +1004,9 @@ pub trait LintContext {
|
|||
span: S,
|
||||
decorator: impl for<'a> DecorateLint<'a, ()>,
|
||||
) {
|
||||
self.lookup(lint, Some(span), decorator.msg(), |diag| decorator.decorate_lint(diag));
|
||||
self.lookup(lint, Some(span), decorator.msg(), |diag| {
|
||||
decorator.decorate_lint(diag);
|
||||
});
|
||||
}
|
||||
|
||||
/// Emit a lint at the appropriate level, with an associated span.
|
||||
|
@ -1022,9 +1020,7 @@ pub trait LintContext {
|
|||
lint: &'static Lint,
|
||||
span: S,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
) {
|
||||
self.lookup(lint, Some(span), msg, decorate);
|
||||
}
|
||||
|
@ -1033,7 +1029,7 @@ pub trait LintContext {
|
|||
/// generated by `#[derive(LintDiagnostic)]`).
|
||||
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) {
|
||||
self.lookup(lint, None as Option<Span>, decorator.msg(), |diag| {
|
||||
decorator.decorate_lint(diag)
|
||||
decorator.decorate_lint(diag);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1047,9 +1043,7 @@ pub trait LintContext {
|
|||
&self,
|
||||
lint: &'static Lint,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
) {
|
||||
self.lookup(lint, None as Option<Span>, msg, decorate);
|
||||
}
|
||||
|
@ -1113,9 +1107,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
|
|||
lint: &'static Lint,
|
||||
span: Option<S>,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
) {
|
||||
let hir_id = self.last_node_with_lint_attrs;
|
||||
|
||||
|
@ -1142,9 +1134,7 @@ impl LintContext for EarlyContext<'_> {
|
|||
lint: &'static Lint,
|
||||
span: Option<S>,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
) {
|
||||
self.builder.struct_lint(lint, span.map(|s| s.into()), msg, decorate)
|
||||
}
|
||||
|
|
|
@ -45,13 +45,7 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
|
|||
fn inlined_check_id(&mut self, id: ast::NodeId) {
|
||||
for early_lint in self.context.buffered.take(id) {
|
||||
let BufferedEarlyLint { span, msg, node_id: _, lint_id, diagnostic } = early_lint;
|
||||
self.context.lookup_with_diagnostics(
|
||||
lint_id.lint,
|
||||
Some(span),
|
||||
msg,
|
||||
|lint| lint,
|
||||
diagnostic,
|
||||
);
|
||||
self.context.lookup_with_diagnostics(lint_id.lint, Some(span), msg, |_| {}, diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1077,7 +1077,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||
GateIssue::Language,
|
||||
lint_from_cli,
|
||||
);
|
||||
lint
|
||||
},
|
||||
);
|
||||
return false;
|
||||
|
@ -1104,9 +1103,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||
lint: &'static Lint,
|
||||
span: Option<MultiSpan>,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
decorate: impl for<'a, 'b> FnOnce(
|
||||
&'b mut DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut DiagnosticBuilder<'a, ()>,
|
||||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
|
||||
) {
|
||||
let (level, src) = self.lint_level(lint);
|
||||
struct_lint_level(self.sess, lint, level, src, span, msg, decorate)
|
||||
|
@ -1121,7 +1118,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||
) {
|
||||
let (level, src) = self.lint_level(lint);
|
||||
struct_lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| {
|
||||
decorate.decorate_lint(lint)
|
||||
decorate.decorate_lint(lint);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1129,7 +1126,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) {
|
||||
let (level, src) = self.lint_level(lint);
|
||||
struct_lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
|
||||
decorate.decorate_lint(lint)
|
||||
decorate.decorate_lint(lint);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
|||
lint.note(fluent::lint_more_info_note);
|
||||
if !is_arg_inside_call(arg_span, span) {
|
||||
// No clue where this argument is coming from.
|
||||
return lint;
|
||||
return;
|
||||
}
|
||||
if arg_macro.is_some_and(|id| cx.tcx.is_diagnostic_item(sym::format_macro, id)) {
|
||||
// A case of `panic!(format!(..))`.
|
||||
|
@ -207,7 +207,6 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
|||
}
|
||||
}
|
||||
}
|
||||
lint
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue