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.
This commit is contained in:
commit
8fe989dd76
117 changed files with 1127 additions and 1191 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue