lint: fix condition in diagnostic lints
Unfortunately, the diagnostic lints are very broken and trigger much more often than they should. Correct the conditional which checks if the function call being made is to a diagnostic function so that it returns in every intended case. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
7702ae16a2
commit
871c879bff
1 changed files with 6 additions and 3 deletions
|
@ -406,9 +406,12 @@ impl LateLintPass<'_> for Diagnostics {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||||
let Some((span, def_id, substs)) = typeck_results_of_method_fn(cx, expr) else { return };
|
let Some((span, def_id, substs)) = typeck_results_of_method_fn(cx, expr) else { return };
|
||||||
debug!(?span, ?def_id, ?substs);
|
debug!(?span, ?def_id, ?substs);
|
||||||
if let Ok(Some(instance)) = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, substs) &&
|
let has_attr = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, substs)
|
||||||
!cx.tcx.has_attr(instance.def_id(), sym::rustc_lint_diagnostics)
|
.ok()
|
||||||
{
|
.and_then(|inst| inst)
|
||||||
|
.map(|inst| cx.tcx.has_attr(inst.def_id(), sym::rustc_lint_diagnostics))
|
||||||
|
.unwrap_or(false);
|
||||||
|
if !has_attr {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue