@@ -31,8 +31,8 @@ use crate::ty::util::Discr;
3131use rustc_ast as ast;
3232use rustc_attr as attr;
3333use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
34- use rustc_data_structures:: intern:: Interned ;
35- use rustc_data_structures:: stable_hasher:: { HashStable , NodeIdHashingMode , StableHasher } ;
34+ use rustc_data_structures:: intern:: { InTy , Interned } ;
35+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
3636use rustc_data_structures:: tagged_ptr:: CopyTaggedPtr ;
3737use rustc_hir as hir;
3838use rustc_hir:: def:: { CtorKind , CtorOf , DefKind , Res } ;
@@ -433,32 +433,28 @@ crate struct TyS<'tcx> {
433433 /// De Bruijn indices within the type are contained within `0..D`
434434 /// (exclusive).
435435 outer_exclusive_binder : ty:: DebruijnIndex ,
436-
437- /// The stable hash of the type. This way hashing of types will not have to work
438- /// on the address of the type anymore, but can instead just read this field
439- stable_hash : Fingerprint ,
440436}
441437
442438// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
443439#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "64" ) ) ]
444- static_assert_size ! ( TyS <' _>, 56 ) ;
440+ static_assert_size ! ( TyS <' _>, 40 ) ;
445441
446442/// Use this rather than `TyS`, whenever possible.
447- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
443+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , HashStable ) ]
448444#[ rustc_diagnostic_item = "Ty" ]
449445#[ rustc_pass_by_value]
450- pub struct Ty < ' tcx > ( Interned < ' tcx , TyS < ' tcx > > ) ;
446+ pub struct Ty < ' tcx > ( Interned < ' tcx , InTy < TyS < ' tcx > > > ) ;
451447
452448// Statics only used for internal testing.
453- pub static BOOL_TY : Ty < ' static > = Ty ( Interned :: new_unchecked ( & BOOL_TYS ) ) ;
454- static BOOL_TYS : TyS < ' static > = TyS {
449+ pub static BOOL_TY : Ty < ' static > =
450+ Ty ( Interned :: new_unchecked ( & InTy { internee : BOOL_TYS , stable_hash : Fingerprint :: ZERO } ) ) ;
451+ const BOOL_TYS : TyS < ' static > = TyS {
455452 kind : ty:: Bool ,
456453 flags : TypeFlags :: empty ( ) ,
457454 outer_exclusive_binder : DebruijnIndex :: from_usize ( 0 ) ,
458- stable_hash : Fingerprint :: ZERO ,
459455} ;
460456
461- impl < ' a , ' tcx > HashStable < StableHashingContext < ' a > > for Ty < ' tcx > {
457+ impl < ' a , ' tcx > HashStable < StableHashingContext < ' a > > for TyS < ' tcx > {
462458 fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
463459 let TyS {
464460 kind,
@@ -468,28 +464,9 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Ty<'tcx> {
468464 flags : _,
469465
470466 outer_exclusive_binder : _,
467+ } = self ;
471468
472- stable_hash,
473- } = self . 0 . 0 ;
474-
475- if * stable_hash == Fingerprint :: ZERO {
476- // No cached hash available. This can only mean that incremental is disabled.
477- // We don't cache stable hashes in non-incremental mode, because they are used
478- // so rarely that the performance actually suffers.
479-
480- let stable_hash: Fingerprint = {
481- let mut hasher = StableHasher :: new ( ) ;
482- hcx. while_hashing_spans ( false , |hcx| {
483- hcx. with_node_id_hashing_mode ( NodeIdHashingMode :: HashDefPath , |hcx| {
484- kind. hash_stable ( hcx, & mut hasher)
485- } )
486- } ) ;
487- hasher. finish ( )
488- } ;
489- stable_hash. hash_stable ( hcx, hasher) ;
490- } else {
491- stable_hash. hash_stable ( hcx, hasher) ;
492- }
469+ kind. hash_stable ( hcx, hasher)
493470 }
494471}
495472
0 commit comments