@@ -75,10 +75,6 @@ pub struct OnDiskCache<'sess> {
75
75
// A map from dep-node to the position of any associated diagnostics in
76
76
// `serialized_data`.
77
77
prev_diagnostics_index : FxHashMap < SerializedDepNodeIndex , AbsoluteBytePos > ,
78
-
79
- // A map from dep-node to the position of any associated constants in
80
- // `serialized_data`.
81
- prev_constants_index : FxHashMap < SerializedDepNodeIndex , AbsoluteBytePos > ,
82
78
}
83
79
84
80
// This type is used only for (de-)serialization.
@@ -88,10 +84,8 @@ struct Footer {
88
84
prev_cnums : Vec < ( u32 , String , CrateDisambiguator ) > ,
89
85
query_result_index : EncodedQueryResultIndex ,
90
86
diagnostics_index : EncodedQueryResultIndex ,
91
- constants_index : EncodedConstantsIndex ,
92
87
}
93
88
94
- type EncodedConstantsIndex = Vec < ( SerializedDepNodeIndex , AbsoluteBytePos ) > ;
95
89
type EncodedQueryResultIndex = Vec < ( SerializedDepNodeIndex , AbsoluteBytePos ) > ;
96
90
type EncodedDiagnosticsIndex = Vec < ( SerializedDepNodeIndex , AbsoluteBytePos ) > ;
97
91
type EncodedDiagnostics = Vec < Diagnostic > ;
@@ -145,7 +139,6 @@ impl<'sess> OnDiskCache<'sess> {
145
139
current_diagnostics : RefCell :: new ( FxHashMap ( ) ) ,
146
140
query_result_index : footer. query_result_index . into_iter ( ) . collect ( ) ,
147
141
prev_diagnostics_index : footer. diagnostics_index . into_iter ( ) . collect ( ) ,
148
- prev_constants_index : footer. constants_index . into_iter ( ) . collect ( ) ,
149
142
synthetic_expansion_infos : RefCell :: new ( FxHashMap ( ) ) ,
150
143
}
151
144
}
@@ -161,7 +154,6 @@ impl<'sess> OnDiskCache<'sess> {
161
154
current_diagnostics : RefCell :: new ( FxHashMap ( ) ) ,
162
155
query_result_index : FxHashMap ( ) ,
163
156
prev_diagnostics_index : FxHashMap ( ) ,
164
- prev_constants_index : FxHashMap ( ) ,
165
157
synthetic_expansion_infos : RefCell :: new ( FxHashMap ( ) ) ,
166
158
}
167
159
}
@@ -229,46 +221,25 @@ impl<'sess> OnDiskCache<'sess> {
229
221
encode_query_results :: < symbol_name , _ > ( tcx, enc, qri) ?;
230
222
encode_query_results :: < check_match , _ > ( tcx, enc, qri) ?;
231
223
encode_query_results :: < trans_fn_attrs , _ > ( tcx, enc, qri) ?;
232
- }
233
224
234
- // encode successful constant evaluations
235
- let constants_index = {
236
- let mut constants_index = EncodedConstantsIndex :: new ( ) ;
237
- use ty:: maps:: queries:: const_eval;
225
+ // const eval is special, it only encodes successfully evaluated constants
238
226
use ty:: maps:: plumbing:: GetCacheInternal ;
239
- use ty:: maps:: config:: QueryDescription ;
240
227
for ( key, entry) in const_eval:: get_cache_internal ( tcx) . map . iter ( ) {
241
- if let Ok ( ref constant ) = entry . value {
242
- if const_eval:: cache_on_disk ( key. clone ( ) ) {
243
- trace ! ( "caching constant {:?} with value {:#?}" , key , constant ) ;
228
+ use ty :: maps :: config :: QueryDescription ;
229
+ if const_eval:: cache_on_disk ( key. clone ( ) ) {
230
+ if let Ok ( ref value ) = entry . value {
244
231
let dep_node = SerializedDepNodeIndex :: new ( entry. index . index ( ) ) ;
245
232
246
233
// Record position of the cache entry
247
- constants_index. push ( (
248
- dep_node,
249
- AbsoluteBytePos :: new ( encoder. position ( ) ) ,
250
- ) ) ;
251
- let did = key. value . instance . def_id ( ) ;
252
- let constant = if key. value . promoted . is_none ( )
253
- && tcx. is_static ( did) . is_some ( ) {
254
- // memorize the allocation for the static, too, so
255
- // we can refer to the static, not just read its value
256
- // since we have had a successful query, the cached value must
257
- // exist, so we can unwrap it
258
- let cached = tcx. interpret_interner . get_cached ( did) . unwrap ( ) ;
259
- ( constant, Some ( cached) )
260
- } else {
261
- ( constant, None )
262
- } ;
234
+ qri. push ( ( dep_node, AbsoluteBytePos :: new ( enc. position ( ) ) ) ) ;
263
235
264
236
// Encode the type check tables with the SerializedDepNodeIndex
265
237
// as tag.
266
- encoder . encode_tagged ( dep_node, & constant ) ?;
238
+ enc . encode_tagged ( dep_node, value ) ?;
267
239
}
268
240
}
269
241
}
270
- constants_index
271
- } ;
242
+ }
272
243
273
244
// Encode diagnostics
274
245
let diagnostics_index = {
@@ -303,7 +274,6 @@ impl<'sess> OnDiskCache<'sess> {
303
274
prev_cnums,
304
275
query_result_index,
305
276
diagnostics_index,
306
- constants_index,
307
277
} ) ?;
308
278
309
279
// Encode the position of the footer as the last 8 bytes of the
@@ -326,25 +296,6 @@ impl<'sess> OnDiskCache<'sess> {
326
296
} )
327
297
}
328
298
329
- /// Load a constant emitted during the previous compilation session.
330
- pub fn load_constant < ' a , ' tcx > ( & self ,
331
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
332
- dep_node_index : SerializedDepNodeIndex )
333
- -> Option < & ' tcx ty:: Const < ' tcx > > {
334
- type Encoded < ' tcx > = ( ty:: Const < ' tcx > , Option < interpret:: AllocId > ) ;
335
- let constant: Option < Encoded < ' tcx > > = self . load_indexed (
336
- tcx,
337
- dep_node_index,
338
- & self . prev_constants_index ,
339
- "constants" ) ;
340
-
341
- constant. map ( |( c, _alloc_id) | {
342
- // the AllocId decoding already registers the AllocId to its DefId
343
- // so we don't need to take additional actions here
344
- tcx. mk_const ( c)
345
- } )
346
- }
347
-
348
299
/// Load a diagnostic emitted during the previous compilation session.
349
300
pub fn load_diagnostics < ' a , ' tcx > ( & self ,
350
301
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
0 commit comments