Auto merge of #86180 - cjgillot:defmv, r=petrochenkov
Hash DefId in rustc_span. This is mostly just moving code around. Changes are simplifications of unneeded callbacks from rustc_span to rustc_middle. r? `@petrochenkov`
This commit is contained in:
commit
0f6ba39fd8
6 changed files with 56 additions and 71 deletions
|
@ -14,7 +14,6 @@ use rustc_span::source_map::SourceMap;
|
|||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{BytePos, CachingSourceMapView, SourceFile, SpanData};
|
||||
|
||||
use rustc_span::def_id::{CrateNum, CRATE_DEF_INDEX};
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp::Ord;
|
||||
use std::thread::LocalKey;
|
||||
|
@ -227,15 +226,8 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn hash_crate_num(&mut self, cnum: CrateNum, hasher: &mut StableHasher) {
|
||||
let hcx = self;
|
||||
hcx.def_path_hash(DefId { krate: cnum, index: CRATE_DEF_INDEX }).hash_stable(hcx, hasher);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn hash_def_id(&mut self, def_id: DefId, hasher: &mut StableHasher) {
|
||||
let hcx = self;
|
||||
hcx.def_path_hash(def_id).hash_stable(hcx, hasher);
|
||||
fn def_path_hash(&self, def_id: DefId) -> DefPathHash {
|
||||
self.def_path_hash(def_id)
|
||||
}
|
||||
|
||||
fn expn_id_cache() -> &'static LocalKey<rustc_span::ExpnIdCache> {
|
||||
|
|
|
@ -6,7 +6,6 @@ use rustc_attr as attr;
|
|||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use smallvec::SmallVec;
|
||||
use std::mem;
|
||||
|
@ -113,46 +112,6 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
|
|||
|
||||
self.node_id_hashing_mode = prev_hash_node_ids;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn local_def_path_hash(&self, def_id: LocalDefId) -> DefPathHash {
|
||||
self.local_def_path_hash(def_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for DefId {
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
|
||||
hcx.def_path_hash(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for LocalDefId {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
hcx.def_path_hash(self.to_def_id()).hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for LocalDefId {
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
|
||||
hcx.def_path_hash(self.to_def_id())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for CrateNum {
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
|
||||
let def_id = DefId { krate: *self, index: CRATE_DEF_INDEX };
|
||||
def_id.to_stable_hash_key(hcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::ItemLocalId {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue