diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2023-04-22 10:33:57 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-22 10:33:57 +0900 |
| commit | 9a798e416cd998aba2b17aeb89a0f707c2e40ae9 (patch) | |
| tree | 57a670f3aef48bc4b0c5eaa2f38c2c249e16d4b7 | |
| parent | 684bdf87f4431210ef827d68247c50f2a2b0a8d2 (diff) | |
| parent | 4375af53af48febdd3534d8d300b7769a4e0fb1c (diff) | |
| download | rust-9a798e416cd998aba2b17aeb89a0f707c2e40ae9.tar.gz rust-9a798e416cd998aba2b17aeb89a0f707c2e40ae9.zip | |
Rollup merge of #110622 - WaffleLapkin:hashtag#, r=compiler-errors
Stable hash tag (discriminant) of `GenericArg` This is a continuation of my quest of removing `transmute` if generic args and types (#110496, #110599). r? `@compiler-errors`
| -rw-r--r-- | compiler/rustc_middle/src/ty/impls_ty.rs | 28 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/subst.rs | 2 |
2 files changed, 1 insertions, 29 deletions
diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index 4c7822acdf7..02baa395c3c 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -73,34 +73,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArg<'t } } -impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArgKind<'tcx> { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - match self { - // WARNING: We dedup cache the `HashStable` results for `List` - // while ignoring types and freely transmute - // between `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>`. - // See `fn mk_type_list` for more details. - // - // We therefore hash types without adding a hash for their discriminant. - // - // 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 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) => { - 0xF3u8.hash_stable(hcx, hasher); - ct.hash_stable(hcx, hasher); - } - ty::subst::GenericArgKind::Lifetime(lt) => { - 0xF5u8.hash_stable(hcx, hasher); - lt.hash_stable(hcx, hasher); - } - } - } -} - // AllocIds get resolved to whatever they point to (to be stable) impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 73c9c86f76a..a439211ca33 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -47,7 +47,7 @@ const TYPE_TAG: usize = 0b00; const REGION_TAG: usize = 0b01; const CONST_TAG: usize = 0b10; -#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord, HashStable)] pub enum GenericArgKind<'tcx> { Lifetime(ty::Region<'tcx>), Type(Ty<'tcx>), |
