Skip to content

Commit 15e03e1

Browse files
paulstansifergraydon
authored andcommitted
Forbid attrs on macros, since we don't handle them properly yet.
1 parent 6174a30 commit 15e03e1

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,7 @@ impl Parser {
21972197
fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
21982198
// If we have attributes then we should have an item
21992199
if vec::is_not_empty(current_attrs) {
2200-
p.fatal(~"expected item");
2200+
p.fatal(~"expected item after attrs");
22012201
}
22022202
}
22032203
@@ -2210,6 +2210,9 @@ impl Parser {
22102210
} else if is_ident(self.token)
22112211
&& !self.is_any_keyword(copy self.token)
22122212
&& self.look_ahead(1) == token::NOT {
2213+
2214+
check_expected_item(self, first_item_attrs);
2215+
22132216
// Potential trouble: if we allow macros with paths instead of
22142217
// idents, we'd need to look ahead past the whole path here...
22152218
let pth = self.parse_value_path();
@@ -2381,7 +2384,7 @@ impl Parser {
23812384
}
23822385
}
23832386

2384-
stmt_mac(m, false) => {
2387+
stmt_mac(m, _) => {
23852388
// Statement macro; might be an expr
23862389
match self.token {
23872390
token::SEMI => {
@@ -3590,6 +3593,10 @@ impl Parser {
35903593
&& (is_plain_ident(self.look_ahead(2))
35913594
|| self.look_ahead(2) == token::LPAREN
35923595
|| self.look_ahead(2) == token::LBRACE) {
3596+
if attrs.len() > 0 {
3597+
self.fatal(~"attrs on macros are not yet supported");
3598+
}
3599+
35933600
// item macro.
35943601
let pth = self.parse_path_without_tps();
35953602
self.expect(token::NOT);

src/libsyntax/parse/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl ident_interner {
344344
}
345345
}
346346

347-
/** Key for thread-local data for sneaking interner information to the
347+
/* Key for thread-local data for sneaking interner information to the
348348
* serializer/deserializer. It sounds like a hack because it is one.
349349
* Bonus ultra-hack: functions as keys don't work across crates,
350350
* so we have to use a unique number. See taskgroup_key! in task.rs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fn main() {
22
#[attr]
3-
debug!("hi"); //~ ERROR expected item
3+
debug!("hi"); //~ ERROR expected item after attrs
44
}

src/test/compile-fail/ext-after-attrib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:expected item but found `fmt`
1+
// error-pattern:attrs on macros are not yet supported
22

33
// Don't know how to deal with a syntax extension appearing after an
44
// item attribute. Probably could use a better error message.

0 commit comments

Comments
 (0)