about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo.net>2017-06-30 14:51:03 -0700
committerMichael Woerister <michaelwoerister@posteo.net>2017-07-10 12:20:56 +0200
commit9808661b3d696c3f115b3dc3c68a8dc6cbc3bf72 (patch)
tree354064bf5c2d2a6943acb7a72a64e9d30c32dbe4
parentca0a40396cd6c92dbe56e3f8c744a95b29964d68 (diff)
downloadrust-9808661b3d696c3f115b3dc3c68a8dc6cbc3bf72.tar.gz
rust-9808661b3d696c3f115b3dc3c68a8dc6cbc3bf72.zip
Add StableHash implementation for ty::Instance.
-rw-r--r--src/librustc/ich/impls_ty.rs57
1 files changed, 57 insertions, 0 deletions
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<StableHashingContext<'a, 'gcx, 'tcx>> for ty::InstanceDef<'tcx> {
+    fn hash_stable<W: StableHasherResult>(&self,
+                                          hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
+                                          hasher: &mut StableHasher<W>) {
+        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);
+            }
+        }
+    }
+}
+