Cache Predicates' hash within themselves

This commit is contained in:
Oli Scherer
2022-03-14 16:54:31 +00:00
parent 8a75c5a9b5
commit 8582f9644b
3 changed files with 59 additions and 28 deletions

View File

@@ -546,9 +546,9 @@ pub(crate) struct PredicateS<'tcx> {
}
/// Use this rather than `PredicateS`, whenever possible.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable)]
#[rustc_pass_by_value]
pub struct Predicate<'tcx>(Interned<'tcx, PredicateS<'tcx>>);
pub struct Predicate<'tcx>(Interned<'tcx, WithStableHash<PredicateS<'tcx>>>);
impl<'tcx> Predicate<'tcx> {
/// Gets the inner `Binder<'tcx, PredicateKind<'tcx>>`.
@@ -627,7 +627,7 @@ impl<'tcx> Predicate<'tcx> {
}
}
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for PredicateS<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let PredicateS {
ref kind,
@@ -636,7 +636,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {
// also contained in `kind`, so no need to hash them.
flags: _,
outer_exclusive_binder: _,
} = self.0.0;
} = self;
kind.hash_stable(hcx, hasher);
}