@@ -75,10 +75,6 @@ pub struct OnDiskCache<'sess> {
7575 // A map from dep-node to the position of any associated diagnostics in
7676 // `serialized_data`.
7777 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 > ,
8278}
8379
8480// This type is used only for (de-)serialization.
@@ -88,10 +84,8 @@ struct Footer {
8884 prev_cnums : Vec < ( u32 , String , CrateDisambiguator ) > ,
8985 query_result_index : EncodedQueryResultIndex ,
9086 diagnostics_index : EncodedQueryResultIndex ,
91- constants_index : EncodedConstantsIndex ,
9287}
9388
94- type EncodedConstantsIndex = Vec < ( SerializedDepNodeIndex , AbsoluteBytePos ) > ;
9589type EncodedQueryResultIndex = Vec < ( SerializedDepNodeIndex , AbsoluteBytePos ) > ;
9690type EncodedDiagnosticsIndex = Vec < ( SerializedDepNodeIndex , AbsoluteBytePos ) > ;
9791type EncodedDiagnostics = Vec < Diagnostic > ;
@@ -145,7 +139,6 @@ impl<'sess> OnDiskCache<'sess> {
145139 current_diagnostics : RefCell :: new ( FxHashMap ( ) ) ,
146140 query_result_index : footer. query_result_index . into_iter ( ) . collect ( ) ,
147141 prev_diagnostics_index : footer. diagnostics_index . into_iter ( ) . collect ( ) ,
148- prev_constants_index : footer. constants_index . into_iter ( ) . collect ( ) ,
149142 synthetic_expansion_infos : RefCell :: new ( FxHashMap ( ) ) ,
150143 }
151144 }
@@ -161,7 +154,6 @@ impl<'sess> OnDiskCache<'sess> {
161154 current_diagnostics : RefCell :: new ( FxHashMap ( ) ) ,
162155 query_result_index : FxHashMap ( ) ,
163156 prev_diagnostics_index : FxHashMap ( ) ,
164- prev_constants_index : FxHashMap ( ) ,
165157 synthetic_expansion_infos : RefCell :: new ( FxHashMap ( ) ) ,
166158 }
167159 }
@@ -229,46 +221,25 @@ impl<'sess> OnDiskCache<'sess> {
229221 encode_query_results :: < symbol_name , _ > ( tcx, enc, qri) ?;
230222 encode_query_results :: < check_match , _ > ( tcx, enc, qri) ?;
231223 encode_query_results :: < trans_fn_attrs , _ > ( tcx, enc, qri) ?;
232- }
233224
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
238226 use ty:: maps:: plumbing:: GetCacheInternal ;
239- use ty:: maps:: config:: QueryDescription ;
240227 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 {
244231 let dep_node = SerializedDepNodeIndex :: new ( entry. index . index ( ) ) ;
245232
246233 // 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 ( ) ) ) ) ;
263235
264236 // Encode the type check tables with the SerializedDepNodeIndex
265237 // as tag.
266- encoder . encode_tagged ( dep_node, & constant ) ?;
238+ enc . encode_tagged ( dep_node, value ) ?;
267239 }
268240 }
269241 }
270- constants_index
271- } ;
242+ }
272243
273244 // Encode diagnostics
274245 let diagnostics_index = {
@@ -303,7 +274,6 @@ impl<'sess> OnDiskCache<'sess> {
303274 prev_cnums,
304275 query_result_index,
305276 diagnostics_index,
306- constants_index,
307277 } ) ?;
308278
309279 // Encode the position of the footer as the last 8 bytes of the
@@ -326,25 +296,6 @@ impl<'sess> OnDiskCache<'sess> {
326296 } )
327297 }
328298
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-
348299 /// Load a diagnostic emitted during the previous compilation session.
349300 pub fn load_diagnostics < ' a , ' tcx > ( & self ,
350301 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
0 commit comments