Update compiler/rustc_middle/src/hir/map/mod.rs

Co-authored-by: Michael Goulet <michael@errs.io>
This commit is contained in:
Mara Bos 2024-09-23 09:36:17 +00:00 committed by GitHub
parent 7a19b17084
commit c0c569f99d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -598,7 +598,8 @@ impl<'hir> Map<'hir> {
/// in the HIR which is recorded by the map and is an item, either an item /// in the HIR which is recorded by the map and is an item, either an item
/// in a module, trait, or impl. /// in a module, trait, or impl.
pub fn get_parent_item(self, hir_id: HirId) -> OwnerId { pub fn get_parent_item(self, hir_id: HirId) -> OwnerId {
if hir_id.local_id.index() != 0 { if hir_id.local_id != ItemLocalId::ZERO {
// If this is a child of a HIR owner, return the owner.
hir_id.owner hir_id.owner
} else if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() { } else if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
def_id def_id