Skip to content

Commit 474d277

Browse files
committed
Add a Clippy exception for derive_hash_xor_eq
This is a string interning library. It does some weird things related to hashing. This is fine.
1 parent 8313ec7 commit 474d277

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@
103103
104104
#![cfg_attr(test, deny(warnings))]
105105

106+
// Types, such as Atom, that impl Hash must follow the hash invariant: if two objects match
107+
// with PartialEq, they must also have the same Hash. Clippy warns on types that derive one while
108+
// manually impl-ing the other, because it seems easy for the two to drift apart, causing the
109+
// invariant to be violated.
110+
//
111+
// But Atom is a newtype over NonZeroU64, and probably always will be, since cheap comparisons and
112+
// copying are this library's purpose. So we know what the PartialEq comparison is going to do.
113+
//
114+
// The `get_hash` function, seen in `atom.rs`, consults that number, plus the global string interner
115+
// tables. The only way for the resulting hash for two Atoms with the same inner 64-bit number to
116+
// differ would be if the table entry changed between invocations, and that would be really bad.
117+
#![allow(clippy::derive_hash_xor_eq)]
118+
106119
mod atom;
107120
mod dynamic_set;
108121
mod static_sets;

0 commit comments

Comments
 (0)