@@ -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 ast_method) = 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
841
encode_method_argument_names ( rbml_w, ast_method. pe_fn_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 < & 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,9 +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
- if let Some ( typedef ) = typedef_opt {
877
- encode_attributes ( rbml_w, & typedef . attrs ) ;
878
- encode_type ( ecx, rbml_w, ty:: node_id_to_type ( ecx. tcx , typedef . id ) ) ;
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 ) ) ;
879
878
}
880
879
881
880
rbml_w. end_tag ( ) ;
@@ -1232,11 +1231,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
1232
1231
pos : rbml_w. mark_stable_position ( ) ,
1233
1232
} ) ;
1234
1233
1235
- let trait_item_type =
1236
- ty:: impl_or_trait_item ( tcx, trait_item_def_id. def_id ( ) ) ;
1237
- match ( trait_item_type, ast_item) {
1238
- ( ty:: MethodTraitItem ( ref method_type) ,
1239
- Some ( & ast:: MethodImplItem ( _) ) ) => {
1234
+ match ty:: impl_or_trait_item ( tcx, trait_item_def_id. def_id ( ) ) {
1235
+ ty:: MethodTraitItem ( ref method_type) => {
1240
1236
encode_info_for_method ( ecx,
1241
1237
rbml_w,
1242
1238
& * * method_type,
@@ -1245,31 +1241,13 @@ fn encode_info_for_item(ecx: &EncodeContext,
1245
1241
item. id ,
1246
1242
ast_item)
1247
1243
}
1248
- ( ty:: MethodTraitItem ( ref method_type) , _) => {
1249
- encode_info_for_method ( ecx,
1250
- rbml_w,
1251
- & * * method_type,
1252
- path. clone ( ) ,
1253
- false ,
1254
- item. id ,
1255
- None )
1256
- }
1257
- ( ty:: TypeTraitItem ( ref associated_type) ,
1258
- Some ( & ast:: TypeImplItem ( ref typedef) ) ) => {
1259
- encode_info_for_associated_type ( ecx,
1260
- rbml_w,
1261
- & * * associated_type,
1262
- path. clone ( ) ,
1263
- item. id ,
1264
- Some ( typedef) )
1265
- }
1266
- ( ty:: TypeTraitItem ( ref associated_type) , _) => {
1244
+ ty:: TypeTraitItem ( ref associated_type) => {
1267
1245
encode_info_for_associated_type ( ecx,
1268
1246
rbml_w,
1269
1247
& * * associated_type,
1270
1248
path. clone ( ) ,
1271
1249
item. id ,
1272
- None )
1250
+ ast_item )
1273
1251
}
1274
1252
}
1275
1253
}
@@ -1393,25 +1371,22 @@ fn encode_info_for_item(ecx: &EncodeContext,
1393
1371
encode_bounds_and_type_for_item ( rbml_w, ecx, item_def_id. def_id ( ) . local_id ( ) ) ;
1394
1372
}
1395
1373
} ;
1396
- match * trait_item {
1374
+ encode_attributes ( rbml_w, & trait_item. attrs ) ;
1375
+ match trait_item. node {
1397
1376
ast:: RequiredMethod ( ref m) => {
1398
- encode_attributes ( rbml_w, & m. attrs ) ;
1399
1377
encode_trait_item ( rbml_w) ;
1400
1378
encode_item_sort ( rbml_w, 'r' ) ;
1401
1379
encode_method_argument_names ( rbml_w, & * m. decl ) ;
1402
1380
}
1403
1381
1404
1382
ast:: ProvidedMethod ( ref m) => {
1405
- encode_attributes ( rbml_w, & m. attrs ) ;
1406
1383
encode_trait_item ( rbml_w) ;
1407
1384
encode_item_sort ( rbml_w, 'p' ) ;
1408
1385
encode_inlined_item ( ecx, rbml_w, IITraitItemRef ( def_id, trait_item) ) ;
1409
1386
encode_method_argument_names ( rbml_w, & * m. pe_fn_decl ( ) ) ;
1410
1387
}
1411
1388
1412
- ast:: TypeTraitItem ( ref associated_type) => {
1413
- encode_attributes ( rbml_w,
1414
- & associated_type. attrs ) ;
1389
+ ast:: TypeTraitItem ( ..) => {
1415
1390
encode_item_sort ( rbml_w, 't' ) ;
1416
1391
}
1417
1392
}
0 commit comments