@@ -15,6 +15,7 @@ use hir::def_id::{CrateNum, DefIndex, DefId, LocalDefId,
15
15
RESERVED_FOR_INCR_COMP_CACHE , LOCAL_CRATE } ;
16
16
use hir:: map:: definitions:: DefPathHash ;
17
17
use middle:: cstore:: CrateStore ;
18
+ use mir;
18
19
use rustc_data_structures:: fx:: FxHashMap ;
19
20
use rustc_data_structures:: indexed_vec:: { IndexVec , Idx } ;
20
21
use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder , opaque,
@@ -36,6 +37,9 @@ use ty::context::TyCtxt;
36
37
const PREV_DIAGNOSTICS_TAG : u64 = 0x1234_5678_A1A1_A1A1 ;
37
38
const QUERY_RESULT_INDEX_TAG : u64 = 0x1234_5678_C3C3_C3C3 ;
38
39
40
+ const TAG_CLEAR_CROSS_CRATE_CLEAR : u8 = 0 ;
41
+ const TAG_CLEAR_CROSS_CRATE_SET : u8 = 1 ;
42
+
39
43
/// `OnDiskCache` provides an interface to incr. comp. data cached from the
40
44
/// previous compilation session. This data will eventually include the results
41
45
/// of a few selected queries (like `typeck_tables_of` and `mir_optimized`) and
@@ -518,12 +522,32 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<hir::HirId> for CacheDecoder<'a, 'tcx, 'x>
518
522
// NodeIds are not stable across compilation sessions, so we store them in their
519
523
// HirId representation. This allows use to map them to the current NodeId.
520
524
impl < ' a , ' tcx , ' x > SpecializedDecoder < NodeId > for CacheDecoder < ' a , ' tcx , ' x > {
525
+ #[ inline]
521
526
fn specialized_decode ( & mut self ) -> Result < NodeId , Self :: Error > {
522
527
let hir_id = hir:: HirId :: decode ( self ) ?;
523
528
Ok ( self . tcx ( ) . hir . hir_to_node_id ( hir_id) )
524
529
}
525
530
}
526
531
532
+ impl < ' a , ' tcx , ' x , T : Decodable > SpecializedDecoder < mir:: ClearCrossCrate < T > >
533
+ for CacheDecoder < ' a , ' tcx , ' x > {
534
+ #[ inline]
535
+ fn specialized_decode ( & mut self ) -> Result < mir:: ClearCrossCrate < T > , Self :: Error > {
536
+ let discr = u8:: decode ( self ) ?;
537
+
538
+ match discr {
539
+ TAG_CLEAR_CROSS_CRATE_CLEAR => Ok ( mir:: ClearCrossCrate :: Clear ) ,
540
+ TAG_CLEAR_CROSS_CRATE_SET => {
541
+ let val = T :: decode ( self ) ?;
542
+ Ok ( mir:: ClearCrossCrate :: Set ( val) )
543
+ }
544
+ _ => {
545
+ unreachable ! ( )
546
+ }
547
+ }
548
+ }
549
+ }
550
+
527
551
//- ENCODING -------------------------------------------------------------------
528
552
529
553
struct CacheEncoder < ' enc , ' a , ' tcx , E >
@@ -658,6 +682,27 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'enc, 'a, 't
658
682
}
659
683
}
660
684
685
+ impl < ' enc , ' a , ' tcx , E , T > SpecializedEncoder < mir:: ClearCrossCrate < T > >
686
+ for CacheEncoder < ' enc , ' a , ' tcx , E >
687
+ where E : ' enc + ty_codec:: TyEncoder ,
688
+ T : Encodable ,
689
+ {
690
+ #[ inline]
691
+ fn specialized_encode ( & mut self ,
692
+ val : & mir:: ClearCrossCrate < T > )
693
+ -> Result < ( ) , Self :: Error > {
694
+ match * val {
695
+ mir:: ClearCrossCrate :: Clear => {
696
+ TAG_CLEAR_CROSS_CRATE_CLEAR . encode ( self )
697
+ }
698
+ mir:: ClearCrossCrate :: Set ( ref val) => {
699
+ TAG_CLEAR_CROSS_CRATE_SET . encode ( self ) ?;
700
+ val. encode ( self )
701
+ }
702
+ }
703
+ }
704
+ }
705
+
661
706
macro_rules! encoder_methods {
662
707
( $( $name: ident( $ty: ty) ; ) * ) => {
663
708
$( fn $name( & mut self , value: $ty) -> Result <( ) , Self :: Error > {
0 commit comments