From 3466c9b4befd03fd39b099466b97fea92bb5109f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 15 Jan 2012 17:23:59 -0800 Subject: rustc: Parse fn inner attributes. Closes #1506 --- src/comp/syntax/print/pprust.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/comp/syntax/print/pprust.rs') diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index ea2404e849c..e0c1acc4fcc 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -366,7 +366,7 @@ fn print_item(s: ps, &&item: @ast::item) { ast::item_fn(decl, typarams, body) { print_fn(s, decl, item.ident, typarams); word(s.s, " "); - print_block(s, body); + print_block_with_attrs(s, body, item.attrs); } ast::item_mod(_mod) { head(s, "mod"); @@ -551,10 +551,20 @@ fn print_block(s: ps, blk: ast::blk) { print_possibly_embedded_block(s, blk, block_normal, indent_unit); } +fn print_block_with_attrs(s: ps, blk: ast::blk, attrs: [ast::attribute]) { + print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs); +} + tag embed_type { block_macro; block_block_fn; block_normal; } fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type, indented: uint) { + print_possibly_embedded_block_( + s, blk, embedded, indented, []); +} + +fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, + indented: uint, attrs: [ast::attribute]) { alt blk.node.rules { ast::unchecked_blk. { word(s.s, "unchecked"); } ast::unsafe_blk. { word(s.s, "unsafe"); } @@ -570,6 +580,8 @@ fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type, block_normal. { bopen(s); } } + print_inner_attributes(s, attrs); + for vi in blk.node.view_items { print_view_item(s, vi); } for st: @ast::stmt in blk.node.stmts { print_stmt(s, *st); -- cgit 1.4.1-3-g733a5