pub trait HashStable<CTX> {
    // Required method
    fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher);
}
Expand description

Something that implements HashStable<CTX> can be hashed in a way that is stable across multiple compilation sessions.

Note that HashStable imposes rather more strict requirements than usual hash functions:

  • Stable hashes are sometimes used as identifiers. Therefore they must conform to the corresponding PartialEq implementations:

    • x == y implies hash_stable(x) == hash_stable(y), and
    • x != y implies hash_stable(x) != hash_stable(y).

    That second condition is usually not required for hash functions (e.g. Hash). In practice this means that hash_stable must feed any information into the hasher that a PartialEq comparison takes into account. See #49300 for an example where violating this invariant has caused trouble in the past.

  • hash_stable() must be independent of the current compilation session. E.g. they must not hash memory addresses or other things that are “randomly” assigned per compilation session.

  • hash_stable() must be independent of the host architecture. The StableHasher takes care of endianness and isize/usize platform differences.

Required Methods§

source

fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)

Implementations on Foreign Types§

source§

impl<'a, T, CTX> HashStable<CTX> for &'a T
where T: HashStable<CTX> + ?Sized,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<A, const N: usize, CTX> HashStable<CTX> for SmallVec<[A; N]>
where A: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for Ordering

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for bool

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for char

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for f32

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for f64

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for i8

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for i16

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for i32

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for i64

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for i128

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for isize

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for !

source§

fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for str

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for u8

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for u16

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for u32

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for u64

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for u128

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for ()

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for usize

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for String

source§

fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for NonZero<u32>

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for NonZero<usize>

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for Path

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for PathBuf

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX> HashStable<CTX> for [u8]

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<CTX, T> HashStable<CTX> for PhantomData<T>

source§

fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher)

source§

impl<I: Idx, CTX> HashStable<CTX> for BitSet<I>

source§

fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<I: Idx, T, CTX> HashStable<CTX> for IndexSlice<I, T>
where T: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<I: Idx, T, CTX> HashStable<CTX> for IndexVec<I, T>
where T: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<K, HCX> HashStable<HCX> for BTreeSet<K>
where K: HashStable<HCX> + StableOrd,

source§

fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)

source§

impl<K, R, CTX> HashStable<CTX> for IndexSet<K, R>
where K: HashStable<CTX> + Eq + Hash, R: BuildHasher,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<K, V, HCX> !HashStable<HCX> for HashMap<K, V>

source§

impl<K, V, HCX> HashStable<HCX> for BTreeMap<K, V>
where K: HashStable<HCX> + StableOrd, V: HashStable<HCX>,

source§

fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)

source§

impl<K, V, R, CTX> HashStable<CTX> for IndexMap<K, V, R>
where K: HashStable<CTX> + Eq + Hash, V: HashStable<CTX>, R: BuildHasher,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<R: Idx, C: Idx, CTX> HashStable<CTX> for BitMatrix<R, C>

source§

fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T1, T2, CTX> HashStable<CTX> for Result<T1, T2>
where T1: HashStable<CTX>, T2: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T1, T2, T3, CTX> HashStable<CTX> for (T1, T2, T3)
where T1: HashStable<CTX>, T2: HashStable<CTX>, T3: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T1, T2, T3, T4, CTX> HashStable<CTX> for (T1, T2, T3, T4)
where T1: HashStable<CTX>, T2: HashStable<CTX>, T3: HashStable<CTX>, T4: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T1: HashStable<CTX>, CTX> HashStable<CTX> for (T1,)

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T1: HashStable<CTX>, T2: HashStable<CTX>, CTX> HashStable<CTX> for (T1, T2)

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T, CTX> HashStable<CTX> for Option<T>
where T: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T, CTX> HashStable<CTX> for FiniteBitSet<T>
where T: HashStable<CTX> + FiniteBitSetTy,

source§

fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T, CTX> HashStable<CTX> for Discriminant<T>

source§

fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)

source§

impl<T, CTX> HashStable<CTX> for RangeInclusive<T>
where T: HashStable<CTX>,

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T: HashStable<CTX>, CTX> HashStable<CTX> for [T]

source§

default fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T>

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T>

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Rc<T>

source§

fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)

source§

impl<V, HCX> !HashStable<HCX> for HashSet<V>

Implementors§

source§

impl<CTX> HashStable<CTX> for Fingerprint

source§

impl<CTX> HashStable<CTX> for Pu128

source§

impl<CTX> HashStable<CTX> for Hash64

source§

impl<CTX> HashStable<CTX> for Hash128

source§

impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T>

source§

impl<HCX, K: Hash + Eq + HashStable<HCX>, V: HashStable<HCX>> HashStable<HCX> for UnordMap<K, V>

source§

impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordBag<V>

source§

impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordSet<V>

source§

impl<I: Idx, K, V, C> HashStable<C> for SortedIndexMultiMap<I, K, V>
where K: HashStable<C>, V: HashStable<C>,

source§

impl<K: HashStable<CTX> + StableOrd, V: HashStable<CTX>, CTX> HashStable<CTX> for SortedMap<K, V>

source§

impl<P, T, HCX, const CP: bool> HashStable<HCX> for CopyTaggedPtr<P, T, CP>
where P: Pointer + HashStable<HCX>, T: Tag + HashStable<HCX>,

source§

impl<P, T, HCX, const CP: bool> HashStable<HCX> for TaggedPtr<P, T, CP>
where P: Pointer + HashStable<HCX>, T: Tag + HashStable<HCX>,

source§

impl<T> HashStable<T> for Svh

source§

impl<T, CTX> HashStable<CTX> for Interned<'_, T>
where T: HashStable<CTX>,

source§

impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Arc<T>