@@ -4,7 +4,7 @@ use crate::ast::{Attribute, MacDelimiter, GenericArg};
44use crate :: util:: parser:: { self , AssocOp , Fixity } ;
55use crate :: attr;
66use 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 } ;
88use crate :: parse:: lexer:: comments;
99use crate :: parse:: { self , ParseSess } ;
1010use crate :: print:: pp:: { self , Breaks } ;
@@ -619,9 +619,23 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
619619 if let Some ( mi) = attr. meta ( ) {
620620 self . print_meta_item ( & mi) ;
621621 } 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+ }
625639 }
626640 self . word ( "]" ) ;
627641 }
0 commit comments