From 301ce3610f5a40b33162e38b30e0b7ee47c805c1 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 26 Feb 2024 07:59:44 +0100 Subject: [PATCH] Limit non local defs lint logic to only impls and macros --- compiler/rustc_lint/src/non_local_def.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 6cb6fd1cbd550..9ba04ca9ea434 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -67,6 +67,10 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { return; } + if !matches!(item.kind, ItemKind::Impl(_) | ItemKind::Macro(_, _)) { + return; + } + let parent = cx.tcx.parent(item.owner_id.def_id.into()); let parent_def_kind = cx.tcx.def_kind(parent); let parent_opt_item_name = cx.tcx.opt_item_name(parent);