Don't drain-on-drop in DrainFilter impls of various collections. by the8472 · Pull Request #104455 · rust-lang/rust (original) (raw)

Hi @the8472,

I was upgrading Rust version in our project and I found that upgrade from 1.71.0 to 1.72.0 causes differences in our determinism checks. In short, we have a complicated heuristic algorithm with a lot of inputs and we have a way to check if it gives exactly the same results (if we do not expect changes).

In 1.72.0 Changelog I could not see anything that would affect our code, but for some reason our determinism checks failed.
I've used cargo-bisect-rustc to find the commit that started the issue and it pointed me to this PR.

I've analysed our code and I found where the behaviour has changed.
We have a DeterministicHashMap defined as follows:

pub type DeterministicHashMap<K, V> = std::collections::HashMap<K, V, BuildHasherDefault<FxHasher64>>;

In Rust 1.72.0 this DeterministicHashMap is sorted differently then in 1.71.0, I've checked the hashes generated by FxHasher64 and they remained identical, but something, probably this PR, caused different ordering inside the std::collections::HashMap.

It is not really much of a problem for us, as I now know understand the difference, I can just upgrade Rust version in our project.
However, I would like to understand why did this PR cause the change in the ordering?