-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VecDeque's Hash::hash implementation is incorrect #80303
Comments
This comment has been minimized.
This comment has been minimized.
Ugh, not another |
I also filed #80304 with code references, but I closed in favor of this issue. My conclusions:
|
So ultimately this falls into the |
@rustbot claim I will work on this |
@Stupremee I do think this needs a @rust-lang/libs decision first on the specified behavior. |
This may also be suspect if a hasher is endian-sensitive -- e.g. if it would normalize |
We discussed this in the libs meeting 2 weeks ago and came to the conclusion that |
Incidentally |
We could potentially add a new method to Hasher that does behave that way, but I don't know if it'd really be useful in many contexts outside of something like VecDeque. |
Assigning |
VecDeque's hashcode changes after rotation. In the following example, the VecDeque should be in its original ordering, yet it produces a different hashcode.
I've also opened rust-lang/hashbrown#218 but I was advised to open a new issue here.
I tried this code:
I expected to see this happen:
The hashcode should not change and the example should terminate successfully
Instead, this happened:
The hashcode is different and the application panics.
Meta
Yes, the bug exists in beta and nightly.
rustc --version --verbose
:The issue is caused by an ambiguity in the
Hash::hash_slice()
contract - it's not clear whether the hashcode should be sensitive to the slice's length. The default hasher is not sensitive, while ahash is.The text was updated successfully, but these errors were encountered: