]> git.lizzy.rs Git - rust.git/commitdiff
Implement Hash for new types
authorvarkor <github@varkor.com>
Wed, 20 Feb 2019 01:13:49 +0000 (01:13 +0000)
committervarkor <github@varkor.com>
Tue, 5 Mar 2019 22:09:31 +0000 (22:09 +0000)
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
src/librustc/ich/impls_ty.rs

index f77a88128f252ef36deb2a9665d78a087547da56..21988de90183a0a9df91bd6d830f76e9941b6f28 100644 (file)
@@ -74,6 +74,7 @@ fn hash_stable<W: StableHasherResult>(&self,
         match self {
             ty::subst::UnpackedKind::Lifetime(lt) => lt.hash_stable(hcx, hasher),
             ty::subst::UnpackedKind::Type(ty) => ty.hash_stable(hcx, hasher),
+            ty::subst::UnpackedKind::Const(ct) => ct.hash_stable(hcx, hasher),
         }
     }
 }
@@ -134,6 +135,15 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
+impl<'gcx, 'tcx> HashStable<StableHashingContext<'gcx>> for ty::ConstVid<'tcx> {
+    #[inline]
+    fn hash_stable<W: StableHasherResult>(&self,
+                                          hcx: &mut StableHashingContext<'gcx>,
+                                          hasher: &mut StableHasher<W>) {
+        self.index.hash_stable(hcx, hasher);
+    }
+}
+
 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
     #[inline]
     fn hash_stable<W: StableHasherResult>(&self,
@@ -297,6 +307,14 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
+impl_stable_hash_for!(
+    impl<'tcx> for enum ty::InferConst<'tcx> [ ty::InferConst ] {
+        Var(vid),
+        Fresh(i),
+        Canonical(debruijn, var),
+    }
+);
+
 impl_stable_hash_for!(enum ty::VariantDiscr {
     Explicit(def_id),
     Relative(distance)
@@ -310,11 +328,14 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 impl_stable_hash_for!(
     impl<'tcx> for enum mir::interpret::ConstValue<'tcx> [ mir::interpret::ConstValue ] {
+        Param(param),
+        Infer(infer),
         Scalar(val),
         Slice(a, b),
         ByRef(ptr, alloc),
     }
 );
+
 impl_stable_hash_for!(struct crate::mir::interpret::RawConst<'tcx> {
     alloc_id,
     ty,
@@ -518,6 +539,7 @@ impl<'tcx, O> for enum mir::interpret::EvalErrorKind<'tcx, O>
 impl_stable_hash_for!(enum ty::GenericParamDefKind {
     Lifetime,
     Type { has_default, object_lifetime_default, synthetic },
+    Const,
 });
 
 impl_stable_hash_for!(
@@ -736,6 +758,11 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
+impl_stable_hash_for!(struct ty::ParamConst {
+    index,
+    name
+});
+
 impl_stable_hash_for!(struct ty::ParamTy {
     idx,
     name