Implement HashStable
for StableMap/StableSet
instead of HashMap/HashSet
#84446
Labels
A-incr-comp
Area: Incremental compilation
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The implementation of
HashStable
forHashSet
usesToStableHashKey
to sort the entries before hashing:rust/compiler/rustc_data_structures/src/stable_hasher.rs
Lines 537 to 552 in ccf1712
However, nothing ensures that a
HashMap
is used in an order-independent way by other code. In particular, a query could directly iterate over the entires, and produce different results for twoHashMap
s that have the sameFingerprint
.We should enforce this order independence by only implementing
HashStable
on a wrapper type that hides the underlying iteration order. We could probably useStableMap
andStableSet
, but we'll need the ability to customize the key used byinto_sorted_vector
(we'll want to sort using a stable key, not theOrd
implementation of aDefId
).The text was updated successfully, but these errors were encountered: