Skip to content

Commit 6802082

Browse files
committed
Hash all of the import_ids for the TraitCandidate.
1 parent fc34d5f commit 6802082

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/librustc/ich/impls_hir.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::hir::def_id::{DefId, LocalDefId, CrateNum, CRATE_DEF_INDEX};
77
use crate::ich::{StableHashingContext, NodeIdHashingMode, Fingerprint};
88
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
99
StableHasher, StableHasherResult};
10+
use smallvec::SmallVec;
1011
use std::mem;
1112
use syntax::ast;
1213
use syntax::attr;
@@ -397,14 +398,13 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
397398
} = self;
398399

399400
def_id.hash_stable(hcx, hasher);
400-
// We only use the outermost import NodeId as key
401-
import_ids.first().hash_stable(hcx, hasher);
401+
import_ids.hash_stable(hcx, hasher);
402402
});
403403
}
404404
}
405405

406406
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
407-
type KeyType = (DefPathHash, Option<(DefPathHash, hir::ItemLocalId)>);
407+
type KeyType = (DefPathHash, SmallVec<[(DefPathHash, hir::ItemLocalId); 1]>);
408408

409409
fn to_stable_hash_key(&self,
410410
hcx: &StableHashingContext<'a>)
@@ -414,10 +414,10 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
414414
import_ids,
415415
} = self;
416416

417-
let first_import_id = import_ids.first().map(|node_id| hcx.node_to_hir_id(*node_id))
417+
let import_keys = import_ids.iter().map(|node_id| hcx.node_to_hir_id(*node_id))
418418
.map(|hir_id| (hcx.local_def_path_hash(hir_id.owner),
419-
hir_id.local_id));
420-
(hcx.def_path_hash(*def_id), first_import_id)
419+
hir_id.local_id)).collect();
420+
(hcx.def_path_hash(*def_id), import_keys)
421421
}
422422
}
423423

src/librustc_data_structures/stable_hasher.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::hash::{Hash, Hasher, BuildHasher};
22
use std::marker::PhantomData;
33
use std::mem;
4+
use smallvec::SmallVec;
45
use crate::sip128::SipHasher128;
56
use crate::indexed_vec;
67
use crate::bit_set;
@@ -318,6 +319,17 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
318319
}
319320
}
320321

322+
impl<A, CTX> HashStable<CTX> for SmallVec<[A; 1]> where A: HashStable<CTX> {
323+
#[inline]
324+
fn hash_stable<W: StableHasherResult>(&self,
325+
ctx: &mut CTX,
326+
hasher: &mut StableHasher<W>) {
327+
for item in self {
328+
item.hash_stable(ctx, hasher);
329+
}
330+
}
331+
}
332+
321333
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T> {
322334
#[inline]
323335
fn hash_stable<W: StableHasherResult>(&self,

0 commit comments

Comments
 (0)