Proposal
Stable hashing involves various types, traits, modules, etc., and these are named inconsistently. The most important inconsistency is that some things use StableHash and some use HashStable and it's difficult to remember which is which. There are also some other minor inconsistencies.
This situation is best exemplified by the trait named HashStableContext which is impl'd by a single type named StableHashingContext. Yuk.
The following shows the planned renamings.
UNCHANGED
rustc-stable-hash (crate)
StableHasher (renaming of `StableSipHasher128` from `rustc-stable-hash`)
StableHasherHash(?) (renaming of `SipHasher128Hash` from `rustc-stable-hash`)
ToStableHashKey (trait)
to_stable_hash_key (trait method)
stable_hash (newtype_index attribute)
CHANGED
HashStable -> StableHash (trait)
hash_stable -> stable_hash (trait method)
HashStable -> StableHash (derive)
HashStable_NoContext -> StableHash_NoContext (derive)
HashStableContext -> StableHashCtxt (trait/trait bound)
span_hash_stable -> stable_hash_span (trait method)
StableHashingContext -> StableHashState (struct)
stable_hasher -> stable_hash (mod in rustc_data_structures)
hash_stable -> stable_hash (mod in rustc_macros)
HashingControls -> StableHashControls (struct)
AbiHashStable -> StableAbiHash (trait)
abi_hash -> stable_abi_hash (trait method)
Rationale
- Want a consistent order, and
StableHash is better than HashStable.
- "stable hash" is the English noun phrase.
- "stable hash" could serve as an English verb phrase at a stretch (e.g. "I will stable-hash this value"), though "I will compute the stable hash of this value" is more reasonable.
- In contrast, "hash stable" doesn't really make sense in English as a noun phrase or verb phrase.
rustc-stable-hash is a published crate and is the hardest name to change.
- We have a trait called
StableOrd (not OrdStable).
- Want consistent forms, e.g. replace the rarely used
Hashing with Hash.
StableHashCtxt: this trait is used a lot so it uses Ctxt instead of Context, because it's good for highly-used names to be short.
- There are many existing
Hcx/hcx names in use with this trait, so preserving the use of Ctxt/Context is good.
StableHashState: this struct avoids Context/Ctxt to prevent confusion with the trait.
Mentors or Reviewers
I can do the work. Reviewing will be tedious but easy.
Process
The main points of the Major Change Process are as follows:
You can read more about Major Change Proposals on forge.
Proposal
Stable hashing involves various types, traits, modules, etc., and these are named inconsistently. The most important inconsistency is that some things use
StableHashand some useHashStableand it's difficult to remember which is which. There are also some other minor inconsistencies.This situation is best exemplified by the trait named
HashStableContextwhich is impl'd by a single type namedStableHashingContext. Yuk.The following shows the planned renamings.
Rationale
StableHashis better thanHashStable.rustc-stable-hashis a published crate and is the hardest name to change.StableOrd(notOrdStable).HashingwithHash.StableHashCtxt: this trait is used a lot so it usesCtxtinstead ofContext, because it's good for highly-used names to be short.Hcx/hcxnames in use with this trait, so preserving the use ofCtxt/Contextis good.StableHashState: this struct avoidsContext/Ctxtto prevent confusion with the trait.HashStablerust#155018 merges.Mentors or Reviewers
I can do the work. Reviewing will be tedious but easy.
Process
The main points of the Major Change Process are as follows:
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.You can read more about Major Change Proposals on forge.