Fetch diagnostic item later.

This commit is contained in:
Camille GILLOT 2023-08-03 13:12:58 +00:00
parent 0edd4f9499
commit 905b63d64f

View file

@ -756,14 +756,14 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations {
_ => return,
}
let Some(debug) = cx.tcx.get_diagnostic_item(sym::Debug) else { return };
// Avoid listing trait impls if the trait is allowed.
let (level, _) = cx.tcx.lint_level_at_node(MISSING_DEBUG_IMPLEMENTATIONS, item.hir_id());
if level == Level::Allow {
return;
}
let Some(debug) = cx.tcx.get_diagnostic_item(sym::Debug) else { return };
let has_impl = cx
.tcx
.non_blanket_impls_for_ty(debug, cx.tcx.type_of(item.owner_id).instantiate_identity())