Hash DefId in rustc_span.
This commit is contained in:
parent
1f949e94e8
commit
a7a50b0c0a
6 changed files with 55 additions and 71 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::crate_disambiguator::CrateDisambiguator;
|
||||
use crate::HashStableContext;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||
use rustc_data_structures::AtomicRef;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
@ -309,12 +309,47 @@ rustc_data_structures::define_id_collections!(LocalDefIdMap, LocalDefIdSet, Loca
|
|||
|
||||
impl<CTX: HashStableContext> HashStable<CTX> for DefId {
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
hcx.hash_def_id(*self, hasher)
|
||||
hcx.def_path_hash(*self).hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX: HashStableContext> HashStable<CTX> for LocalDefId {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
hcx.def_path_hash(self.to_def_id()).hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX: HashStableContext> HashStable<CTX> for CrateNum {
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
hcx.hash_crate_num(*self, hasher)
|
||||
hcx.def_path_hash(DefId { krate: *self, index: CRATE_DEF_INDEX }).hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX: HashStableContext> ToStableHashKey<CTX> for DefId {
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
|
||||
hcx.def_path_hash(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX: HashStableContext> ToStableHashKey<CTX> for LocalDefId {
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
|
||||
hcx.def_path_hash(self.to_def_id())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX: HashStableContext> ToStableHashKey<CTX> for CrateNum {
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash {
|
||||
let def_id = DefId { krate: *self, index: CRATE_DEF_INDEX };
|
||||
def_id.to_stable_hash_key(hcx)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue