}
fn find_entry(&self, id: HirId) -> Option<Entry<'hir>> {
- if id.local_id == ItemLocalId::from_u32(0) {
- let owner = self.tcx.hir_owner(id.owner);
+ if id.local_id == ItemLocalId::from_u32_const(0) {
+ let owner = self.tcx.hir_owner(id.owner_def_id());
owner.map(|owner| Entry { parent: owner.parent, node: owner.node })
} else {
- let owner = self.tcx.hir_owner_nodes(id.owner);
+ let owner = self.tcx.hir_owner_items(id.owner_def_id());
owner.and_then(|owner| {
- let node = owner.nodes[id.local_id].as_ref();
- // FIXME(eddyb) use a single generic type insted of having both
- // `Entry` and `ParentedNode`, which are effectively the same.
- // Alternatively, rewrite code using `Entry` to use `ParentedNode`.
- node.map(|node| Entry {
- parent: HirId { owner: id.owner, local_id: node.parent },
- node: node.node,
+ let item = owner.items[id.local_id].as_ref();
+ item.map(|item| Entry {
+ parent: HirId { owner: id.owner, local_id: item.parent },
+ node: item.node,
})
})
}
}
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
- self.tcx.hir_owner_nodes(id.hir_id.owner).unwrap().bodies.get(&id.hir_id.local_id).unwrap()
+ self.tcx
+ .hir_owner_items(DefId::local(id.hir_id.owner))
+ .unwrap()
+ .bodies
+ .get(&id.hir_id.local_id)
+ .unwrap()
}
pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
let module = hir.as_local_hir_id(id);
&tcx.untracked_crate.modules[&module]
};
- providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature;
- providers.hir_owner_nodes =
- |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|nodes| &**nodes);
+ providers.hir_owner = |tcx, id| tcx.index_hir(id.krate).map[id.index].signature;
+ providers.hir_owner_items =
+ |tcx, id| tcx.index_hir(id.krate).map[id.index].with_bodies.as_ref().map(|items| &**items);
map::provide(providers);
}
//
// This can be conveniently accessed by methods on `tcx.hir()`.
// Avoid calling this query directly.
- query hir_owner(key: LocalDefId) -> Option<&'tcx crate::hir::Owner<'tcx>> {
+ query hir_owner(key: DefId) -> Option<&'tcx HirOwner<'tcx>> {
eval_always
desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
}
//
// This can be conveniently accessed by methods on `tcx.hir()`.
// Avoid calling this query directly.
- query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx crate::hir::OwnerNodes<'tcx>> {
+ query hir_owner_items(key: DefId) -> Option<&'tcx HirOwnerItems<'tcx>> {
eval_always
desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
}