@@ -32,6 +32,7 @@ use syntax_pos::{BytePos, Span, NO_EXPANSION, DUMMY_SP};
3232use ty;
3333use ty:: codec:: { self as ty_codec, TyDecoder , TyEncoder } ;
3434use ty:: context:: TyCtxt ;
35+ use ty:: maps:: config:: QueryDescription ;
3536use ty:: subst:: Substs ;
3637
3738// Some magic values used for verifying that encoding and decoding. These are
@@ -229,9 +230,22 @@ impl<'sess> OnDiskCache<'sess> {
229230
230231
231232 // Encode query results
232- let query_result_index = EncodedQueryResultIndex :: new ( ) ;
233- // ... we don't encode anything yet, actually
233+ let mut query_result_index = EncodedQueryResultIndex :: new ( ) ;
234234
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 ( ) ) ;
239+
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+ }
248+ }
235249
236250 // Encode query result index
237251 let query_result_index_pos = encoder. position ( ) as u64 ;
@@ -522,9 +536,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
522536
523537impl < ' a , ' tcx , ' x > SpecializedDecoder < CrateNum > for CacheDecoder < ' a , ' tcx , ' x > {
524538 fn specialized_decode ( & mut self ) -> Result < CrateNum , Self :: Error > {
525- let cnum = CrateNum :: from_u32 ( u32:: decode ( self ) ?) ;
526- let mapped = self . map_encoded_cnum_to_current ( cnum) ;
527- Ok ( mapped)
539+ ty_codec:: decode_cnum ( self )
528540 }
529541}
530542
@@ -576,6 +588,8 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<hir::HirId> for CacheDecoder<'a, 'tcx, 'x>
576588 . as_ref ( )
577589 . unwrap ( ) [ & def_path_hash] ;
578590
591+ debug_assert ! ( def_id. is_local( ) ) ;
592+
579593 // The ItemLocalId needs no remapping.
580594 let local_id = hir:: ItemLocalId :: decode ( self ) ?;
581595
@@ -721,6 +735,20 @@ impl<'enc, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
721735 }
722736}
723737
738+ impl < ' enc , ' tcx , E > SpecializedEncoder < hir:: HirId > for CacheEncoder < ' enc , ' tcx , E >
739+ where E : ' enc + ty_codec:: TyEncoder
740+ {
741+ fn specialized_encode ( & mut self , id : & hir:: HirId ) -> Result < ( ) , Self :: Error > {
742+ let hir:: HirId {
743+ owner,
744+ local_id,
745+ } = * id;
746+
747+ owner. encode ( self ) ?;
748+ local_id. encode ( self )
749+ }
750+ }
751+
724752// NodeIds are not stable across compilation sessions, so we store them in their
725753// HirId representation. This allows use to map them to the current NodeId.
726754impl < ' enc , ' tcx , E > SpecializedEncoder < NodeId > for CacheEncoder < ' enc , ' tcx , E >
0 commit comments