@@ -4,7 +4,7 @@ use crate::ast::{Attribute, MacDelimiter, GenericArg};
4
4
use crate :: util:: parser:: { self , AssocOp , Fixity } ;
5
5
use crate :: attr;
6
6
use crate :: source_map:: { self , SourceMap , Spanned } ;
7
- use crate :: parse:: token:: { self , BinOpToken , Nonterminal , Token , TokenKind } ;
7
+ use crate :: parse:: token:: { self , BinOpToken , DelimToken , Nonterminal , Token , TokenKind } ;
8
8
use crate :: parse:: lexer:: comments;
9
9
use crate :: parse:: { self , ParseSess } ;
10
10
use crate :: print:: pp:: { self , Breaks } ;
@@ -619,9 +619,23 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
619
619
if let Some ( mi) = attr. meta ( ) {
620
620
self . print_meta_item ( & mi) ;
621
621
} else {
622
- self . print_path ( & attr. path , false , 0 ) ;
623
- self . space ( ) ;
624
- self . print_tts ( attr. tokens . clone ( ) , true ) ;
622
+ match attr. tokens . trees ( ) . next ( ) {
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 ) ;
630
+ }
631
+ tree => {
632
+ self . print_path ( & attr. path , false , 0 ) ;
633
+ if tree. is_some ( ) {
634
+ self . space ( ) ;
635
+ self . print_tts ( attr. tokens . clone ( ) , true ) ;
636
+ }
637
+ }
638
+ }
625
639
}
626
640
self . word ( "]" ) ;
627
641
}
0 commit comments