@@ -703,6 +703,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
703
703
& mut self ,
704
704
path : & ast:: Path ,
705
705
has_bang : bool ,
706
+ ident : Option < ast:: Ident > ,
706
707
tts : TokenStream ,
707
708
delim : MacDelimiter ,
708
709
span : Span ,
@@ -711,6 +712,11 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
711
712
if has_bang {
712
713
self . word ( "!" ) ;
713
714
}
715
+ if let Some ( ident) = ident {
716
+ self . space ( ) ;
717
+ self . print_ident ( ident) ;
718
+ self . space ( ) ;
719
+ }
714
720
match delim {
715
721
MacDelimiter :: Parenthesis => self . popen ( ) ,
716
722
MacDelimiter :: Bracket => self . word ( "[" ) ,
@@ -1329,33 +1335,17 @@ impl<'a> State<'a> {
1329
1335
self . s . word ( ";" ) ;
1330
1336
}
1331
1337
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 ( ";" ) ,
1348
1342
}
1349
1343
}
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
+ ) ;
1359
1349
}
1360
1350
}
1361
1351
self . ann . post ( self , AnnNode :: Item ( item) )
@@ -1743,7 +1733,7 @@ impl<'a> State<'a> {
1743
1733
}
1744
1734
1745
1735
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 ) ;
1747
1737
}
1748
1738
1749
1739
0 commit comments