@@ -621,12 +621,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
621
621
} else {
622
622
match attr. tokens . trees ( ) . next ( ) {
623
623
Some ( TokenTree :: Delimited ( _, delim, tts) ) => {
624
- let delim = match delim {
625
- DelimToken :: Brace => MacDelimiter :: Brace ,
626
- DelimToken :: Bracket => MacDelimiter :: Bracket ,
627
- DelimToken :: Paren | DelimToken :: NoDelim => MacDelimiter :: Parenthesis ,
628
- } ;
629
- self . print_mac_common ( & attr. path , false , None , tts, delim, attr. span ) ;
624
+ self . print_mac_common (
625
+ Some ( & attr. path ) , false , None , delim, tts, true , attr. span
626
+ ) ;
630
627
}
631
628
tree => {
632
629
self . print_path ( & attr. path , false , 0 ) ;
@@ -692,13 +689,11 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
692
689
_ => { }
693
690
}
694
691
}
695
- TokenTree :: Delimited ( _, delim, tts) => {
696
- self . word ( token_kind_to_string ( & token:: OpenDelim ( delim) ) ) ;
697
- self . space ( ) ;
698
- self . print_tts ( tts, convert_dollar_crate) ;
699
- self . space ( ) ;
700
- self . word ( token_kind_to_string ( & token:: CloseDelim ( delim) ) )
701
- } ,
692
+ TokenTree :: Delimited ( dspan, delim, tts) => {
693
+ self . print_mac_common (
694
+ None , false , None , delim, tts, convert_dollar_crate, dspan. entire ( )
695
+ ) ;
696
+ }
702
697
}
703
698
}
704
699
@@ -715,14 +710,17 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
715
710
716
711
fn print_mac_common (
717
712
& mut self ,
718
- path : & ast:: Path ,
713
+ path : Option < & ast:: Path > ,
719
714
has_bang : bool ,
720
715
ident : Option < ast:: Ident > ,
716
+ delim : DelimToken ,
721
717
tts : TokenStream ,
722
- delim : MacDelimiter ,
718
+ convert_dollar_crate : bool ,
723
719
span : Span ,
724
720
) {
725
- self . print_path ( path, false , 0 ) ;
721
+ if let Some ( path) = path {
722
+ self . print_path ( path, false , 0 ) ;
723
+ }
726
724
if has_bang {
727
725
self . word ( "!" ) ;
728
726
}
@@ -732,18 +730,20 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
732
730
self . space ( ) ;
733
731
}
734
732
match delim {
735
- MacDelimiter :: Parenthesis => self . popen ( ) ,
736
- MacDelimiter :: Bracket => self . word ( "[" ) ,
737
- MacDelimiter :: Brace => {
733
+ DelimToken :: Paren => self . popen ( ) ,
734
+ DelimToken :: Bracket => self . word ( "[" ) ,
735
+ DelimToken :: NoDelim => self . word ( " " ) ,
736
+ DelimToken :: Brace => {
738
737
self . head ( "" ) ;
739
738
self . bopen ( ) ;
740
739
}
741
740
}
742
- self . print_tts ( tts, true ) ;
741
+ self . print_tts ( tts, convert_dollar_crate ) ;
743
742
match delim {
744
- MacDelimiter :: Parenthesis => self . pclose ( ) ,
745
- MacDelimiter :: Bracket => self . word ( "]" ) ,
746
- MacDelimiter :: Brace => self . bclose ( span) ,
743
+ DelimToken :: Paren => self . pclose ( ) ,
744
+ DelimToken :: Bracket => self . word ( "]" ) ,
745
+ DelimToken :: NoDelim => self . word ( " " ) ,
746
+ DelimToken :: Brace => self . bclose ( span) ,
747
747
}
748
748
}
749
749
@@ -1356,9 +1356,14 @@ impl<'a> State<'a> {
1356
1356
}
1357
1357
}
1358
1358
ast:: ItemKind :: MacroDef ( ref macro_def) => {
1359
- let path = & ast:: Path :: from_ident ( ast:: Ident :: with_empty_ctxt ( sym:: macro_rules) ) ;
1360
1359
self . print_mac_common (
1361
- path, true , Some ( item. ident ) , macro_def. stream ( ) , MacDelimiter :: Brace , item. span
1360
+ Some ( & ast:: Path :: from_ident ( ast:: Ident :: with_empty_ctxt ( sym:: macro_rules) ) ) ,
1361
+ true ,
1362
+ Some ( item. ident ) ,
1363
+ DelimToken :: Brace ,
1364
+ macro_def. stream ( ) ,
1365
+ true ,
1366
+ item. span ,
1362
1367
) ;
1363
1368
}
1364
1369
}
@@ -1747,10 +1752,11 @@ impl<'a> State<'a> {
1747
1752
}
1748
1753
1749
1754
crate fn print_mac ( & mut self , m : & ast:: Mac ) {
1750
- self . print_mac_common ( & m. node . path , true , None , m. node . stream ( ) , m. node . delim , m. span ) ;
1755
+ self . print_mac_common (
1756
+ Some ( & m. node . path ) , true , None , m. node . delim . to_token ( ) , m. node . stream ( ) , true , m. span
1757
+ ) ;
1751
1758
}
1752
1759
1753
-
1754
1760
fn print_call_post ( & mut self , args : & [ P < ast:: Expr > ] ) {
1755
1761
self . popen ( ) ;
1756
1762
self . commasep_exprs ( Inconsistent , args) ;
0 commit comments