mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Skip query in get_parent_item when possible.
This commit is contained in:
parent
2b11f265b6
commit
7a19b17084
@ -598,7 +598,9 @@ impl<'hir> Map<'hir> {
|
||||
/// in the HIR which is recorded by the map and is an item, either an item
|
||||
/// in a module, trait, or impl.
|
||||
pub fn get_parent_item(self, hir_id: HirId) -> OwnerId {
|
||||
if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
|
||||
if hir_id.local_id.index() != 0 {
|
||||
hir_id.owner
|
||||
} else if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
|
||||
def_id
|
||||
} else {
|
||||
CRATE_OWNER_ID
|
||||
|
Loading…
Reference in New Issue
Block a user