@@ -601,13 +601,29 @@ fn print_item(s: ps, &&item: @ast::item) {
601
601
for methods. each |meth| { print_ty_method( s, meth) ; }
602
602
bclose( s, item. span) ;
603
603
}
604
- ast:: item_mac( _m) {
605
- fail "item macros unimplemented"
604
+ ast:: item_mac( { node: ast:: mac_invoc_tt( pth, tts) , _} ) {
605
+
606
+ word( s. s, * item. ident) ;
607
+ bopen( s) ;
608
+ for tts. each |tt| { print_tt( s, tt) ; }
609
+ bclose( s, item. span) ;
610
+ }
611
+ ast:: item_mac( _) {
612
+ fail "invalid item-position syntax bit"
606
613
}
607
614
}
608
615
s. ann. post( ann_node) ;
609
616
}
610
617
618
+ /// Unimplemented because ident tokens lose their meaning without the interner
619
+ /// present. Fixing that would make invoking the pretty printer painful.
620
+ /// If this did work, the naive way of implementing it would be really ugly.
621
+ /// A prettier option would involve scraping the macro grammar for formatting
622
+ /// advice. But that would be hard.
623
+ fn print_tt( _s: ps, _tt: ast:: token_tree) {
624
+ fail "token trees cannot be pretty-printed"
625
+ }
626
+
611
627
fn print_variant( s: ps, v: ast:: variant) {
612
628
word( s. s, * v. node. name) ;
613
629
if vec:: len( v. node. args) > 0 u {
@@ -822,6 +838,13 @@ fn print_mac(s: ps, m: ast::mac) {
822
838
option:: iter ( arg, |a| print_expr ( s, a) ) ;
823
839
// FIXME: extension 'body' (#2339)
824
840
}
841
+ ast:: mac_invoc_tt ( path, tts) {
842
+ print_path ( s, path, false ) ;
843
+ word ( s. s , "!" ) ;
844
+ bopen ( s) ;
845
+ for tts. each( ) |tt| { print_tt( s, tt) ; }
846
+ bclose( s, m. span) ;
847
+ }
825
848
ast:: mac_embed_type( ty) {
826
849
word( s. s, "#<" ) ;
827
850
print_type( s, ty) ;
0 commit comments