1
Fork 0

Don't pass lint back out of lint decorator

This commit is contained in:
Michael Goulet 2023-12-08 01:52:56 +00:00
parent 4d1bd0db7f
commit 7f565ed282
38 changed files with 50 additions and 116 deletions

View file

@ -578,7 +578,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
hir_id, hir_id,
no_sanitize_span, no_sanitize_span,
"`no_sanitize` will have no effect after inlining", "`no_sanitize` will have no effect after inlining",
|lint| lint.span_note(inline_span, "inlining requested here"), |lint| {
lint.span_note(inline_span, "inlining requested here");
},
) )
} }
} }

View file

@ -661,7 +661,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
args.args[0].hir_id(), args.args[0].hir_id(),
multispan, multispan,
msg, msg,
|lint| lint, |_| {},
); );
} }

View file

@ -122,7 +122,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
self.maybe_lint_blanket_trait_impl(self_ty, lint); self.maybe_lint_blanket_trait_impl(self_ty, lint);
lint
}, },
); );
} }

View file

@ -1506,8 +1506,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident), format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
lint
}, },
); );
} }

View file

@ -51,7 +51,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
hir_id, hir_id,
span, span,
"use of calling convention not supported on this target", "use of calling convention not supported on this target",
|lint| lint, |_| {},
); );
} }
} }
@ -190,7 +190,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
"static of uninhabited type", "static of uninhabited type",
|lint| { |lint| {
lint lint
.note("uninhabited statics cannot be initialized, and any access would be an immediate error") .note("uninhabited statics cannot be initialized, and any access would be an immediate error");
}, },
); );
} }
@ -1093,7 +1093,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
"this {descr} contains `{field_ty}`, which {note}, \ "this {descr} contains `{field_ty}`, which {note}, \
and makes it not a breaking change to become \ and makes it not a breaking change to become \
non-zero-sized in the future." non-zero-sized in the future."
)) ));
}, },
) )
} else { } else {

View file

@ -574,7 +574,6 @@ fn emit_implied_wf_lint<'tcx>(
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }
lint
}, },
); );
} }

View file

@ -269,7 +269,6 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
lint.help(format!( lint.help(format!(
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}`", "or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}`",
)); ));
lint
}, },
); );
} }

View file

@ -45,7 +45,7 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) {
item.hir_id(), item.hir_id(),
path.span, path.span,
msg, msg,
|lint| lint, |_| {},
); );
} }
} }

View file

@ -522,7 +522,7 @@ fn lint_auto_trait_impl<'tcx>(
format!( format!(
"try using the same sequence of generic parameters as the {self_descr} definition", "try using the same sequence of generic parameters as the {self_descr} definition",
), ),
) );
}, },
); );
} }

View file

@ -279,7 +279,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
param.hir_id, param.hir_id,
param.span, param.span,
TYPE_DEFAULT_NOT_ALLOWED, TYPE_DEFAULT_NOT_ALLOWED,
|lint| lint, |_| {},
); );
} }
Defaults::Deny => { Defaults::Deny => {

View file

@ -925,7 +925,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
"you can use the `'static` lifetime directly, in place of `{}`", "you can use the `'static` lifetime directly, in place of `{}`",
lifetime.ident, lifetime.ident,
); );
lint.help(help) lint.help(help);
}, },
); );
} }

View file

@ -72,7 +72,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
orig_span, orig_span,
custom_note custom_note
.unwrap_or("any code following this expression is unreachable"), .unwrap_or("any code following this expression is unreachable"),
) );
}, },
) )
} }

View file

@ -122,8 +122,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
format!("disambiguate the method call with `({self_adjusted})`",), format!("disambiguate the method call with `({self_adjusted})`",),
); );
} }
lint
}, },
); );
} else { } else {
@ -187,8 +185,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
), ),
); );
} }
lint
}, },
); );
} }
@ -307,8 +303,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
format!("<{} as {}>::{}", self_ty_name, trait_name, method_name.name,), format!("<{} as {}>::{}", self_ty_name, trait_name, method_name.name,),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
lint
}, },
); );
} }

View file

@ -445,7 +445,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
scope_expr_id, scope_expr_id,
span, span,
"type annotations needed", "type annotations needed",
|lint| lint, |_| {},
); );
} }
} else { } else {
@ -1427,8 +1427,6 @@ impl<'tcx> Pick<'tcx> {
)); ));
} }
} }
lint
}, },
); );
} }

View file

@ -1845,8 +1845,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
lint.note(format!( lint.note(format!(
"the pattern is of type `{ty}` and the `non_exhaustive_omitted_patterns` attribute was found", "the pattern is of type `{ty}` and the `non_exhaustive_omitted_patterns` attribute was found",
)); ));
lint
}); });
} }

View file

@ -912,8 +912,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::HasPlaceholders Applicability::HasPlaceholders
); );
} }
lint
}, },
); );
} }

View file

@ -2800,7 +2800,7 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels {
NAMED_ASM_LABELS, NAMED_ASM_LABELS,
Some(target_spans), Some(target_spans),
fluent::lint_builtin_asm_labels, fluent::lint_builtin_asm_labels,
|lint| lint, |_| {},
BuiltinLintDiagnostics::NamedAsmLabel( BuiltinLintDiagnostics::NamedAsmLabel(
"only local labels of the form `<number>:` should be used in inline asm" "only local labels of the form `<number>:` should be used in inline asm"
.to_string(), .to_string(),

View file

@ -530,9 +530,7 @@ pub trait LintContext {
lint: &'static Lint, lint: &'static Lint,
span: Option<impl Into<MultiSpan>>, span: Option<impl Into<MultiSpan>>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
diagnostic: BuiltinLintDiagnostics, diagnostic: BuiltinLintDiagnostics,
) { ) {
// We first generate a blank diagnostic. // We first generate a blank diagnostic.
@ -995,9 +993,7 @@ pub trait LintContext {
lint: &'static Lint, lint: &'static Lint,
span: Option<S>, span: Option<S>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
); );
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
@ -1008,7 +1004,9 @@ pub trait LintContext {
span: S, span: S,
decorator: impl for<'a> DecorateLint<'a, ()>, 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. /// Emit a lint at the appropriate level, with an associated span.
@ -1022,9 +1020,7 @@ pub trait LintContext {
lint: &'static Lint, lint: &'static Lint,
span: S, span: S,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
self.lookup(lint, Some(span), msg, decorate); self.lookup(lint, Some(span), msg, decorate);
} }
@ -1033,7 +1029,7 @@ pub trait LintContext {
/// generated by `#[derive(LintDiagnostic)]`). /// generated by `#[derive(LintDiagnostic)]`).
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) { fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) {
self.lookup(lint, None as Option<Span>, decorator.msg(), |diag| { 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, &self,
lint: &'static Lint, lint: &'static Lint,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
self.lookup(lint, None as Option<Span>, msg, decorate); self.lookup(lint, None as Option<Span>, msg, decorate);
} }
@ -1113,9 +1107,7 @@ impl<'tcx> LintContext for LateContext<'tcx> {
lint: &'static Lint, lint: &'static Lint,
span: Option<S>, span: Option<S>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
let hir_id = self.last_node_with_lint_attrs; let hir_id = self.last_node_with_lint_attrs;
@ -1142,9 +1134,7 @@ impl LintContext for EarlyContext<'_> {
lint: &'static Lint, lint: &'static Lint,
span: Option<S>, span: Option<S>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
self.builder.struct_lint(lint, span.map(|s| s.into()), msg, decorate) self.builder.struct_lint(lint, span.map(|s| s.into()), msg, decorate)
} }

View file

@ -45,13 +45,7 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
fn inlined_check_id(&mut self, id: ast::NodeId) { fn inlined_check_id(&mut self, id: ast::NodeId) {
for early_lint in self.context.buffered.take(id) { for early_lint in self.context.buffered.take(id) {
let BufferedEarlyLint { span, msg, node_id: _, lint_id, diagnostic } = early_lint; let BufferedEarlyLint { span, msg, node_id: _, lint_id, diagnostic } = early_lint;
self.context.lookup_with_diagnostics( self.context.lookup_with_diagnostics(lint_id.lint, Some(span), msg, |_| {}, diagnostic);
lint_id.lint,
Some(span),
msg,
|lint| lint,
diagnostic,
);
} }
} }

View file

@ -1077,7 +1077,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
GateIssue::Language, GateIssue::Language,
lint_from_cli, lint_from_cli,
); );
lint
}, },
); );
return false; return false;
@ -1104,9 +1103,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
lint: &'static Lint, lint: &'static Lint,
span: Option<MultiSpan>, span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
let (level, src) = self.lint_level(lint); let (level, src) = self.lint_level(lint);
struct_lint_level(self.sess, lint, level, src, span, msg, decorate) 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); let (level, src) = self.lint_level(lint);
struct_lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |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, ()>) { pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) {
let (level, src) = self.lint_level(lint); let (level, src) = self.lint_level(lint);
struct_lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| { struct_lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
decorate.decorate_lint(lint) decorate.decorate_lint(lint);
}); });
} }
} }

View file

@ -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); lint.note(fluent::lint_more_info_note);
if !is_arg_inside_call(arg_span, span) { if !is_arg_inside_call(arg_span, span) {
// No clue where this argument is coming from. // 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)) { if arg_macro.is_some_and(|id| cx.tcx.is_diagnostic_item(sym::format_macro, id)) {
// A case of `panic!(format!(..))`. // A case of `panic!(format!(..))`.
@ -207,7 +207,6 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
} }
} }
} }
lint
}); });
} }

View file

@ -284,9 +284,7 @@ pub fn struct_lint_level(
src: LintLevelSource, src: LintLevelSource,
span: Option<MultiSpan>, span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to // Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
// the "real" work. // the "real" work.
@ -298,12 +296,7 @@ pub fn struct_lint_level(
src: LintLevelSource, src: LintLevelSource,
span: Option<MultiSpan>, span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: Box< decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)>,
dyn '_
+ for<'a, 'b> FnOnce(
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
>,
) { ) {
// Check for future incompatibility lints and issue a stronger warning. // Check for future incompatibility lints and issue a stronger warning.
let future_incompatible = lint.future_incompatible; let future_incompatible = lint.future_incompatible;

View file

@ -223,7 +223,6 @@ fn late_report_deprecation(
let kind = tcx.def_descr(def_id); let kind = tcx.def_descr(def_id);
deprecation_suggestion(diag, kind, suggestion, method_span); deprecation_suggestion(diag, kind, suggestion, method_span);
} }
diag
}); });
} }
@ -587,7 +586,7 @@ impl<'tcx> TyCtxt<'tcx> {
unmarked: impl FnOnce(Span, DefId), unmarked: impl FnOnce(Span, DefId),
) -> bool { ) -> bool {
let soft_handler = |lint, span, msg: String| { let soft_handler = |lint, span, msg: String| {
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |lint| lint) self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, msg, |_| {})
}; };
let eval_result = let eval_result =
self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable); self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable);

View file

@ -113,7 +113,7 @@ impl<'tcx> TyCtxt<'tcx> {
self.local_def_id_to_hir_id(local_def_id), self.local_def_id_to_hir_id(local_def_id),
self.def_span(ct.def), self.def_span(ct.def),
"cannot use constants which depend on generic parameters in types", "cannot use constants which depend on generic parameters in types",
|err| err, |_| {},
) )
} }
} }

View file

@ -2030,7 +2030,7 @@ impl<'tcx> TyCtxt<'tcx> {
let msg = decorator.msg(); let msg = decorator.msg();
let (level, src) = self.lint_level_at_node(lint, hir_id); let (level, src) = self.lint_level_at_node(lint, hir_id);
struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| { struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| {
decorator.decorate_lint(diag) decorator.decorate_lint(diag);
}) })
} }
@ -2047,9 +2047,7 @@ impl<'tcx> TyCtxt<'tcx> {
hir_id: HirId, hir_id: HirId,
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
let (level, src) = self.lint_level_at_node(lint, hir_id); let (level, src) = self.lint_level_at_node(lint, hir_id);
struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate); struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
@ -2064,7 +2062,9 @@ impl<'tcx> TyCtxt<'tcx> {
id: HirId, id: HirId,
decorator: impl for<'a> DecorateLint<'a, ()>, decorator: impl for<'a> DecorateLint<'a, ()>,
) { ) {
self.struct_lint_node(lint, id, decorator.msg(), |diag| decorator.decorate_lint(diag)) self.struct_lint_node(lint, id, decorator.msg(), |diag| {
decorator.decorate_lint(diag);
})
} }
/// Emit a lint at the appropriate level for a hir node. /// Emit a lint at the appropriate level for a hir node.
@ -2079,9 +2079,7 @@ impl<'tcx> TyCtxt<'tcx> {
lint: &'static Lint, lint: &'static Lint,
id: HirId, id: HirId,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce( decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
let (level, src) = self.lint_level_at_node(lint, id); let (level, src) = self.lint_level_at_node(lint, id);
struct_lint_level(self.sess, lint, level, src, None, msg, decorate); struct_lint_level(self.sess, lint, level, src, None, msg, decorate);

View file

@ -273,7 +273,6 @@ fn overlap<'tcx>(
causing the impls to overlap", causing the impls to overlap",
infcx.resolve_vars_if_possible(failing_obligation.predicate) infcx.resolve_vars_if_possible(failing_obligation.predicate)
)); ));
lint
}, },
); );
} }

View file

@ -194,7 +194,6 @@ fn lint_object_unsafe_trait(
// Only provide the help if its a local trait, otherwise it's not // Only provide the help if its a local trait, otherwise it's not
violation.solution().add_to(err); violation.solution().add_to(err);
} }
err
}, },
); );
} }

View file

@ -450,7 +450,6 @@ fn report_conflicting_impls<'tcx>(
msg, msg,
|err| { |err| {
decorate(tcx, &overlap, impl_span, err); decorate(tcx, &overlap, impl_span, err);
err
}, },
); );
} }

View file

@ -380,7 +380,9 @@ pub(crate) fn run_global_ctxt(
crate::lint::MISSING_CRATE_LEVEL_DOCS, crate::lint::MISSING_CRATE_LEVEL_DOCS,
DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(), DocContext::as_local_hir_id(tcx, krate.module.item_id).unwrap(),
"no documentation found for this crate's top-level module", "no documentation found for this crate's top-level module",
|lint| lint.help(help), |lint| {
lint.help(help);
},
); );
} }

View file

@ -835,7 +835,7 @@ impl<'tcx> ExtraInfo<'tcx> {
self.tcx.local_def_id_to_hir_id(def_id), self.tcx.local_def_id_to_hir_id(def_id),
self.sp, self.sp,
msg, msg,
|l| l, |_| {},
); );
} }
} }
@ -843,9 +843,7 @@ impl<'tcx> ExtraInfo<'tcx> {
fn error_invalid_codeblock_attr_with_help( fn error_invalid_codeblock_attr_with_help(
&self, &self,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
f: impl for<'a, 'b> FnOnce( f: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) { ) {
if let Some(def_id) = self.def_id.as_local() { if let Some(def_id) = self.def_id.as_local() {
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
@ -1296,7 +1294,7 @@ impl LangString {
lint.help(format!( lint.help(format!(
"there is an attribute with a similar name: `edition{}`", "there is an attribute with a similar name: `edition{}`",
&x[4..], &x[4..],
)) ));
}, },
); );
} }
@ -1350,7 +1348,7 @@ impl LangString {
lint.help(format!( lint.help(format!(
"there is an attribute with a similar name: `{flag}`" "there is an attribute with a similar name: `{flag}`"
)) ))
.help(help) .help(help);
}, },
); );
} }

View file

@ -131,7 +131,7 @@ pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item
hir_id, hir_id,
sp, sp,
"missing code example in this documentation", "missing code example in this documentation",
|lint| lint, |_| {},
); );
} }
} else if tests.found_tests > 0 } else if tests.found_tests > 0
@ -142,7 +142,7 @@ pub(crate) fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item
hir_id, hir_id,
item.attr_span(cx.tcx), item.attr_span(cx.tcx),
"documentation test in private item", "documentation test in private item",
|lint| lint, |_| {},
); );
} }
} }

View file

@ -1755,8 +1755,6 @@ fn report_diagnostic(
} }
decorate(lint, span, link_range); decorate(lint, span, link_range);
lint
}); });
} }

View file

@ -31,7 +31,7 @@ pub(super) fn visit_item(cx: &DocContext<'_>, item: &Item) {
"use an automatic link instead", "use an automatic link instead",
format!("<{url}>"), format!("<{url}>"),
Applicability::MachineApplicable, Applicability::MachineApplicable,
) );
}); });
}; };

View file

@ -131,8 +131,6 @@ fn check_rust_syntax(
for message in buffer.messages.iter() { for message in buffer.messages.iter() {
lint.note(message.clone()); lint.note(message.clone());
} }
lint
}); });
} }

View file

@ -89,7 +89,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
if (generics_start > 0 && dox.as_bytes()[generics_start - 1] == b'<') if (generics_start > 0 && dox.as_bytes()[generics_start - 1] == b'<')
|| (generics_end < dox.len() && dox.as_bytes()[generics_end] == b'>') || (generics_end < dox.len() && dox.as_bytes()[generics_end] == b'>')
{ {
return lint; return;
} }
// multipart form is chosen here because ``Vec<i32>`` would be confusing. // multipart form is chosen here because ``Vec<i32>`` would be confusing.
lint.multipart_suggestion( lint.multipart_suggestion(
@ -101,8 +101,6 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }
lint
}); });
}; };

View file

@ -181,8 +181,6 @@ fn check_inline_or_reference_unknown_redundancy(
.span_label(display_span, "because label contains path that resolves to same destination") .span_label(display_span, "because label contains path that resolves to same destination")
.note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links") .note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links")
.span_suggestion_with_style(link_span, "remove explicit link target", format!("[{}]", link_data.display_link), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways); .span_suggestion_with_style(link_span, "remove explicit link target", format!("[{}]", link_data.display_link), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways);
lint
}); });
} }
@ -234,8 +232,6 @@ fn check_reference_redundancy(
.span_note(def_span, "referenced explicit link target defined here") .span_note(def_span, "referenced explicit link target defined here")
.note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links") .note("when a link's destination is not specified,\nthe label is used to resolve intra-doc links")
.span_suggestion_with_style(link_span, "remove explicit link target", format!("[{}]", link_data.display_link), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways); .span_suggestion_with_style(link_span, "remove explicit link target", format!("[{}]", link_data.display_link), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways);
lint
}); });
} }

View file

@ -111,8 +111,6 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
} }
suggest_insertion(cx, item, &dox, lint, backtick_index, '\\', "if you meant to use a literal backtick, escape it"); suggest_insertion(cx, item, &dox, lint, backtick_index, '\\', "if you meant to use a literal backtick, escape it");
lint
}); });
} }
Event::Code(_) => { Event::Code(_) => {

View file

@ -49,7 +49,6 @@ pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<Mult
#[expect(clippy::disallowed_methods)] #[expect(clippy::disallowed_methods)]
cx.struct_span_lint(lint, sp, msg.to_string(), |diag| { cx.struct_span_lint(lint, sp, msg.to_string(), |diag| {
docs_link(diag, lint); docs_link(diag, lint);
diag
}); });
} }
@ -90,7 +89,6 @@ pub fn span_lint_and_help<T: LintContext>(
diag.help(help.to_string()); diag.help(help.to_string());
} }
docs_link(diag, lint); docs_link(diag, lint);
diag
}); });
} }
@ -134,7 +132,6 @@ pub fn span_lint_and_note<T: LintContext>(
diag.note(note); diag.note(note);
} }
docs_link(diag, lint); docs_link(diag, lint);
diag
}); });
} }
@ -152,7 +149,6 @@ where
cx.struct_span_lint(lint, sp, msg.to_string(), |diag| { cx.struct_span_lint(lint, sp, msg.to_string(), |diag| {
f(diag); f(diag);
docs_link(diag, lint); docs_link(diag, lint);
diag
}); });
} }
@ -160,7 +156,6 @@ pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, s
#[expect(clippy::disallowed_methods)] #[expect(clippy::disallowed_methods)]
cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| { cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| {
docs_link(diag, lint); docs_link(diag, lint);
diag
}); });
} }
@ -176,7 +171,6 @@ pub fn span_lint_hir_and_then(
cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| { cx.tcx.struct_span_lint_hir(lint, hir_id, sp, msg.to_string(), |diag| {
f(diag); f(diag);
docs_link(diag, lint); docs_link(diag, lint);
diag
}); });
} }