@@ -29,7 +29,7 @@ use middle::check_const::ConstQualif;
29
29
use middle:: privacy:: { AllPublic , LastMod } ;
30
30
use middle:: subst;
31
31
use middle:: subst:: VecPerParamSpace ;
32
- use middle:: ty:: { self , Ty , MethodCall , MethodCallee , MethodOrigin } ;
32
+ use middle:: ty:: { self , Ty } ;
33
33
34
34
use syntax:: { ast, ast_util, codemap, fold} ;
35
35
use syntax:: codemap:: Span ;
@@ -600,21 +600,21 @@ impl tr for ty::UpvarCapture {
600
600
601
601
trait read_method_callee_helper < ' tcx > {
602
602
fn read_method_callee < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
603
- -> ( u32 , MethodCallee < ' tcx > ) ;
603
+ -> ( u32 , ty :: MethodCallee < ' tcx > ) ;
604
604
}
605
605
606
606
fn encode_method_callee < ' a , ' tcx > ( ecx : & e:: EncodeContext < ' a , ' tcx > ,
607
607
rbml_w : & mut Encoder ,
608
608
autoderef : u32 ,
609
- method : & MethodCallee < ' tcx > ) {
609
+ method : & ty :: MethodCallee < ' tcx > ) {
610
610
use serialize:: Encoder ;
611
611
612
612
rbml_w. emit_struct ( "MethodCallee" , 4 , |rbml_w| {
613
613
rbml_w. emit_struct_field ( "autoderef" , 0 , |rbml_w| {
614
614
autoderef. encode ( rbml_w)
615
615
} ) ;
616
- rbml_w. emit_struct_field ( "origin " , 1 , |rbml_w| {
617
- Ok ( rbml_w. emit_method_origin ( ecx , & method. origin ) )
616
+ rbml_w. emit_struct_field ( "def_id " , 1 , |rbml_w| {
617
+ Ok ( rbml_w. emit_def_id ( method. def_id ) )
618
618
} ) ;
619
619
rbml_w. emit_struct_field ( "ty" , 2 , |rbml_w| {
620
620
Ok ( rbml_w. emit_ty ( ecx, method. ty ) )
@@ -627,21 +627,20 @@ fn encode_method_callee<'a, 'tcx>(ecx: &e::EncodeContext<'a, 'tcx>,
627
627
628
628
impl < ' a , ' tcx > read_method_callee_helper < ' tcx > for reader:: Decoder < ' a > {
629
629
fn read_method_callee < ' b , ' c > ( & mut self , dcx : & DecodeContext < ' b , ' c , ' tcx > )
630
- -> ( u32 , MethodCallee < ' tcx > ) {
630
+ -> ( u32 , ty :: MethodCallee < ' tcx > ) {
631
631
632
632
self . read_struct ( "MethodCallee" , 4 , |this| {
633
- let autoderef = this. read_struct_field ( "autoderef" , 0 , |this| {
634
- Decodable :: decode ( this)
635
- } ) . unwrap ( ) ;
636
- Ok ( ( autoderef, MethodCallee {
637
- origin : this. read_struct_field ( "origin" , 1 , |this| {
638
- Ok ( this. read_method_origin ( dcx) )
633
+ let autoderef = this. read_struct_field ( "autoderef" , 0 ,
634
+ Decodable :: decode) . unwrap ( ) ;
635
+ Ok ( ( autoderef, ty:: MethodCallee {
636
+ def_id : this. read_struct_field ( "def_id" , 1 , |this| {
637
+ Ok ( this. read_def_id ( dcx) )
639
638
} ) . unwrap ( ) ,
640
639
ty : this. read_struct_field ( "ty" , 2 , |this| {
641
640
Ok ( this. read_ty ( dcx) )
642
641
} ) . unwrap ( ) ,
643
642
substs : this. read_struct_field ( "substs" , 3 , |this| {
644
- Ok ( this. read_substs ( dcx) )
643
+ Ok ( dcx . tcx . mk_substs ( this. read_substs ( dcx) ) )
645
644
} ) . unwrap ( )
646
645
} ) )
647
646
} ) . unwrap ( )
@@ -707,9 +706,6 @@ impl<'a, 'tcx> get_ty_str_ctxt<'tcx> for e::EncodeContext<'a, 'tcx> {
707
706
trait rbml_writer_helpers < ' tcx > {
708
707
fn emit_closure_type < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
709
708
closure_type : & ty:: ClosureTy < ' tcx > ) ;
710
- fn emit_method_origin < ' a > ( & mut self ,
711
- ecx : & e:: EncodeContext < ' a , ' tcx > ,
712
- method_origin : & ty:: MethodOrigin < ' tcx > ) ;
713
709
fn emit_ty < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > , ty : Ty < ' tcx > ) ;
714
710
fn emit_tys < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > , tys : & [ Ty < ' tcx > ] ) ;
715
711
fn emit_type_param_def < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
@@ -741,73 +737,6 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
741
737
} ) ;
742
738
}
743
739
744
- fn emit_method_origin < ' b > ( & mut self ,
745
- ecx : & e:: EncodeContext < ' b , ' tcx > ,
746
- method_origin : & ty:: MethodOrigin < ' tcx > )
747
- {
748
- use serialize:: Encoder ;
749
-
750
- self . emit_enum ( "MethodOrigin" , |this| {
751
- match * method_origin {
752
- ty:: MethodStatic ( def_id) => {
753
- this. emit_enum_variant ( "MethodStatic" , 0 , 1 , |this| {
754
- Ok ( this. emit_def_id ( def_id) )
755
- } )
756
- }
757
-
758
- ty:: MethodStaticClosure ( def_id) => {
759
- this. emit_enum_variant ( "MethodStaticClosure" , 1 , 1 , |this| {
760
- Ok ( this. emit_def_id ( def_id) )
761
- } )
762
- }
763
-
764
- ty:: MethodTypeParam ( ref p) => {
765
- this. emit_enum_variant ( "MethodTypeParam" , 2 , 1 , |this| {
766
- this. emit_struct ( "MethodParam" , 2 , |this| {
767
- try!( this. emit_struct_field ( "trait_ref" , 0 , |this| {
768
- Ok ( this. emit_trait_ref ( ecx, & p. trait_ref ) )
769
- } ) ) ;
770
- try!( this. emit_struct_field ( "method_num" , 0 , |this| {
771
- this. emit_uint ( p. method_num )
772
- } ) ) ;
773
- try!( this. emit_struct_field ( "impl_def_id" , 0 , |this| {
774
- this. emit_option ( |this| {
775
- match p. impl_def_id {
776
- None => this. emit_option_none ( ) ,
777
- Some ( did) => this. emit_option_some ( |this| {
778
- Ok ( this. emit_def_id ( did) )
779
- } )
780
- }
781
- } )
782
- } ) ) ;
783
- Ok ( ( ) )
784
- } )
785
- } )
786
- }
787
-
788
- ty:: MethodTraitObject ( ref o) => {
789
- this. emit_enum_variant ( "MethodTraitObject" , 3 , 1 , |this| {
790
- this. emit_struct ( "MethodObject" , 2 , |this| {
791
- try!( this. emit_struct_field ( "trait_ref" , 0 , |this| {
792
- Ok ( this. emit_trait_ref ( ecx, & o. trait_ref ) )
793
- } ) ) ;
794
- try!( this. emit_struct_field ( "object_trait_id" , 0 , |this| {
795
- Ok ( this. emit_def_id ( o. object_trait_id ) )
796
- } ) ) ;
797
- try!( this. emit_struct_field ( "method_num" , 0 , |this| {
798
- this. emit_uint ( o. method_num )
799
- } ) ) ;
800
- try!( this. emit_struct_field ( "vtable_index" , 0 , |this| {
801
- this. emit_uint ( o. vtable_index )
802
- } ) ) ;
803
- Ok ( ( ) )
804
- } )
805
- } )
806
- }
807
- }
808
- } ) ;
809
- }
810
-
811
740
fn emit_ty < ' b > ( & mut self , ecx : & e:: EncodeContext < ' b , ' tcx > , ty : Ty < ' tcx > ) {
812
741
self . emit_opaque ( |this| Ok ( e:: write_type ( ecx, this, ty) ) ) ;
813
742
}
@@ -1077,7 +1006,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
1077
1006
} )
1078
1007
}
1079
1008
1080
- let method_call = MethodCall :: expr ( id) ;
1009
+ let method_call = ty :: MethodCall :: expr ( id) ;
1081
1010
if let Some ( method) = tcx. tables . borrow ( ) . method_map . get ( & method_call) {
1082
1011
rbml_w. tag ( c:: tag_table_method_map, |rbml_w| {
1083
1012
rbml_w. id ( id) ;
@@ -1089,7 +1018,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
1089
1018
match * adjustment {
1090
1019
ty:: AdjustDerefRef ( ref adj) => {
1091
1020
for autoderef in 0 ..adj. autoderefs {
1092
- let method_call = MethodCall :: autoderef ( id, autoderef as u32 ) ;
1021
+ let method_call = ty :: MethodCall :: autoderef ( id, autoderef as u32 ) ;
1093
1022
if let Some ( method) = tcx. tables . borrow ( ) . method_map . get ( & method_call) {
1094
1023
rbml_w. tag ( c:: tag_table_method_map, |rbml_w| {
1095
1024
rbml_w. id ( id) ;
@@ -1150,8 +1079,6 @@ impl<'a> doc_decoder_helpers for rbml::Doc<'a> {
1150
1079
}
1151
1080
1152
1081
trait rbml_decoder_decoder_helpers < ' tcx > {
1153
- fn read_method_origin < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1154
- -> ty:: MethodOrigin < ' tcx > ;
1155
1082
fn read_ty < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > ) -> Ty < ' tcx > ;
1156
1083
fn read_tys < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > ) -> Vec < Ty < ' tcx > > ;
1157
1084
fn read_trait_ref < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
@@ -1235,88 +1162,6 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
1235
1162
} ) . unwrap ( )
1236
1163
}
1237
1164
1238
- fn read_method_origin < ' b , ' c > ( & mut self , dcx : & DecodeContext < ' b , ' c , ' tcx > )
1239
- -> ty:: MethodOrigin < ' tcx >
1240
- {
1241
- self . read_enum ( "MethodOrigin" , |this| {
1242
- let variants = & [ "MethodStatic" , "MethodStaticClosure" ,
1243
- "MethodTypeParam" , "MethodTraitObject" ] ;
1244
- this. read_enum_variant ( variants, |this, i| {
1245
- Ok ( match i {
1246
- 0 => {
1247
- let def_id = this. read_def_id ( dcx) ;
1248
- ty:: MethodStatic ( def_id)
1249
- }
1250
-
1251
- 1 => {
1252
- let def_id = this. read_def_id ( dcx) ;
1253
- ty:: MethodStaticClosure ( def_id)
1254
- }
1255
-
1256
- 2 => {
1257
- this. read_struct ( "MethodTypeParam" , 2 , |this| {
1258
- Ok ( ty:: MethodTypeParam (
1259
- ty:: MethodParam {
1260
- trait_ref : {
1261
- this. read_struct_field ( "trait_ref" , 0 , |this| {
1262
- Ok ( this. read_trait_ref ( dcx) )
1263
- } ) . unwrap ( )
1264
- } ,
1265
- method_num : {
1266
- this. read_struct_field ( "method_num" , 1 , |this| {
1267
- this. read_uint ( )
1268
- } ) . unwrap ( )
1269
- } ,
1270
- impl_def_id : {
1271
- this. read_struct_field ( "impl_def_id" , 2 , |this| {
1272
- this. read_option ( |this, b| {
1273
- if b {
1274
- Ok ( Some ( this. read_def_id ( dcx) ) )
1275
- } else {
1276
- Ok ( None )
1277
- }
1278
- } )
1279
- } ) . unwrap ( )
1280
- }
1281
- } ) )
1282
- } ) . unwrap ( )
1283
- }
1284
-
1285
- 3 => {
1286
- this. read_struct ( "MethodTraitObject" , 2 , |this| {
1287
- Ok ( ty:: MethodTraitObject (
1288
- ty:: MethodObject {
1289
- trait_ref : {
1290
- this. read_struct_field ( "trait_ref" , 0 , |this| {
1291
- Ok ( this. read_trait_ref ( dcx) )
1292
- } ) . unwrap ( )
1293
- } ,
1294
- object_trait_id : {
1295
- this. read_struct_field ( "object_trait_id" , 1 , |this| {
1296
- Ok ( this. read_def_id ( dcx) )
1297
- } ) . unwrap ( )
1298
- } ,
1299
- method_num : {
1300
- this. read_struct_field ( "method_num" , 2 , |this| {
1301
- this. read_uint ( )
1302
- } ) . unwrap ( )
1303
- } ,
1304
- vtable_index : {
1305
- this. read_struct_field ( "vtable_index" , 3 , |this| {
1306
- this. read_uint ( )
1307
- } ) . unwrap ( )
1308
- } ,
1309
- } ) )
1310
- } ) . unwrap ( )
1311
- }
1312
-
1313
- _ => panic ! ( ".." )
1314
- } )
1315
- } )
1316
- } ) . unwrap ( )
1317
- }
1318
-
1319
-
1320
1165
fn read_ty < ' b , ' c > ( & mut self , dcx : & DecodeContext < ' b , ' c , ' tcx > ) -> Ty < ' tcx > {
1321
1166
// Note: regions types embed local node ids. In principle, we
1322
1167
// should translate these node ids into the new decode
@@ -1663,7 +1508,7 @@ fn decode_side_tables(dcx: &DecodeContext,
1663
1508
}
1664
1509
c:: tag_table_method_map => {
1665
1510
let ( autoderef, method) = val_dsr. read_method_callee ( dcx) ;
1666
- let method_call = MethodCall {
1511
+ let method_call = ty :: MethodCall {
1667
1512
expr_id : id,
1668
1513
autoderef : autoderef
1669
1514
} ;
0 commit comments