Description
When working on #64906, I ran into a latent dependency on the iteration order of a HashMap
. This resulted in the PR becoming unmergeable - since a FxHashMap
was being used, the iteration order ended up differing between platforms, which made it impossible to make the tests pass on all platforms.
It would be nice to have a way of exposing these kinds of hidden ordering dependencies before they result in blocked PRs.
I propose the following:
- Add a new feature called
randomize_iteration
tostd
andfxhash
. When enabled, this feature will cause the iteration order ofiter
anditer_mut
to be randomized per call. - Add a
config.toml
key to enable both of these features.
This will allow producing a special build of the compiler that will (hopefully) expose many hidden ordering dependencies. The overhead could be very high, but that shouldn't matter too much - the only purpose of this build would be to run the testsuite.
Once std-aware Cargo is fully implement, we could consider making this usable by user-written crates (e.g. allowing people to opt-in to recompiling std in this mode).