RS.CLIPPY.DERIVED_HASH_WITH_MANUAL_EQ
Deriving `Hash` but implementing `PartialEq` explicitly
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: derived_hash_with_manual_eq. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Lints against manual PartialEq implementations for types with a derived Hash
implementation.
Why is this bad?
The implementation of these traits must agree (for
example for use with HashMap) so it's probably a bad idea to use a
default-generated Hash implementation with an explicitly defined
PartialEq. In particular, the following must hold for any type:
k1 == k2 ⇒ hash(k1) == hash(k2)
Example
#[derive(Hash)]
struct Foo;
impl PartialEq for Foo {
...
}
Past names
- derive_hash_xor_eq