diff options
| author | bors <bors@rust-lang.org> | 2022-05-10 10:53:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-10 10:53:47 +0000 |
| commit | c51871c469f7ed3b35ae25d7e6e77bc73fbdd0e3 (patch) | |
| tree | b803c7532ecf211c28f6efd79a4b170145b76422 | |
| parent | d53f1e8fbf891cf84fcb11eb078a27e528df795a (diff) | |
| parent | 5b6b348b8525686d828621ecfa30a282a7269d0c (diff) | |
| download | rust-c51871c469f7ed3b35ae25d7e6e77bc73fbdd0e3.tar.gz rust-c51871c469f7ed3b35ae25d7e6e77bc73fbdd0e3.zip | |
Auto merge of #94799 - lcnr:list-ty-perf, r=petrochenkov
update `hash_stable` for `List<Ty<'tcx>>` cc https://github.com/rust-lang/rust/pull/93505#issuecomment-1047538798 this is the hottest part changed since the pre-merge perf run
| -rw-r--r-- | compiler/rustc_middle/src/ty/impls_ty.rs | 12 |
1 files 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 2009364b24e..65c9b1aed05 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -86,18 +86,16 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> 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); 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); } } |
