@@ -360,7 +360,7 @@ fn token_to_string_ext(token: &Token, convert_dollar_crate: bool) -> String {
360
360
crate fn nonterminal_to_string ( nt : & Nonterminal ) -> String {
361
361
match * nt {
362
362
token:: NtExpr ( ref e) => expr_to_string ( e) ,
363
- token:: NtMeta ( ref e) => meta_item_to_string ( e) ,
363
+ token:: NtMeta ( ref e) => attr_item_to_string ( e) ,
364
364
token:: NtTy ( ref e) => ty_to_string ( e) ,
365
365
token:: NtPath ( ref e) => path_to_string ( e) ,
366
366
token:: NtItem ( ref e) => item_to_string ( e) ,
@@ -448,8 +448,8 @@ pub fn meta_list_item_to_string(li: &ast::NestedMetaItem) -> String {
448
448
to_string ( |s| s. print_meta_list_item ( li) )
449
449
}
450
450
451
- pub fn meta_item_to_string ( mi : & ast:: MetaItem ) -> String {
452
- to_string ( |s| s. print_meta_item ( mi ) )
451
+ fn attr_item_to_string ( ai : & ast:: AttrItem ) -> String {
452
+ to_string ( |s| s. print_attr_item ( ai , ai . path . span ) )
453
453
}
454
454
455
455
pub fn attribute_to_string ( attr : & ast:: Attribute ) -> String {
@@ -665,24 +665,28 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
665
665
ast:: AttrStyle :: Inner => self . word ( "#![" ) ,
666
666
ast:: AttrStyle :: Outer => self . word ( "#[" ) ,
667
667
}
668
- self . ibox ( 0 ) ;
669
- match attr. tokens . trees ( ) . next ( ) {
670
- Some ( TokenTree :: Delimited ( _, delim, tts) ) => {
671
- self . print_mac_common (
672
- Some ( MacHeader :: Path ( & attr. path ) ) , false , None , delim, tts, true , attr. span
673
- ) ;
674
- }
675
- tree => {
676
- self . print_path ( & attr. path , false , 0 ) ;
677
- if tree. is_some ( ) {
678
- self . space ( ) ;
679
- self . print_tts ( attr. tokens . clone ( ) , true ) ;
680
- }
668
+ self . print_attr_item ( & attr. item , attr. span ) ;
669
+ self . word ( "]" ) ;
670
+ }
671
+ }
672
+
673
+ fn print_attr_item ( & mut self , item : & ast:: AttrItem , span : Span ) {
674
+ self . ibox ( 0 ) ;
675
+ match item. tokens . trees ( ) . next ( ) {
676
+ Some ( TokenTree :: Delimited ( _, delim, tts) ) => {
677
+ self . print_mac_common (
678
+ Some ( MacHeader :: Path ( & item. path ) ) , false , None , delim, tts, true , span
679
+ ) ;
680
+ }
681
+ tree => {
682
+ self . print_path ( & item. path , false , 0 ) ;
683
+ if tree. is_some ( ) {
684
+ self . space ( ) ;
685
+ self . print_tts ( item. tokens . clone ( ) , true ) ;
681
686
}
682
687
}
683
- self . end ( ) ;
684
- self . word ( "]" ) ;
685
688
}
689
+ self . end ( ) ;
686
690
}
687
691
688
692
fn print_meta_list_item ( & mut self , item : & ast:: NestedMetaItem ) {
0 commit comments