@@ -284,8 +284,8 @@ fn path_has_local_parent(
284
284
. is_some_and ( |did| did_has_local_parent ( did, cx. tcx , impl_parent, outermost_impl_parent) )
285
285
}
286
286
287
- /// Given a def id this checks if the parent def id (modulo modules) correspond to
288
- /// the def id of the parent impl definition (the direct one and the outermost one).
287
+ /// Given a def if we check if the parent def id (modulo modules and const-anons ) correspond
288
+ /// to the def id of the parent impl definition (the direct parent or the outermost one).
289
289
#[ inline]
290
290
fn did_has_local_parent (
291
291
did : DefId ,
@@ -301,13 +301,21 @@ fn did_has_local_parent(
301
301
return false ;
302
302
} ;
303
303
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 || Some ( parent_did) == outermost_impl_parent)
310
- . unwrap_or ( false )
304
+ // Peel modules
305
+ peel_parent_while ( tcx, parent_did, |tcx, did| tcx. def_kind ( did) == DefKind :: Mod )
306
+ // Peel const-anons
307
+ . map ( |parent_did| {
308
+ peel_parent_while ( tcx, parent_did, |tcx, did| {
309
+ tcx. def_kind ( did) == DefKind :: Const
310
+ && tcx. opt_item_name ( did) == Some ( kw:: Underscore )
311
+ } )
312
+ } )
313
+ . flatten ( )
314
+ // Check if parent def if is either equal to:
315
+ // - the `impl` parent
316
+ // - or the outermost `impl` parent
317
+ . map ( |parent_did| parent_did == impl_parent || Some ( parent_did) == outermost_impl_parent)
318
+ . unwrap_or ( false )
311
319
}
312
320
313
321
/// Given a `DefId` checks if it satisfies `f` if it does check with it's parent and continue
0 commit comments