Skip to main content

HashStable

Trait HashStable 

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

Something that implements HashStable<Hcx> 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 Hcx, hasher: &mut StableHasher)

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for Ordering

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for bool

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for char

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for f32

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for f64

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for i8

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for i16

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for i32

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for i64

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for i128

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for isize

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for !

Source§

fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher)

Source§

impl<Hcx> HashStable<Hcx> for str

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for u8

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for u16

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for u32

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for u64

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for u128

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for ()

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for usize

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for Hash64

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for Hash128

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for String

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for NonZero<u32>

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for NonZero<usize>

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for OsStr

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for Path

Source§

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

Source§

impl<Hcx> HashStable<Hcx> for PathBuf

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher)

Source§

impl<I: Idx, Hcx> HashStable<Hcx> for DenseBitSet<I>

Source§

fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher)

Source§

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

Source§

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

Source§

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

Source§

fn hash_stable(&self, hcx: &mut Hcx, 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, Hcx> HashStable<Hcx> for IndexSet<K, R>
where K: HashStable<Hcx> + Eq + Hash, R: BuildHasher,

Source§

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

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, Hcx> HashStable<Hcx> for IndexMap<K, V, R>
where K: HashStable<Hcx> + Eq + Hash, V: HashStable<Hcx>, R: BuildHasher,

Source§

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

Source§

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

Source§

fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher)

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl<'a, P, T, Hcx> HashStable<Hcx> for TaggedRef<'a, P, T>
where P: HashStable<Hcx> + Aligned + ?Sized, T: Tag + HashStable<Hcx>,

Source§

impl<Hcx> HashStable<Hcx> for Fingerprint

Source§

impl<Hcx> HashStable<Hcx> for Pu128

Source§

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

Source§

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

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, __CTX> HashStable<__CTX> for SortedIndexMultiMap<I, K, V>
where IndexVec<I, (K, V)>: HashStable<__CTX>, Vec<I>: HashStable<__CTX>,

Source§

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

Source§

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

Source§

impl<__CTX> HashStable<__CTX> for Svh