From 299dd02e11f9165cc9e9b2038eb6723d96767b60 Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 10 Mar 2022 08:29:20 +0100 Subject: [PATCH 1/2] update `hash_stable` for `List>` --- compiler/rustc_middle/src/ty/impls_ty.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index 54a345daec8a5..1dc7083c2a0f0 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -73,18 +73,16 @@ impl<'a, 'tcx> HashStable> for ty::subst::GenericArgKin // // In order to make it very unlikely for the sequence of bytes being hashed for // a `GenericArgKind::Type` to be the same as the sequence of bytes being - // hashed for one of the other variants, we hash a `0xFF` byte before hashing - // their discriminant (since the discriminant of `TyKind` is unlikely to ever start - // with 0xFF). + // hashed for one of the other variants, we hash some very high number instead + // of their actual discriminant since `TyKind` should never start with anything + // that high. ty::subst::GenericArgKind::Type(ty) => ty.hash_stable(hcx, hasher), ty::subst::GenericArgKind::Const(ct) => { - 0xFFu8.hash_stable(hcx, hasher); - mem::discriminant(self).hash_stable(hcx, hasher); + 0xF3u8.hash_stable(hcx, hasher).hash_stable(hcx, hasher); ct.hash_stable(hcx, hasher); } ty::subst::GenericArgKind::Lifetime(lt) => { - 0xFFu8.hash_stable(hcx, hasher); - mem::discriminant(self).hash_stable(hcx, hasher); + 0xF5u8.hash_stable(hcx, hasher); lt.hash_stable(hcx, hasher); } } From 5b6b348b8525686d828621ecfa30a282a7269d0c Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 10 Mar 2022 11:39:12 +0100 Subject: [PATCH 2/2] don't hash `()` --- compiler/rustc_middle/src/ty/impls_ty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index 1dc7083c2a0f0..ead3d6de16c7c 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -78,7 +78,7 @@ impl<'a, 'tcx> HashStable> for ty::subst::GenericArgKin // that high. ty::subst::GenericArgKind::Type(ty) => ty.hash_stable(hcx, hasher), ty::subst::GenericArgKind::Const(ct) => { - 0xF3u8.hash_stable(hcx, hasher).hash_stable(hcx, hasher); + 0xF3u8.hash_stable(hcx, hasher); ct.hash_stable(hcx, hasher); } ty::subst::GenericArgKind::Lifetime(lt) => {