summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/derive_hash_xor_eq.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/derive_hash_xor_eq.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/derive_hash_xor_eq.txt b/src/tools/clippy/src/docs/derive_hash_xor_eq.txt
new file mode 100644
index 000000000..fbf623d5a
--- /dev/null
+++ b/src/tools/clippy/src/docs/derive_hash_xor_eq.txt
@@ -0,0 +1,23 @@
+### What it does
+Checks for deriving `Hash` but implementing `PartialEq`
+explicitly or vice versa.
+
+### 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 {
+ ...
+}
+``` \ No newline at end of file