@@ -23,6 +23,7 @@ use metadata::tydecode;
2323use metadata:: tydecode:: { DefIdSource , NominalType , TypeWithId , TypeParameter } ;
2424use metadata:: tydecode:: { RegionParameter , ClosureSource } ;
2525use metadata:: tyencode;
26+ use middle:: cast;
2627use middle:: check_const:: ConstQualif ;
2728use middle:: mem_categorization:: Typer ;
2829use middle:: privacy:: { AllPublic , LastMod } ;
@@ -688,6 +689,10 @@ pub fn encode_closure_kind(ebml_w: &mut Encoder, kind: ty::ClosureKind) {
688689 kind. encode ( ebml_w) . unwrap ( ) ;
689690}
690691
692+ pub fn encode_cast_kind ( ebml_w : & mut Encoder , kind : cast:: CastKind ) {
693+ kind. encode ( ebml_w) . unwrap ( ) ;
694+ }
695+
691696pub trait vtable_decoder_helpers < ' tcx > {
692697 fn read_vec_per_param_space < T , F > ( & mut self , f : F ) -> VecPerParamSpace < T > where
693698 F : FnMut ( & mut Self ) -> T ;
@@ -1248,6 +1253,13 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12481253 } )
12491254 }
12501255
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+
12511263 for & qualif in tcx. const_qualif_map . borrow ( ) . get ( & id) . iter ( ) {
12521264 rbml_w. tag ( c:: tag_table_const_qualif, |rbml_w| {
12531265 rbml_w. id ( id) ;
@@ -1289,6 +1301,8 @@ trait rbml_decoder_decoder_helpers<'tcx> {
12891301 -> subst:: Substs < ' tcx > ;
12901302 fn read_auto_adjustment < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
12911303 -> ty:: AutoAdjustment < ' tcx > ;
1304+ fn read_cast_kind < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1305+ -> cast:: CastKind ;
12921306 fn read_closure_kind < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
12931307 -> ty:: ClosureKind ;
12941308 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> {
16411655 } ) . unwrap ( )
16421656 }
16431657
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+
16441664 fn read_closure_kind < ' b , ' c > ( & mut self , _dcx : & DecodeContext < ' b , ' c , ' tcx > )
16451665 -> ty:: ClosureKind
16461666 {
@@ -1801,6 +1821,11 @@ fn decode_side_tables(dcx: &DecodeContext,
18011821 dcx. tcx . closure_kinds . borrow_mut ( ) . insert ( ast_util:: local_def ( id) ,
18021822 closure_kind) ;
18031823 }
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+ }
18041829 c:: tag_table_const_qualif => {
18051830 let qualif: ConstQualif = Decodable :: decode ( val_dsr) . unwrap ( ) ;
18061831 dcx. tcx . const_qualif_map . borrow_mut ( ) . insert ( id, qualif) ;
0 commit comments