@@ -23,6 +23,7 @@ use metadata::tydecode;
23
23
use metadata:: tydecode:: { DefIdSource , NominalType , TypeWithId , TypeParameter } ;
24
24
use metadata:: tydecode:: { RegionParameter , ClosureSource } ;
25
25
use metadata:: tyencode;
26
+ use middle:: cast;
26
27
use middle:: check_const:: ConstQualif ;
27
28
use middle:: mem_categorization:: Typer ;
28
29
use middle:: privacy:: { AllPublic , LastMod } ;
@@ -688,6 +689,10 @@ pub fn encode_closure_kind(ebml_w: &mut Encoder, kind: ty::ClosureKind) {
688
689
kind. encode ( ebml_w) . unwrap ( ) ;
689
690
}
690
691
692
+ pub fn encode_cast_kind ( ebml_w : & mut Encoder , kind : cast:: CastKind ) {
693
+ kind. encode ( ebml_w) . unwrap ( ) ;
694
+ }
695
+
691
696
pub trait vtable_decoder_helpers < ' tcx > {
692
697
fn read_vec_per_param_space < T , F > ( & mut self , f : F ) -> VecPerParamSpace < T > where
693
698
F : FnMut ( & mut Self ) -> T ;
@@ -1248,6 +1253,13 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
1248
1253
} )
1249
1254
}
1250
1255
1256
+ if let Some ( cast_kind) = tcx. cast_kinds . borrow ( ) . get ( & id) {
1257
+ rbml_w. tag ( c:: tag_table_cast_kinds, |rbml_w| {
1258
+ rbml_w. id ( id) ;
1259
+ encode_cast_kind ( rbml_w, * cast_kind)
1260
+ } )
1261
+ }
1262
+
1251
1263
for & qualif in tcx. const_qualif_map . borrow ( ) . get ( & id) . iter ( ) {
1252
1264
rbml_w. tag ( c:: tag_table_const_qualif, |rbml_w| {
1253
1265
rbml_w. id ( id) ;
@@ -1289,6 +1301,8 @@ trait rbml_decoder_decoder_helpers<'tcx> {
1289
1301
-> subst:: Substs < ' tcx > ;
1290
1302
fn read_auto_adjustment < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1291
1303
-> ty:: AutoAdjustment < ' tcx > ;
1304
+ fn read_cast_kind < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1305
+ -> cast:: CastKind ;
1292
1306
fn read_closure_kind < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1293
1307
-> ty:: ClosureKind ;
1294
1308
fn read_closure_ty < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
@@ -1641,6 +1655,12 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
1641
1655
} ) . unwrap ( )
1642
1656
}
1643
1657
1658
+ fn read_cast_kind < ' b , ' c > ( & mut self , _dcx : & DecodeContext < ' b , ' c , ' tcx > )
1659
+ -> cast:: CastKind
1660
+ {
1661
+ Decodable :: decode ( self ) . unwrap ( )
1662
+ }
1663
+
1644
1664
fn read_closure_kind < ' b , ' c > ( & mut self , _dcx : & DecodeContext < ' b , ' c , ' tcx > )
1645
1665
-> ty:: ClosureKind
1646
1666
{
@@ -1801,6 +1821,11 @@ fn decode_side_tables(dcx: &DecodeContext,
1801
1821
dcx. tcx . closure_kinds . borrow_mut ( ) . insert ( ast_util:: local_def ( id) ,
1802
1822
closure_kind) ;
1803
1823
}
1824
+ c:: tag_table_cast_kinds => {
1825
+ let cast_kind =
1826
+ val_dsr. read_cast_kind ( dcx) ;
1827
+ dcx. tcx . cast_kinds . borrow_mut ( ) . insert ( id, cast_kind) ;
1828
+ }
1804
1829
c:: tag_table_const_qualif => {
1805
1830
let qualif: ConstQualif = Decodable :: decode ( val_dsr) . unwrap ( ) ;
1806
1831
dcx. tcx . const_qualif_map . borrow_mut ( ) . insert ( id, qualif) ;
0 commit comments