hir: Simplify hir_owner_nodes query

The query accept arbitrary DefIds, not just owner DefIds.
The return can be an `Option` because if there are no nodes, then it doesn't matter whether it's due to NonOwner or Phantom.
Also rename the query to `opt_hir_owner_nodes`.
This commit is contained in:
Vadim Petrochenkov 2024-01-25 19:16:38 +03:00
parent a51fc2a80e
commit c0f49a9995

View File

@ -93,7 +93,7 @@ impl Visitor<'_> for IdentVisitor<'_, '_> {
// reimplement it even if we wanted to
cx.tcx.opt_hir_node(hir_id)
} else {
let Some(owner) = cx.tcx.hir_owner_nodes(hir_id.owner).as_owner() else {
let Some(owner) = cx.tcx.opt_hir_owner_nodes(hir_id.owner) else {
return;
};
owner.nodes.get(hir_id.local_id).copied().flatten().map(|p| p.node)