From 9808661b3d696c3f115b3dc3c68a8dc6cbc3bf72 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Fri, 30 Jun 2017 14:51:03 -0700 Subject: Add StableHash implementation for ty::Instance. --- src/librustc/ich/impls_ty.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 4f365a97f4c..a286ce8c7cb 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -661,3 +661,60 @@ for ty::TypeckTables<'tcx> { }) } } + +impl_stable_hash_for!(enum ty::fast_reject::SimplifiedType { + BoolSimplifiedType, + CharSimplifiedType, + IntSimplifiedType(int_ty), + UintSimplifiedType(int_ty), + FloatSimplifiedType(float_ty), + AdtSimplifiedType(def_id), + StrSimplifiedType, + ArraySimplifiedType, + PtrSimplifiedType, + NeverSimplifiedType, + TupleSimplifiedType(size), + TraitSimplifiedType(def_id), + ClosureSimplifiedType(def_id), + AnonSimplifiedType(def_id), + FunctionSimplifiedType(params), + ParameterSimplifiedType +}); + +impl_stable_hash_for!(struct ty::Instance<'tcx> { + def, + substs +}); + +impl<'a, 'gcx, 'tcx> HashStable> for ty::InstanceDef<'tcx> { + fn hash_stable(&self, + hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>, + hasher: &mut StableHasher) { + mem::discriminant(self).hash_stable(hcx, hasher); + + match *self { + ty::InstanceDef::Item(def_id) => { + def_id.hash_stable(hcx, hasher); + } + ty::InstanceDef::Intrinsic(def_id) => { + def_id.hash_stable(hcx, hasher); + } + ty::InstanceDef::FnPtrShim(def_id, ty) => { + def_id.hash_stable(hcx, hasher); + ty.hash_stable(hcx, hasher); + } + ty::InstanceDef::Virtual(def_id, n) => { + def_id.hash_stable(hcx, hasher); + n.hash_stable(hcx, hasher); + } + ty::InstanceDef::ClosureOnceShim { call_once } => { + call_once.hash_stable(hcx, hasher); + } + ty::InstanceDef::DropGlue(def_id, t) => { + def_id.hash_stable(hcx, hasher); + t.hash_stable(hcx, hasher); + } + } + } +} + -- cgit 1.4.1-3-g733a5