Also use outermost const-anon for impl items in non_local_defs lint · rust-lang/rust@b5e91a0 (original) (raw)

File tree

3 files changed

lines changed

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -301,9 +301,13 @@ fn did_has_local_parent(
301 301 return false;
302 302 };
303 303
304 -peel_parent_while(tcx, parent_did, |tcx, did tcx.def_kind(did) == DefKind::Mod)
305 -.map(|parent_did parent_did == impl_parent
306 -.unwrap_or(false)
304 +peel_parent_while(tcx, parent_did, |tcx, did {
305 + tcx.def_kind(did) == DefKind::Mod
306 + | (tcx.def_kind(did) == DefKind::Const
307 + && tcx.opt_item_name(did) == Some(kw::Underscore))
308 +})
309 +.map(|parent_did parent_did == impl_parent
310 +.unwrap_or(false)
307 311 }
308 312
309 313 /// Given a `DefId` checks if it satisfies `f` if it does check with it's parent and continue
Original file line number Diff line number Diff line change
@@ -31,4 +31,15 @@ const _: () = {
31 31 };
32 32 };
33 33
34 +// https://github.com/rust-lang/rust/issues/131643
35 +const _: () = {
36 +const _: () = {
37 +impl tmp::InnerTest {}
38 +};
39 +
40 +mod tmp {
41 +pub(super) struct InnerTest;
42 +}
43 +};
44 +
34 45 fn main() {}
Original file line number Diff line number Diff line change
@@ -21,4 +21,13 @@ const _: () = {
21 21 };
22 22 };
23 23
24 +// https://github.com/rust-lang/rust/issues/131643
25 +const _: () = {
26 +const _: () = {
27 +impl InnerTest {}
28 +};
29 +
30 +struct InnerTest;
31 +};
32 +
24 33 fn main() {}