Allow attributes to appear as macro arguments

Fixes #8393
This commit is contained in:
Niko Matsakis
2013-08-08 13:28:06 -04:00
parent 8f65dbfcfa
commit 33c6d3fd78
7 changed files with 137 additions and 59 deletions

View File

@@ -105,6 +105,7 @@ pub enum nonterminal {
nt_expr(@ast::expr),
nt_ty( ast::Ty),
nt_ident(ast::ident, bool),
nt_attr(@ast::Attribute), // #[foo]
nt_path( ast::Path),
nt_tt( @ast::token_tree), //needs @ed to break a circularity
nt_matchers(~[ast::matcher])
@@ -205,6 +206,7 @@ pub fn to_str(input: @ident_interner, t: &Token) -> ~str {
INTERPOLATED(ref nt) => {
match nt {
&nt_expr(e) => ::print::pprust::expr_to_str(e, input),
&nt_attr(e) => ::print::pprust::attribute_to_str(e, input),
_ => {
~"an interpolated " +
match (*nt) {
@@ -212,6 +214,7 @@ pub fn to_str(input: @ident_interner, t: &Token) -> ~str {
nt_block(*) => ~"block",
nt_stmt(*) => ~"statement",
nt_pat(*) => ~"pattern",
nt_attr(*) => fail!("should have been handled"),
nt_expr(*) => fail!("should have been handled above"),
nt_ty(*) => ~"type",
nt_ident(*) => ~"identifier",