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
Derived Hash is incorrect if PartialEq is not derived #29758
Comments
Enforcing this rigorously seems unreasonable, but one could lint against this. See https://github.com/Manishearth/rust-clippy/issues/430 |
I don't know, rust-clippy mostly seems to be about warning about either ugly or noop/inefficent code, while deriving Hash without deriving PartialEq leads to actual bugs. |
I think a lint with a warning here would be appropriate. |
Since new lints have a big impact on users of rustc, the policy is that they should go through the RFC process like other user-facing changes. As such, I'm going to give this one a close, but if anyone comes across this ticket and wants this lint, consider adding it to clippy and/or writing up an RFC. Thanks! |
Would it be appropriate to just refile this issue against |
whatever, continued at rust-lang/rfcs#1499 |
This should not work:
playpen
We have this in the docs of
std::hash::Hash
:Since all
Foo
s are equal, their hashes must always be the same too, but the derived hash impl doesn't behave that way (see playpen).One way to avoid this issue is to give up on deriving
Hash
whenPartialEq
isn't automatically derived.The text was updated successfully, but these errors were encountered: