Skip to content

Commit e41d60c

Browse files
Add StableHash implementation for ty::Instance.
1 parent af095e8 commit e41d60c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,3 +661,60 @@ for ty::TypeckTables<'tcx> {
661661
})
662662
}
663663
}
664+
665+
impl_stable_hash_for!(enum ty::fast_reject::SimplifiedType {
666+
BoolSimplifiedType,
667+
CharSimplifiedType,
668+
IntSimplifiedType(int_ty),
669+
UintSimplifiedType(int_ty),
670+
FloatSimplifiedType(float_ty),
671+
AdtSimplifiedType(def_id),
672+
StrSimplifiedType,
673+
ArraySimplifiedType,
674+
PtrSimplifiedType,
675+
NeverSimplifiedType,
676+
TupleSimplifiedType(size),
677+
TraitSimplifiedType(def_id),
678+
ClosureSimplifiedType(def_id),
679+
AnonSimplifiedType(def_id),
680+
FunctionSimplifiedType(params),
681+
ParameterSimplifiedType
682+
});
683+
684+
impl_stable_hash_for!(struct ty::Instance<'tcx> {
685+
def,
686+
substs
687+
});
688+
689+
impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ty::InstanceDef<'tcx> {
690+
fn hash_stable<W: StableHasherResult>(&self,
691+
hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
692+
hasher: &mut StableHasher<W>) {
693+
mem::discriminant(self).hash_stable(hcx, hasher);
694+
695+
match *self {
696+
ty::InstanceDef::Item(def_id) => {
697+
def_id.hash_stable(hcx, hasher);
698+
}
699+
ty::InstanceDef::Intrinsic(def_id) => {
700+
def_id.hash_stable(hcx, hasher);
701+
}
702+
ty::InstanceDef::FnPtrShim(def_id, ty) => {
703+
def_id.hash_stable(hcx, hasher);
704+
ty.hash_stable(hcx, hasher);
705+
}
706+
ty::InstanceDef::Virtual(def_id, n) => {
707+
def_id.hash_stable(hcx, hasher);
708+
n.hash_stable(hcx, hasher);
709+
}
710+
ty::InstanceDef::ClosureOnceShim { call_once } => {
711+
call_once.hash_stable(hcx, hasher);
712+
}
713+
ty::InstanceDef::DropGlue(def_id, t) => {
714+
def_id.hash_stable(hcx, hasher);
715+
t.hash_stable(hcx, hasher);
716+
}
717+
}
718+
}
719+
}
720+

0 commit comments

Comments
 (0)