Skip to content

Commit b79f026

Browse files
Do not implement HashStable for HashSet.
1 parent 04e5fa3 commit b79f026

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

compiler/rustc_data_structures/src/stable_hasher.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,10 @@ where
617617
}
618618
}
619619

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

633625
impl<K, V, HCX> HashStable<HCX> for ::std::collections::BTreeMap<K, V>
634626
where

0 commit comments

Comments
 (0)