Skip to content

Commit

Permalink
Do not implement HashStable for HashSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Mar 1, 2023
1 parent 04e5fa3 commit b79f026
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions compiler/rustc_data_structures/src/stable_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,18 +617,10 @@ where
}
}

impl<K, R, HCX> HashStable<HCX> for ::std::collections::HashSet<K, R>
where
K: ToStableHashKey<HCX> + Eq,
R: BuildHasher,
{
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
stable_hash_reduce(hcx, hasher, self.iter(), self.len(), |hasher, hcx, key| {
let key = key.to_stable_hash_key(hcx);
key.hash_stable(hcx, hasher);
});
}
}
// It is not safe to implement HashStable for HashSet or any other collection type
// with unstable but observable iteration order.
// See https://github.com/rust-lang/compiler-team/issues/533 for further information.
impl<V, HCX> !HashStable<HCX> for std::collections::HashSet<V> {}

impl<K, V, HCX> HashStable<HCX> for ::std::collections::BTreeMap<K, V>
where
Expand Down

0 comments on commit b79f026

Please sign in to comment.