Skip to content

Commit c51871c

Browse files
committed
Auto merge of rust-lang#94799 - lcnr:list-ty-perf, r=petrochenkov
update `hash_stable` for `List<Ty<'tcx>>` cc rust-lang#93505 (comment) this is the hottest part changed since the pre-merge perf run
2 parents d53f1e8 + 5b6b348 commit c51871c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_middle/src/ty/impls_ty.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,16 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArgKin
8686
//
8787
// In order to make it very unlikely for the sequence of bytes being hashed for
8888
// a `GenericArgKind::Type` to be the same as the sequence of bytes being
89-
// hashed for one of the other variants, we hash a `0xFF` byte before hashing
90-
// their discriminant (since the discriminant of `TyKind` is unlikely to ever start
91-
// with 0xFF).
89+
// hashed for one of the other variants, we hash some very high number instead
90+
// of their actual discriminant since `TyKind` should never start with anything
91+
// that high.
9292
ty::subst::GenericArgKind::Type(ty) => ty.hash_stable(hcx, hasher),
9393
ty::subst::GenericArgKind::Const(ct) => {
94-
0xFFu8.hash_stable(hcx, hasher);
95-
mem::discriminant(self).hash_stable(hcx, hasher);
94+
0xF3u8.hash_stable(hcx, hasher);
9695
ct.hash_stable(hcx, hasher);
9796
}
9897
ty::subst::GenericArgKind::Lifetime(lt) => {
99-
0xFFu8.hash_stable(hcx, hasher);
100-
mem::discriminant(self).hash_stable(hcx, hasher);
98+
0xF5u8.hash_stable(hcx, hasher);
10199
lt.hash_stable(hcx, hasher);
102100
}
103101
}

0 commit comments

Comments
 (0)