pub fn span_lint_and_then<C, S, M, F>(
cx: &C,
lint: &'static Lint,
sp: S,
msg: M,
f: F,
)
Expand description
Like span_lint
but allows to add notes, help and suggestions using a closure.
If you need to customize your lint output a lot, use this function.
If you change the signature, remember to update the internal lint CollapsibleCalls
NOTE: Lint emissions are always bound to a node in the HIR, which is used to determine
the lint level.
For the span_lint_and_then
function, the node that was passed into the LintPass::check_*
function is used.
If you’re emitting the lint at the span of a different node than the one provided by the
LintPass::check_*
function, consider using span_lint_hir_and_then
instead.
This is needed for #[allow]
and #[expect]
attributes to work on the node
highlighted in the displayed warning.
If you’re unsure which function you should use, you can test if the #[allow]
attribute works
where you would expect it to.
If it doesn’t, you likely need to use span_lint_hir_and_then
instead.