Add an unstable 'extra randomization' compile-time flag for hashers (original) (raw)

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:

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).