about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-16 22:14:32 +0000
committerbors <bors@rust-lang.org>2021-02-16 22:14:32 +0000
commit8fe989dd768f5dfdb0fc90933f3f74fa4579fefd (patch)
treeb343f190d8e1bca405fba9548778befb1986087a /compiler/rustc_span/src
parenta143517d44cac50b20cbd3a0b579addab40dd399 (diff)
parent91d8e59ccaacf7df2af847037d30871ed0bd90b6 (diff)
downloadrust-8fe989dd768f5dfdb0fc90933f3f74fa4579fefd.tar.gz
rust-8fe989dd768f5dfdb0fc90933f3f74fa4579fefd.zip
Auto merge of #81611 - cjgillot:meowner, r=estebank
Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/def_id.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index b24ede9c53a..70e9526f626 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -227,6 +227,8 @@ pub struct LocalDefId {
     pub local_def_index: DefIndex,
 }
 
+pub const CRATE_DEF_ID: LocalDefId = LocalDefId { local_def_index: CRATE_DEF_INDEX };
+
 impl Idx for LocalDefId {
     #[inline]
     fn new(idx: usize) -> Self {
@@ -268,6 +270,8 @@ impl<D: Decoder> Decodable<D> for LocalDefId {
     }
 }
 
+rustc_data_structures::define_id_collections!(LocalDefIdMap, LocalDefIdSet, LocalDefId);
+
 impl<CTX: HashStableContext> HashStable<CTX> for DefId {
     fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
         hcx.hash_def_id(*self, hasher)