Skip to content

Commit c638e8a

Browse files
committed
---
yaml --- r: 82270 b: refs/heads/master c: 34d123d h: refs/heads/master v: v3
1 parent 47430f8 commit c638e8a

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-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: 2b978af227492b878a02b69300b3e7e3ce9ca7c5
2+
refs/heads/master: 34d123db4eb03c1b2378b6248ebea5f0f40f2a4f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
2020
use ext::tt::macro_parser::{parse, parse_or_else, success, failure};
2121
use parse::lexer::{new_tt_reader, reader};
2222
use parse::parser::Parser;
23+
use parse::attr::parser_attr;
2324
use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_str};
2425
use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt, EOF};
2526
use print;
@@ -54,12 +55,14 @@ impl AnyMacro for ParserAnyMacro {
5455
ret
5556
}
5657
fn make_item(&self) -> Option<@ast::item> {
57-
let ret = self.parser.parse_item(~[]); // no attrs
58+
let attrs = self.parser.parse_outer_attributes();
59+
let ret = self.parser.parse_item(attrs);
5860
self.ensure_complete_parse(false);
5961
ret
6062
}
6163
fn make_stmt(&self) -> @ast::Stmt {
62-
let ret = self.parser.parse_stmt(~[]); // no attrs
64+
let attrs = self.parser.parse_outer_attributes();
65+
let ret = self.parser.parse_stmt(attrs);
6366
self.ensure_complete_parse(true);
6467
ret
6568
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-pretty - token trees can't pretty print
12+
13+
#[feature(macro_rules)];
14+
15+
macro_rules! compiles_fine {
16+
($at:attr) => {
17+
// test that the different types of attributes work
18+
#[attribute]
19+
/// Documentation!
20+
$at
21+
22+
// check that the attributes are recognised by requiring this
23+
// to be removed to avoid a compile error
24+
#[cfg(always_remove)]
25+
static MISTYPED: () = "foo";
26+
}
27+
}
28+
29+
// item
30+
compiles_fine!(#[foo])
31+
32+
pub fn main() {
33+
// statement
34+
compiles_fine!(#[bar]);
35+
}

0 commit comments

Comments
 (0)