@@ -808,7 +808,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
808
808
impl_path : PathElems ,
809
809
is_default_impl : bool ,
810
810
parent_id : NodeId ,
811
- ast_item_opt : Option < & ast:: ImplItem > ) {
811
+ impl_item_opt : Option < & ast:: ImplItem > ) {
812
812
813
813
debug ! ( "encode_info_for_method: {:?} {:?}" , m. def_id,
814
814
token:: get_name( m. name) ) ;
@@ -826,21 +826,20 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
826
826
827
827
let elem = ast_map:: PathName ( m. name ) ;
828
828
encode_path ( rbml_w, impl_path. chain ( Some ( elem) . into_iter ( ) ) ) ;
829
- match ast_item_opt {
830
- Some ( & ast:: MethodImplItem ( ref ast_method ) ) => {
831
- encode_attributes ( rbml_w, & ast_method . attrs ) ;
829
+ if let Some ( impl_item ) = impl_item_opt {
830
+ if let ast:: MethodImplItem ( ref sig , _ ) = impl_item . node {
831
+ encode_attributes ( rbml_w, & impl_item . attrs ) ;
832
832
let scheme = ty:: lookup_item_type ( ecx. tcx , m. def_id ) ;
833
833
let any_types = !scheme. generics . types . is_empty ( ) ;
834
- if any_types || is_default_impl || attr:: requests_inline ( & ast_method . attrs ) {
834
+ if any_types || is_default_impl || attr:: requests_inline ( & impl_item . attrs ) {
835
835
encode_inlined_item ( ecx, rbml_w, IIImplItemRef ( local_def ( parent_id) ,
836
- ast_item_opt . unwrap ( ) ) ) ;
836
+ impl_item ) ) ;
837
837
}
838
838
if !any_types {
839
839
encode_symbol ( ecx, rbml_w, m. def_id . node ) ;
840
840
}
841
- encode_method_argument_names ( rbml_w, ast_method . pe_fn_decl ( ) ) ;
841
+ encode_method_argument_names ( rbml_w, & sig . decl ) ;
842
842
}
843
- Some ( _) | None => { }
844
843
}
845
844
846
845
rbml_w. end_tag ( ) ;
@@ -851,7 +850,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
851
850
associated_type : & ty:: AssociatedType ,
852
851
impl_path : PathElems ,
853
852
parent_id : NodeId ,
854
- typedef_opt : Option < P < ast:: Typedef > > ) {
853
+ impl_item_opt : Option < & ast:: ImplItem > ) {
855
854
debug ! ( "encode_info_for_associated_type({:?},{:?})" ,
856
855
associated_type. def_id,
857
856
token:: get_name( associated_type. name) ) ;
@@ -873,13 +872,9 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
873
872
let elem = ast_map:: PathName ( associated_type. name ) ;
874
873
encode_path ( rbml_w, impl_path. chain ( Some ( elem) . into_iter ( ) ) ) ;
875
874
876
- match typedef_opt {
877
- None => { }
878
- Some ( typedef) => {
879
- encode_attributes ( rbml_w, & typedef. attrs ) ;
880
- encode_type ( ecx, rbml_w, ty:: node_id_to_type ( ecx. tcx ,
881
- typedef. id ) ) ;
882
- }
875
+ if let Some ( ii) = impl_item_opt {
876
+ encode_attributes ( rbml_w, & ii. attrs ) ;
877
+ encode_type ( ecx, rbml_w, ty:: node_id_to_type ( ecx. tcx , ii. id ) ) ;
883
878
}
884
879
885
880
rbml_w. end_tag ( ) ;
@@ -1226,7 +1221,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
1226
1221
let num_implemented_methods = ast_items. len ( ) ;
1227
1222
for ( i, & trait_item_def_id) in items. iter ( ) . enumerate ( ) {
1228
1223
let ast_item = if i < num_implemented_methods {
1229
- Some ( & ast_items[ i] )
1224
+ Some ( & * ast_items[ i] )
1230
1225
} else {
1231
1226
None
1232
1227
} ;
@@ -1236,11 +1231,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
1236
1231
pos : rbml_w. mark_stable_position ( ) ,
1237
1232
} ) ;
1238
1233
1239
- let trait_item_type =
1240
- ty:: impl_or_trait_item ( tcx, trait_item_def_id. def_id ( ) ) ;
1241
- match ( trait_item_type, ast_item) {
1242
- ( ty:: MethodTraitItem ( ref method_type) ,
1243
- Some ( & ast:: MethodImplItem ( _) ) ) => {
1234
+ match ty:: impl_or_trait_item ( tcx, trait_item_def_id. def_id ( ) ) {
1235
+ ty:: MethodTraitItem ( ref method_type) => {
1244
1236
encode_info_for_method ( ecx,
1245
1237
rbml_w,
1246
1238
& * * method_type,
@@ -1249,31 +1241,13 @@ fn encode_info_for_item(ecx: &EncodeContext,
1249
1241
item. id ,
1250
1242
ast_item)
1251
1243
}
1252
- ( ty:: MethodTraitItem ( ref method_type) , _) => {
1253
- encode_info_for_method ( ecx,
1254
- rbml_w,
1255
- & * * method_type,
1256
- path. clone ( ) ,
1257
- false ,
1258
- item. id ,
1259
- None )
1260
- }
1261
- ( ty:: TypeTraitItem ( ref associated_type) ,
1262
- Some ( & ast:: TypeImplItem ( ref typedef) ) ) => {
1263
- encode_info_for_associated_type ( ecx,
1264
- rbml_w,
1265
- & * * associated_type,
1266
- path. clone ( ) ,
1267
- item. id ,
1268
- Some ( ( * typedef) . clone ( ) ) )
1269
- }
1270
- ( ty:: TypeTraitItem ( ref associated_type) , _) => {
1244
+ ty:: TypeTraitItem ( ref associated_type) => {
1271
1245
encode_info_for_associated_type ( ecx,
1272
1246
rbml_w,
1273
1247
& * * associated_type,
1274
1248
path. clone ( ) ,
1275
1249
item. id ,
1276
- None )
1250
+ ast_item )
1277
1251
}
1278
1252
}
1279
1253
}
@@ -1387,35 +1361,29 @@ fn encode_info_for_item(ecx: &EncodeContext,
1387
1361
1388
1362
encode_parent_sort ( rbml_w, 't' ) ;
1389
1363
1390
- let trait_item = & ms[ i] ;
1391
- let encode_trait_item = |rbml_w : & mut Encoder | {
1392
- // If this is a static method, we've already
1393
- // encoded this.
1394
- if is_nonstatic_method {
1395
- // FIXME: I feel like there is something funny
1396
- // going on.
1397
- encode_bounds_and_type_for_item ( rbml_w, ecx, item_def_id. def_id ( ) . local_id ( ) ) ;
1398
- }
1399
- } ;
1400
- match trait_item {
1401
- & ast:: RequiredMethod ( ref m) => {
1402
- encode_attributes ( rbml_w, & m. attrs ) ;
1403
- encode_trait_item ( rbml_w) ;
1404
- encode_item_sort ( rbml_w, 'r' ) ;
1405
- encode_method_argument_names ( rbml_w, & * m. decl ) ;
1406
- }
1364
+ let trait_item = & * ms[ i] ;
1365
+ encode_attributes ( rbml_w, & trait_item. attrs ) ;
1366
+ match trait_item. node {
1367
+ ast:: MethodTraitItem ( ref sig, ref body) => {
1368
+ // If this is a static method, we've already
1369
+ // encoded this.
1370
+ if is_nonstatic_method {
1371
+ // FIXME: I feel like there is something funny
1372
+ // going on.
1373
+ encode_bounds_and_type_for_item ( rbml_w, ecx,
1374
+ item_def_id. def_id ( ) . local_id ( ) ) ;
1375
+ }
1407
1376
1408
- & ast:: ProvidedMethod ( ref m) => {
1409
- encode_attributes ( rbml_w, & m. attrs ) ;
1410
- encode_trait_item ( rbml_w) ;
1411
- encode_item_sort ( rbml_w, 'p' ) ;
1412
- encode_inlined_item ( ecx, rbml_w, IITraitItemRef ( def_id, trait_item) ) ;
1413
- encode_method_argument_names ( rbml_w, & * m. pe_fn_decl ( ) ) ;
1377
+ if body. is_some ( ) {
1378
+ encode_item_sort ( rbml_w, 'p' ) ;
1379
+ encode_inlined_item ( ecx, rbml_w, IITraitItemRef ( def_id, trait_item) ) ;
1380
+ } else {
1381
+ encode_item_sort ( rbml_w, 'r' ) ;
1382
+ }
1383
+ encode_method_argument_names ( rbml_w, & sig. decl ) ;
1414
1384
}
1415
1385
1416
- & ast:: TypeTraitItem ( ref associated_type) => {
1417
- encode_attributes ( rbml_w,
1418
- & associated_type. attrs ) ;
1386
+ ast:: TypeTraitItem ( ..) => {
1419
1387
encode_item_sort ( rbml_w, 't' ) ;
1420
1388
}
1421
1389
}
0 commit comments