diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-14 06:04:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-14 06:04:30 +0200 |
| commit | d34b9324c0557abbcd52257fdc544e8a8ff77d4d (patch) | |
| tree | 30c1c26d8b1cc5f70f8bead17ee8328e68ca5393 /compiler | |
| parent | 5d63a3db9c7c3a2543fbeb3fe8f30d0173acdcf8 (diff) | |
| parent | b5e91a00c89a065f618693873ad7074a13ad6b90 (diff) | |
| download | rust-d34b9324c0557abbcd52257fdc544e8a8ff77d4d.tar.gz rust-d34b9324c0557abbcd52257fdc544e8a8ff77d4d.zip | |
Rollup merge of #131660 - Urgau:non_local_def-131643, r=jieyouxu
Also use outermost const-anon for impl items in `non_local_defs` lint This PR update the logic for the impl paths (items) in the `non_local_definitions` lint to also consider const-anon in case the impl definition is wrapped inside const-anon it-self wrapped into a const-anon where the items are. r? `@jieyouxu` *(since you interacted on the issue)* Fixes *(after beta-backport)* #131643
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/non_local_def.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 6fecddb3319..3c31b879bd6 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -301,9 +301,13 @@ fn did_has_local_parent( return false; }; - peel_parent_while(tcx, parent_did, |tcx, did| tcx.def_kind(did) == DefKind::Mod) - .map(|parent_did| parent_did == impl_parent || Some(parent_did) == outermost_impl_parent) - .unwrap_or(false) + peel_parent_while(tcx, parent_did, |tcx, did| { + tcx.def_kind(did) == DefKind::Mod + || (tcx.def_kind(did) == DefKind::Const + && tcx.opt_item_name(did) == Some(kw::Underscore)) + }) + .map(|parent_did| parent_did == impl_parent || Some(parent_did) == outermost_impl_parent) + .unwrap_or(false) } /// Given a `DefId` checks if it satisfies `f` if it does check with it's parent and continue |
