From 4e0822e2538bbff9d53c151adaf37ec1fe29de9e Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Wed, 9 Oct 2013 23:13:43 +1100 Subject: syntax: allow macros to expand to items with attributes. Fixes #4471. --- src/libsyntax/ext/tt/macro_rules.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index de0afe23668..343116df642 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -20,6 +20,7 @@ use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; use ext::tt::macro_parser::{parse, parse_or_else, success, failure}; use parse::lexer::{new_tt_reader, reader}; use parse::parser::Parser; +use parse::attr::parser_attr; use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_str}; use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt, EOF}; use print; @@ -54,12 +55,14 @@ impl AnyMacro for ParserAnyMacro { ret } fn make_item(&self) -> Option<@ast::item> { - let ret = self.parser.parse_item(~[]); // no attrs + let attrs = self.parser.parse_outer_attributes(); + let ret = self.parser.parse_item(attrs); self.ensure_complete_parse(false); ret } fn make_stmt(&self) -> @ast::Stmt { - let ret = self.parser.parse_stmt(~[]); // no attrs + let attrs = self.parser.parse_outer_attributes(); + let ret = self.parser.parse_stmt(attrs); self.ensure_complete_parse(true); ret } -- cgit 1.4.1-3-g733a5