mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-23 12:23:22 +00:00
Hash all of the import_ids for the TraitCandidate.
This commit is contained in:
parent
fc34d5f608
commit
6802082039
@ -7,6 +7,7 @@ use crate::hir::def_id::{DefId, LocalDefId, CrateNum, CRATE_DEF_INDEX};
|
||||
use crate::ich::{StableHashingContext, NodeIdHashingMode, Fingerprint};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
|
||||
StableHasher, StableHasherResult};
|
||||
use smallvec::SmallVec;
|
||||
use std::mem;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
@ -397,14 +398,13 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
|
||||
} = self;
|
||||
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
// We only use the outermost import NodeId as key
|
||||
import_ids.first().hash_stable(hcx, hasher);
|
||||
import_ids.hash_stable(hcx, hasher);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
|
||||
type KeyType = (DefPathHash, Option<(DefPathHash, hir::ItemLocalId)>);
|
||||
type KeyType = (DefPathHash, SmallVec<[(DefPathHash, hir::ItemLocalId); 1]>);
|
||||
|
||||
fn to_stable_hash_key(&self,
|
||||
hcx: &StableHashingContext<'a>)
|
||||
@ -414,10 +414,10 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
|
||||
import_ids,
|
||||
} = self;
|
||||
|
||||
let first_import_id = import_ids.first().map(|node_id| hcx.node_to_hir_id(*node_id))
|
||||
let import_keys = import_ids.iter().map(|node_id| hcx.node_to_hir_id(*node_id))
|
||||
.map(|hir_id| (hcx.local_def_path_hash(hir_id.owner),
|
||||
hir_id.local_id));
|
||||
(hcx.def_path_hash(*def_id), first_import_id)
|
||||
hir_id.local_id)).collect();
|
||||
(hcx.def_path_hash(*def_id), import_keys)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::hash::{Hash, Hasher, BuildHasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use smallvec::SmallVec;
|
||||
use crate::sip128::SipHasher128;
|
||||
use crate::indexed_vec;
|
||||
use crate::bit_set;
|
||||
@ -318,6 +319,17 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, CTX> HashStable<CTX> for SmallVec<[A; 1]> where A: HashStable<CTX> {
|
||||
#[inline]
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
ctx: &mut CTX,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
for item in self {
|
||||
item.hash_stable(ctx, hasher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T> {
|
||||
#[inline]
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
|
Loading…
Reference in New Issue
Block a user