Skip to content

Commit 6e33d3e

Browse files
committed
Use modular arithmetic
1 parent a5f5f6b commit 6e33d3e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/rustc_data_structures/src/stable_hasher.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl_stable_hash_via_hash!(::std::path::PathBuf);
503503

504504
impl<K, V, R, HCX> HashStable<HCX> for ::std::collections::HashMap<K, V, R>
505505
where
506-
K: ToStableHashKey<HCX> + Eq,
506+
K: HashStable<HCX> + ToStableHashKey<HCX> + Eq,
507507
V: HashStable<HCX>,
508508
R: BuildHasher,
509509
{
@@ -555,7 +555,7 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
555555
map: &::std::collections::HashMap<K, V, R>,
556556
to_stable_hash_key: F,
557557
) where
558-
K: Eq,
558+
K: Eq + HashStable<HCX>,
559559
V: HashStable<HCX>,
560560
R: BuildHasher,
561561
SK: HashStable<HCX> + Ord,
@@ -570,7 +570,7 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
570570
value.hash_stable(hcx, &mut hasher);
571571
hasher.finish::<u128>()
572572
})
573-
.reduce(|accum, value| accum.wrapping_mul(value));
573+
.reduce(|accum, value| accum.wrapping_add(value));
574574
map.len().hash_stable(hcx, hasher);
575575
hash.hash_stable(hcx, hasher);
576576
}

0 commit comments

Comments
 (0)