@@ -703,6 +703,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
703703 & mut self ,
704704 path : & ast:: Path ,
705705 has_bang : bool ,
706+ ident : Option < ast:: Ident > ,
706707 tts : TokenStream ,
707708 delim : MacDelimiter ,
708709 span : Span ,
@@ -711,6 +712,11 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
711712 if has_bang {
712713 self . word ( "!" ) ;
713714 }
715+ if let Some ( ident) = ident {
716+ self . space ( ) ;
717+ self . print_ident ( ident) ;
718+ self . space ( ) ;
719+ }
714720 match delim {
715721 MacDelimiter :: Parenthesis => self . popen ( ) ,
716722 MacDelimiter :: Bracket => self . word ( "[" ) ,
@@ -1329,33 +1335,17 @@ impl<'a> State<'a> {
13291335 self . s . word ( ";" ) ;
13301336 }
13311337 ast:: ItemKind :: Mac ( ref mac) => {
1332- if item. ident . name == kw:: Invalid {
1333- self . print_mac ( mac) ;
1334- match mac. node . delim {
1335- MacDelimiter :: Brace => { }
1336- _ => self . s . word ( ";" ) ,
1337- }
1338- } else {
1339- self . print_path ( & mac. node . path , false , 0 ) ;
1340- self . s . word ( "! " ) ;
1341- self . print_ident ( item. ident ) ;
1342- self . cbox ( INDENT_UNIT ) ;
1343- self . popen ( ) ;
1344- self . print_tts ( mac. node . stream ( ) , true ) ;
1345- self . pclose ( ) ;
1346- self . s . word ( ";" ) ;
1347- self . end ( ) ;
1338+ self . print_mac ( mac) ;
1339+ match mac. node . delim {
1340+ MacDelimiter :: Brace => { }
1341+ _ => self . s . word ( ";" ) ,
13481342 }
13491343 }
1350- ast:: ItemKind :: MacroDef ( ref tts) => {
1351- self . s . word ( "macro_rules! " ) ;
1352- self . print_ident ( item. ident ) ;
1353- self . cbox ( INDENT_UNIT ) ;
1354- self . popen ( ) ;
1355- self . print_tts ( tts. stream ( ) , true ) ;
1356- self . pclose ( ) ;
1357- self . s . word ( ";" ) ;
1358- self . end ( ) ;
1344+ ast:: ItemKind :: MacroDef ( ref macro_def) => {
1345+ let path = & ast:: Path :: from_ident ( ast:: Ident :: with_empty_ctxt ( sym:: macro_rules) ) ;
1346+ self . print_mac_common (
1347+ path, true , Some ( item. ident ) , macro_def. stream ( ) , MacDelimiter :: Brace , item. span
1348+ ) ;
13591349 }
13601350 }
13611351 self . ann . post ( self , AnnNode :: Item ( item) )
@@ -1743,7 +1733,7 @@ impl<'a> State<'a> {
17431733 }
17441734
17451735 crate fn print_mac ( & mut self , m : & ast:: Mac ) {
1746- self . print_mac_common ( & m. node . path , true , m. node . stream ( ) , m. node . delim , m. span ) ;
1736+ self . print_mac_common ( & m. node . path , true , None , m. node . stream ( ) , m. node . delim , m. span ) ;
17471737 }
17481738
17491739
0 commit comments