@@ -335,8 +335,8 @@ pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
335335 token:: NtLifetime ( e) => e. to_string ( ) ,
336336 token:: NtLiteral ( ref e) => expr_to_string ( e) ,
337337 token:: NtTT ( ref tree) => tt_to_string ( tree. clone ( ) ) ,
338- token :: NtImplItem ( ref e ) => impl_item_to_string ( e ) ,
339- token:: NtTraitItem ( ref e) => trait_item_to_string ( e) ,
338+ // FIXME(Centril): merge these variants.
339+ token:: NtImplItem ( ref e) | token :: NtTraitItem ( ref e ) => assoc_item_to_string ( e) ,
340340 token:: NtVis ( ref e) => vis_to_string ( e) ,
341341 token:: NtForeignItem ( ref e) => foreign_item_to_string ( e) ,
342342 }
@@ -374,12 +374,8 @@ pub fn item_to_string(i: &ast::Item) -> String {
374374 to_string ( |s| s. print_item ( i) )
375375}
376376
377- fn impl_item_to_string ( i : & ast:: ImplItem ) -> String {
378- to_string ( |s| s. print_impl_item ( i) )
379- }
380-
381- fn trait_item_to_string ( i : & ast:: TraitItem ) -> String {
382- to_string ( |s| s. print_trait_item ( i) )
377+ fn assoc_item_to_string ( i : & ast:: AssocItem ) -> String {
378+ to_string ( |s| s. print_assoc_item ( i) )
383379}
384380
385381pub fn generic_params_to_string ( generic_params : & [ ast:: GenericParam ] ) -> String {
@@ -1301,7 +1297,7 @@ impl<'a> State<'a> {
13011297 self . bopen ( ) ;
13021298 self . print_inner_attributes ( & item. attrs ) ;
13031299 for impl_item in impl_items {
1304- self . print_impl_item ( impl_item) ;
1300+ self . print_assoc_item ( impl_item) ;
13051301 }
13061302 self . bclose ( item. span ) ;
13071303 }
@@ -1328,7 +1324,7 @@ impl<'a> State<'a> {
13281324 self . s . word ( " " ) ;
13291325 self . bopen ( ) ;
13301326 for trait_item in trait_items {
1331- self . print_trait_item ( trait_item) ;
1327+ self . print_assoc_item ( trait_item) ;
13321328 }
13331329 self . bclose ( item. span ) ;
13341330 }
@@ -1522,89 +1518,39 @@ impl<'a> State<'a> {
15221518 }
15231519 }
15241520
1525- crate fn print_method_sig ( & mut self ,
1526- ident : ast:: Ident ,
1527- generics : & ast:: Generics ,
1528- m : & ast:: FnSig ,
1529- vis : & ast:: Visibility )
1530- {
1531- self . print_fn ( & m. decl ,
1532- m. header ,
1533- Some ( ident) ,
1534- & generics,
1535- vis)
1536- }
1537-
1538- crate fn print_trait_item ( & mut self , ti : & ast:: TraitItem )
1539- {
1540- self . ann . pre ( self , AnnNode :: SubItem ( ti. id ) ) ;
1521+ crate fn print_assoc_item ( & mut self , item : & ast:: AssocItem ) {
1522+ self . ann . pre ( self , AnnNode :: SubItem ( item. id ) ) ;
15411523 self . hardbreak_if_not_bol ( ) ;
1542- self . maybe_print_comment ( ti. span . lo ( ) ) ;
1543- self . print_outer_attributes ( & ti. attrs ) ;
1544- self . print_defaultness ( ti. defaultness ) ;
1545- match ti. kind {
1546- ast:: TraitItemKind :: Const ( ref ty, ref default) => {
1547- self . print_associated_const ( ti. ident , ty, default. as_deref ( ) , & ti. vis ) ;
1548- }
1549- ast:: TraitItemKind :: Method ( ref sig, ref body) => {
1550- if body. is_some ( ) {
1551- self . head ( "" ) ;
1552- }
1553- self . print_method_sig ( ti. ident , & ti. generics , sig, & ti. vis ) ;
1554- if let Some ( ref body) = * body {
1555- self . nbsp ( ) ;
1556- self . print_block_with_attrs ( body, & ti. attrs ) ;
1557- } else {
1558- self . s . word ( ";" ) ;
1559- }
1560- }
1561- ast:: TraitItemKind :: TyAlias ( ref bounds, ref default) => {
1562- self . print_associated_type ( ti. ident , bounds, default. as_deref ( ) ) ;
1563- }
1564- ast:: TraitItemKind :: Macro ( ref mac) => {
1565- self . print_mac ( mac) ;
1566- if mac. args . need_semicolon ( ) {
1567- self . s . word ( ";" ) ;
1568- }
1524+ self . maybe_print_comment ( item. span . lo ( ) ) ;
1525+ self . print_outer_attributes ( & item. attrs ) ;
1526+ self . print_defaultness ( item. defaultness ) ;
1527+ match & item. kind {
1528+ ast:: AssocItemKind :: Const ( ty, expr) => {
1529+ self . print_associated_const ( item. ident , ty, expr. as_deref ( ) , & item. vis ) ;
15691530 }
1570- }
1571- self . ann . post ( self , AnnNode :: SubItem ( ti. id ) )
1572- }
1573-
1574- // FIXME(Centril): merge with function above.
1575- crate fn print_impl_item ( & mut self , ii : & ast:: ImplItem ) {
1576- self . ann . pre ( self , AnnNode :: SubItem ( ii. id ) ) ;
1577- self . hardbreak_if_not_bol ( ) ;
1578- self . maybe_print_comment ( ii. span . lo ( ) ) ;
1579- self . print_outer_attributes ( & ii. attrs ) ;
1580- self . print_defaultness ( ii. defaultness ) ;
1581- match ii. kind {
1582- ast:: ImplItemKind :: Const ( ref ty, ref expr) => {
1583- self . print_associated_const ( ii. ident , ty, expr. as_deref ( ) , & ii. vis ) ;
1584- }
1585- ast:: ImplItemKind :: Method ( ref sig, ref body) => {
1531+ ast:: AssocItemKind :: Method ( sig, body) => {
15861532 if body. is_some ( ) {
15871533 self . head ( "" ) ;
15881534 }
1589- self . print_method_sig ( ii . ident , & ii . generics , sig , & ii . vis ) ;
1535+ self . print_fn ( & sig . decl , sig . header , Some ( item . ident ) , & item . generics , & item . vis ) ;
15901536 if let Some ( body) = body {
15911537 self . nbsp ( ) ;
1592- self . print_block_with_attrs ( body, & ii . attrs ) ;
1538+ self . print_block_with_attrs ( body, & item . attrs ) ;
15931539 } else {
15941540 self . s . word ( ";" ) ;
15951541 }
15961542 }
1597- ast:: ImplItemKind :: TyAlias ( ref bounds, ref ty) => {
1598- self . print_associated_type ( ii . ident , bounds, ty. as_deref ( ) ) ;
1543+ ast:: AssocItemKind :: TyAlias ( bounds, ty) => {
1544+ self . print_associated_type ( item . ident , bounds, ty. as_deref ( ) ) ;
15991545 }
1600- ast:: ImplItemKind :: Macro ( ref mac) => {
1546+ ast:: AssocItemKind :: Macro ( mac) => {
16011547 self . print_mac ( mac) ;
16021548 if mac. args . need_semicolon ( ) {
16031549 self . s . word ( ";" ) ;
16041550 }
16051551 }
16061552 }
1607- self . ann . post ( self , AnnNode :: SubItem ( ii . id ) )
1553+ self . ann . post ( self , AnnNode :: SubItem ( item . id ) )
16081554 }
16091555
16101556 crate fn print_stmt ( & mut self , st : & ast:: Stmt ) {
0 commit comments