diff options
| author | Jesper Steen Møller <jesper@selskabet.org> | 2019-05-02 15:08:03 +0200 |
|---|---|---|
| committer | Jesper Steen Møller <jesper@selskabet.org> | 2019-05-04 20:29:35 +0200 |
| commit | 6802082039285bc07736f8c9900a0410b5c1e7dc (patch) | |
| tree | 69e14b8a504df4482de1f78eb9fd99192b2c3fbc | |
| parent | fc34d5f608e3476bc7c5c4127d4e1ad1ab4fd01a (diff) | |
| download | rust-6802082039285bc07736f8c9900a0410b5c1e7dc.tar.gz rust-6802082039285bc07736f8c9900a0410b5c1e7dc.zip | |
Hash all of the import_ids for the TraitCandidate.
| -rw-r--r-- | src/librustc/ich/impls_hir.rs | 12 | ||||
| -rw-r--r-- | src/librustc_data_structures/stable_hasher.rs | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 5bd359ba1f6..5b2a1e783c0 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -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) } } diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 19343a9250d..c777f1fa829 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -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, |
