@@ -808,7 +808,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
808808 impl_path : PathElems ,
809809 is_default_impl : bool ,
810810 parent_id : NodeId ,
811- ast_item_opt : Option < & ast:: ImplItem > ) {
811+ impl_item_opt : Option < & ast:: ImplItem > ) {
812812
813813 debug ! ( "encode_info_for_method: {:?} {:?}" , m. def_id,
814814 token:: get_name( m. name) ) ;
@@ -826,21 +826,20 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
826826
827827 let elem = ast_map:: PathName ( m. name ) ;
828828 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 ) ;
832832 let scheme = ty:: lookup_item_type ( ecx. tcx , m. def_id ) ;
833833 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 ) {
835835 encode_inlined_item ( ecx, rbml_w, IIImplItemRef ( local_def ( parent_id) ,
836- ast_item_opt . unwrap ( ) ) ) ;
836+ impl_item ) ) ;
837837 }
838838 if !any_types {
839839 encode_symbol ( ecx, rbml_w, m. def_id . node ) ;
840840 }
841- encode_method_argument_names ( rbml_w, ast_method . pe_fn_decl ( ) ) ;
841+ encode_method_argument_names ( rbml_w, & sig . decl ) ;
842842 }
843- Some ( _) | None => { }
844843 }
845844
846845 rbml_w. end_tag ( ) ;
@@ -851,7 +850,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
851850 associated_type : & ty:: AssociatedType ,
852851 impl_path : PathElems ,
853852 parent_id : NodeId ,
854- typedef_opt : Option < P < ast:: Typedef > > ) {
853+ impl_item_opt : Option < & ast:: ImplItem > ) {
855854 debug ! ( "encode_info_for_associated_type({:?},{:?})" ,
856855 associated_type. def_id,
857856 token:: get_name( associated_type. name) ) ;
@@ -873,13 +872,9 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
873872 let elem = ast_map:: PathName ( associated_type. name ) ;
874873 encode_path ( rbml_w, impl_path. chain ( Some ( elem) . into_iter ( ) ) ) ;
875874
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 ) ) ;
883878 }
884879
885880 rbml_w. end_tag ( ) ;
@@ -1226,7 +1221,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
12261221 let num_implemented_methods = ast_items. len ( ) ;
12271222 for ( i, & trait_item_def_id) in items. iter ( ) . enumerate ( ) {
12281223 let ast_item = if i < num_implemented_methods {
1229- Some ( & ast_items[ i] )
1224+ Some ( & * ast_items[ i] )
12301225 } else {
12311226 None
12321227 } ;
@@ -1236,11 +1231,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
12361231 pos : rbml_w. mark_stable_position ( ) ,
12371232 } ) ;
12381233
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) => {
12441236 encode_info_for_method ( ecx,
12451237 rbml_w,
12461238 & * * method_type,
@@ -1249,31 +1241,13 @@ fn encode_info_for_item(ecx: &EncodeContext,
12491241 item. id ,
12501242 ast_item)
12511243 }
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) => {
12711245 encode_info_for_associated_type ( ecx,
12721246 rbml_w,
12731247 & * * associated_type,
12741248 path. clone ( ) ,
12751249 item. id ,
1276- None )
1250+ ast_item )
12771251 }
12781252 }
12791253 }
@@ -1387,35 +1361,29 @@ fn encode_info_for_item(ecx: &EncodeContext,
13871361
13881362 encode_parent_sort ( rbml_w, 't' ) ;
13891363
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+ }
14071376
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 ) ;
14141384 }
14151385
1416- & ast:: TypeTraitItem ( ref associated_type) => {
1417- encode_attributes ( rbml_w,
1418- & associated_type. attrs ) ;
1386+ ast:: TypeTraitItem ( ..) => {
14191387 encode_item_sort ( rbml_w, 't' ) ;
14201388 }
14211389 }
0 commit comments