@@ -32,7 +32,6 @@ use syntax_pos::{BytePos, Span, NO_EXPANSION, DUMMY_SP};
32
32
use ty;
33
33
use ty:: codec:: { self as ty_codec, TyDecoder , TyEncoder } ;
34
34
use ty:: context:: TyCtxt ;
35
- use ty:: maps:: config:: QueryDescription ;
36
35
use ty:: subst:: Substs ;
37
36
38
37
// Some magic values used for verifying that encoding and decoding. These are
@@ -162,11 +161,11 @@ impl<'sess> OnDiskCache<'sess> {
162
161
}
163
162
}
164
163
165
- pub fn serialize < ' a , ' gcx , ' lcx , E > ( & self ,
166
- tcx : TyCtxt < ' a , ' gcx , ' lcx > ,
167
- cstore : & CrateStore ,
168
- encoder : & mut E )
169
- -> Result < ( ) , E :: Error >
164
+ pub fn serialize < ' a , ' tcx , E > ( & self ,
165
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
166
+ cstore : & CrateStore ,
167
+ encoder : & mut E )
168
+ -> Result < ( ) , E :: Error >
170
169
where E : ty_codec:: TyEncoder
171
170
{
172
171
// Serializing the DepGraph should not modify it:
@@ -232,19 +231,13 @@ impl<'sess> OnDiskCache<'sess> {
232
231
// Encode query results
233
232
let mut query_result_index = EncodedQueryResultIndex :: new ( ) ;
234
233
235
- // Encode TypeckTables
236
- for ( def_id , entry ) in tcx . maps . typeck_tables_of . borrow ( ) . map . iter ( ) {
237
- if ty :: maps :: queries :: typeck_tables_of :: cache_on_disk ( * def_id ) {
238
- let dep_node = SerializedDepNodeIndex :: new ( entry . index . index ( ) ) ;
234
+ {
235
+ use ty :: maps :: queries :: * ;
236
+ let enc = & mut encoder ;
237
+ let qri = & mut query_result_index ;
239
238
240
- // Record position of the cache entry
241
- query_result_index. push ( ( dep_node, encoder. position ( ) ) ) ;
242
-
243
- // Encode the type check tables with the SerializedDepNodeIndex
244
- // as tag.
245
- let typeck_tables: & ty:: TypeckTables < ' gcx > = & entry. value ;
246
- encoder. encode_tagged ( dep_node, typeck_tables) ?;
247
- }
239
+ // Encode TypeckTables
240
+ encode_query_results :: < typeck_tables_of , _ > ( tcx, enc, qri) ?;
248
241
}
249
242
250
243
// Encode query result index
@@ -842,3 +835,27 @@ for CacheDecoder<'a, 'tcx, 'x> {
842
835
Ok ( IntEncodedWithFixedSize ( value) )
843
836
}
844
837
}
838
+
839
+ fn encode_query_results < ' x , ' a , ' tcx , Q , E > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
840
+ encoder : & mut CacheEncoder < ' x , ' tcx , E > ,
841
+ query_result_index : & mut EncodedQueryResultIndex )
842
+ -> Result < ( ) , E :: Error >
843
+ where Q : super :: plumbing:: GetCacheInternal < ' tcx > ,
844
+ E : ' x + TyEncoder ,
845
+ Q :: Value : Encodable ,
846
+ {
847
+ for ( key, entry) in Q :: get_cache_internal ( tcx) . map . iter ( ) {
848
+ if Q :: cache_on_disk ( key. clone ( ) ) {
849
+ let dep_node = SerializedDepNodeIndex :: new ( entry. index . index ( ) ) ;
850
+
851
+ // Record position of the cache entry
852
+ query_result_index. push ( ( dep_node, encoder. position ( ) ) ) ;
853
+
854
+ // Encode the type check tables with the SerializedDepNodeIndex
855
+ // as tag.
856
+ encoder. encode_tagged ( dep_node, & entry. value ) ?;
857
+ }
858
+ }
859
+
860
+ Ok ( ( ) )
861
+ }
0 commit comments