diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
commit | 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch) | |
tree | 3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/tools/clippy/src/docs/implicit_hasher.txt | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip |
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/src/docs/implicit_hasher.txt')
-rw-r--r-- | src/tools/clippy/src/docs/implicit_hasher.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/implicit_hasher.txt b/src/tools/clippy/src/docs/implicit_hasher.txt new file mode 100644 index 000000000..0c1f76620 --- /dev/null +++ b/src/tools/clippy/src/docs/implicit_hasher.txt @@ -0,0 +1,26 @@ +### What it does +Checks for public `impl` or `fn` missing generalization +over different hashers and implicitly defaulting to the default hashing +algorithm (`SipHash`). + +### Why is this bad? +`HashMap` or `HashSet` with custom hashers cannot be +used with them. + +### Known problems +Suggestions for replacing constructors can contain +false-positives. Also applying suggestions can require modification of other +pieces of code, possibly including external crates. + +### Example +``` +impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { } + +pub fn foo(map: &mut HashMap<i32, i32>) { } +``` +could be rewritten as +``` +impl<K: Hash + Eq, V, S: BuildHasher> Serialize for HashMap<K, V, S> { } + +pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { } +```
\ No newline at end of file |