Compute full HIR hash during lowering.
This commit is contained in:
parent
41e80b85cf
commit
0431fdb113
6 changed files with 69 additions and 57 deletions
|
@ -6,8 +6,6 @@ use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
|||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use smallvec::SmallVec;
|
||||
use std::mem;
|
||||
|
||||
impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
|
||||
|
@ -121,6 +119,16 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
|
|||
|
||||
self.node_id_hashing_mode = prev_hash_node_ids;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn hash_hir_trait_candidate(&mut self, tc: &hir::TraitCandidate, hasher: &mut StableHasher) {
|
||||
self.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
||||
let hir::TraitCandidate { def_id, import_ids } = tc;
|
||||
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
import_ids.hash_stable(hcx, hasher);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::Body<'_> {
|
||||
|
@ -135,27 +143,3 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Body<'_> {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
||||
let hir::TraitCandidate { def_id, import_ids } = self;
|
||||
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
import_ids.hash_stable(hcx, hasher);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
|
||||
type KeyType = (DefPathHash, SmallVec<[DefPathHash; 1]>);
|
||||
|
||||
fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> Self::KeyType {
|
||||
let hir::TraitCandidate { def_id, import_ids } = self;
|
||||
|
||||
(
|
||||
hcx.def_path_hash(*def_id),
|
||||
import_ids.iter().map(|def_id| hcx.local_def_path_hash(*def_id)).collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue