rust-lang / rust-lang/rust

`Hash` portability between compiler versions is potentially misleading

Open
#144,540 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs C-discussion T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Location

https://doc.rust-lang.org/std/hash/trait.Hash.html#portability

Summary

Whether Hash and Hasher is portable between compiler versions is ambiguously documented, and potentially misleading.

Serialization formats intended to be portable between platforms or compiler versions should either avoid encoding hashes or only rely on Hash and Hasher implementations that provide additional guarantees.

Changes to the default behaviour of Hasher are frequently[1] discussed[2] without considering portability between rust versions. I am not aware of any breaking changes on stable rust yet, but implying that Hasher output can be stable between compiler versions seems misleading.

A rust-users discussion over whether rapidhash can offer a Hasher-compatible persistent hasher has generated conflicting opinions.

I think it would be restrictive to future work on the Hash trait to claim that Hash and Hasher are portable between compiler versions, and suggest that non-portability between compiler versions is made explicit in both the Hash and Hasher documentation.

Very happy to be convinced otherwise, as it would let me build a persistent RapidHasher if portability is indeed guaranteed. Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Hash portability section at the linked standard-library documentation, then read the linked issue, pull request, and forum discussion to establish the intended compiler-version guarantee. Done means the Hash and Hasher documentation state the agreed portability limitations without ambiguity.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.