Skip to content

Commit 7a19b17

Browse files
committed
Skip query in get_parent_item when possible.
1 parent 2b11f26 commit 7a19b17

File tree

1 file changed

+3
-1
lines changed
  • compiler/rustc_middle/src/hir/map

1 file changed

+3
-1
lines changed

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,9 @@ impl<'hir> Map<'hir> {
598598
/// in the HIR which is recorded by the map and is an item, either an item
599599
/// in a module, trait, or impl.
600600
pub fn get_parent_item(self, hir_id: HirId) -> OwnerId {
601-
if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
601+
if hir_id.local_id.index() != 0 {
602+
hir_id.owner
603+
} else if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
602604
def_id
603605
} else {
604606
CRATE_OWNER_ID

0 commit comments

Comments
 (0)