@@ -24,6 +24,7 @@ use crate::ty::{
24
24
RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyS , TyVar , TyVid , TypeAndMut , UintTy ,
25
25
} ;
26
26
use rustc_ast as ast;
27
+ use rustc_data_structures:: fingerprint:: Fingerprint ;
27
28
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
28
29
use rustc_data_structures:: intern:: Interned ;
29
30
use rustc_data_structures:: memmap:: Mmap ;
@@ -58,6 +59,7 @@ use rustc_span::{Span, DUMMY_SP};
58
59
use rustc_target:: abi:: { Layout , TargetDataLayout , VariantIdx } ;
59
60
use rustc_target:: spec:: abi;
60
61
62
+ use rustc_type_ir:: TypeFlags ;
61
63
use smallvec:: SmallVec ;
62
64
use std:: any:: Any ;
63
65
use std:: borrow:: Borrow ;
@@ -140,16 +142,40 @@ impl<'tcx> CtxtInterners<'tcx> {
140
142
/// Interns a type.
141
143
#[ allow( rustc:: usage_of_ty_tykind) ]
142
144
#[ inline( never) ]
143
- fn intern_ty ( & self , kind : TyKind < ' tcx > ) -> Ty < ' tcx > {
145
+ fn intern_ty (
146
+ & self ,
147
+ kind : TyKind < ' tcx > ,
148
+ sess : & Session ,
149
+ resolutions : & ty:: ResolverOutputs ,
150
+ ) -> Ty < ' tcx > {
144
151
Ty ( Interned :: new_unchecked (
145
152
self . type_
146
153
. intern ( kind, |kind| {
147
154
let flags = super :: flags:: FlagComputation :: for_kind ( & kind) ;
148
155
156
+ let stable_hash = if flags. flags . intersects ( TypeFlags :: HAS_RE_INFER ) {
157
+ Fingerprint :: ZERO
158
+ } else {
159
+ let mut hasher = StableHasher :: new ( ) ;
160
+ let mut hcx = StableHashingContext :: new (
161
+ sess,
162
+ & resolutions. definitions ,
163
+ & * resolutions. cstore ,
164
+ ) ;
165
+
166
+ hcx. while_hashing_spans ( false , |hcx| {
167
+ hcx. with_node_id_hashing_mode ( NodeIdHashingMode :: HashDefPath , |hcx| {
168
+ kind. hash_stable ( hcx, & mut hasher) ;
169
+ } ) ;
170
+ } ) ;
171
+ hasher. finish ( )
172
+ } ;
173
+
149
174
let ty_struct = TyS {
150
175
kind,
151
176
flags : flags. flags ,
152
177
outer_exclusive_binder : flags. outer_exclusive_binder ,
178
+ stable_hash,
153
179
} ;
154
180
155
181
InternedInSet ( self . arena . alloc ( ty_struct) )
@@ -887,8 +913,12 @@ pub enum UserType<'tcx> {
887
913
}
888
914
889
915
impl < ' tcx > CommonTypes < ' tcx > {
890
- fn new ( interners : & CtxtInterners < ' tcx > ) -> CommonTypes < ' tcx > {
891
- let mk = |ty| interners. intern_ty ( ty) ;
916
+ fn new (
917
+ interners : & CtxtInterners < ' tcx > ,
918
+ sess : & Session ,
919
+ resolutions : & ty:: ResolverOutputs ,
920
+ ) -> CommonTypes < ' tcx > {
921
+ let mk = |ty| interners. intern_ty ( ty, sess, resolutions) ;
892
922
893
923
CommonTypes {
894
924
unit : mk ( Tuple ( List :: empty ( ) ) ) ,
@@ -1162,7 +1192,7 @@ impl<'tcx> TyCtxt<'tcx> {
1162
1192
s. fatal ( & err) ;
1163
1193
} ) ;
1164
1194
let interners = CtxtInterners :: new ( arena) ;
1165
- let common_types = CommonTypes :: new ( & interners) ;
1195
+ let common_types = CommonTypes :: new ( & interners, s , & resolutions ) ;
1166
1196
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1167
1197
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
1168
1198
@@ -2276,7 +2306,7 @@ impl<'tcx> TyCtxt<'tcx> {
2276
2306
#[ allow( rustc:: usage_of_ty_tykind) ]
2277
2307
#[ inline]
2278
2308
pub fn mk_ty ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
2279
- self . interners . intern_ty ( st)
2309
+ self . interners . intern_ty ( st, self . sess , & self . gcx . untracked_resolutions )
2280
2310
}
2281
2311
2282
2312
#[ inline]
0 commit comments