Skip to content

Warn about implicit hasher for HashMap #2101

@clarfonthey

Description

@clarfonthey

A lot of libraries, particularly ones that interop with serde, should probably generalise impls over different BuildHashers for HashMap, but end up missing them and defaulting to the hasher. IMHO there should be a lint for blanket impls for HashMap which exclude the hasher, because in most cases you don't specifically depend on SipHasher.

Obviously, structs which simply include HashMap<K, V> inside of them can probably be left as-is.

For example, code like:

impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { ... }

could be suggested to become

impl<K: Hash + Eq, V, S: BuildHasher> Serialize for HashMap<K, V, S> { ... }

We should probably check for specific uses of methods which require the default state, but otherwise lint on less-generic impls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions