Skip to content

Commit d71b122

Browse files
committed
---
yaml --- r: 22444 b: refs/heads/master c: c0abd6a h: refs/heads/master v: v3
1 parent b63ad41 commit d71b122

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f3e874635fa4acb021947d482a7c3a32090e5910
2+
refs/heads/master: c0abd6a2eba72f0bde46abc33abcf361d45c376c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libsyntax/print/pprust.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,29 @@ fn print_item(s: ps, &&item: @ast::item) {
601601
for methods.each |meth| { print_ty_method(s, meth); }
602602
bclose(s, item.span);
603603
}
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"
606613
}
607614
}
608615
s.ann.post(ann_node);
609616
}
610617

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+
611627
fn print_variant(s: ps, v: ast::variant) {
612628
word(s.s, *v.node.name);
613629
if vec::len(v.node.args) > 0u {
@@ -822,6 +838,13 @@ fn print_mac(s: ps, m: ast::mac) {
822838
option::iter(arg, |a| print_expr(s, a));
823839
// FIXME: extension 'body' (#2339)
824840
}
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+
}
825848
ast::mac_embed_type(ty) {
826849
word(s.s, "#<");
827850
print_type(s, ty);

0 commit comments

Comments
 (0)