diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2023-02-21 15:29:12 +0100 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2023-03-01 10:20:45 +0100 |
| commit | b79f0261f87ff38de6fee6a6f6ce9915a8f0e6b4 (patch) | |
| tree | f37182a7ee2ab1ab3470620c61fc50acfb340243 /compiler/rustc_data_structures/src | |
| parent | 04e5fa3ce2a6a2b74c2940364b13bc106d8cadb6 (diff) | |
| download | rust-b79f0261f87ff38de6fee6a6f6ce9915a8f0e6b4.tar.gz rust-b79f0261f87ff38de6fee6a6f6ce9915a8f0e6b4.zip | |
Do not implement HashStable for HashSet.
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/stable_hasher.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index e0d77cdaebb..de9842156d6 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -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 |
