about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Stansifer <paul.stansifer@gmail.com>2012-11-21 22:38:27 -0500
committerGraydon Hoare <graydon@mozilla.com>2012-11-29 12:09:11 -0800
commit15e03e1e5e7bbde88b15411f9cb529d02ff5d23e (patch)
tree4f89df9dc67c07379682e6f03025aff1e85266c9
parent6174a30d7c136c0fd163d512dfac840741a39f7c (diff)
downloadrust-15e03e1e5e7bbde88b15411f9cb529d02ff5d23e.tar.gz
rust-15e03e1e5e7bbde88b15411f9cb529d02ff5d23e.zip
Forbid attrs on macros, since we don't handle them properly yet.
-rw-r--r--src/libsyntax/parse/parser.rs11
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/test/compile-fail/attr-before-ext.rs2
-rw-r--r--src/test/compile-fail/ext-after-attrib.rs2
4 files changed, 12 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 6c029347b9c..52e001f8d5c 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2197,7 +2197,7 @@ impl Parser {
         fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
             // If we have attributes then we should have an item
             if vec::is_not_empty(current_attrs) {
-                p.fatal(~"expected item");
+                p.fatal(~"expected item after attrs");
             }
         }
 
@@ -2210,6 +2210,9 @@ impl Parser {
         } else if is_ident(self.token)
             && !self.is_any_keyword(copy self.token)
             && self.look_ahead(1) == token::NOT {
+
+            check_expected_item(self, first_item_attrs);
+
             // Potential trouble: if we allow macros with paths instead of
             // idents, we'd need to look ahead past the whole path here...
             let pth = self.parse_value_path();
@@ -2381,7 +2384,7 @@ impl Parser {
                             }
                         }
 
-                        stmt_mac(m, false) => {
+                        stmt_mac(m, _) => {
                             // Statement macro; might be an expr
                             match self.token {
                                 token::SEMI => {
@@ -3590,6 +3593,10 @@ impl Parser {
                 && (is_plain_ident(self.look_ahead(2))
                     || self.look_ahead(2) == token::LPAREN
                     || self.look_ahead(2) == token::LBRACE) {
+            if attrs.len() > 0 {
+                self.fatal(~"attrs on macros are not yet supported");
+            }
+
             // item macro.
             let pth = self.parse_path_without_tps();
             self.expect(token::NOT);
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 99c12be4980..c38895f39f1 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -344,7 +344,7 @@ impl ident_interner {
     }
 }
 
-/** Key for thread-local data for sneaking interner information to the
+/* Key for thread-local data for sneaking interner information to the
  * serializer/deserializer. It sounds like a hack because it is one.
  * Bonus ultra-hack: functions as keys don't work across crates,
  * so we have to use a unique number. See taskgroup_key! in task.rs
diff --git a/src/test/compile-fail/attr-before-ext.rs b/src/test/compile-fail/attr-before-ext.rs
index e6bbb50044b..e474b63be85 100644
--- a/src/test/compile-fail/attr-before-ext.rs
+++ b/src/test/compile-fail/attr-before-ext.rs
@@ -1,4 +1,4 @@
 fn main() {
     #[attr]
-    debug!("hi"); //~ ERROR expected item
+    debug!("hi"); //~ ERROR expected item after attrs
 }
\ No newline at end of file
diff --git a/src/test/compile-fail/ext-after-attrib.rs b/src/test/compile-fail/ext-after-attrib.rs
index 5c3ca527068..948a7bf1792 100644
--- a/src/test/compile-fail/ext-after-attrib.rs
+++ b/src/test/compile-fail/ext-after-attrib.rs
@@ -1,4 +1,4 @@
-// error-pattern:expected item but found `fmt`
+// error-pattern:attrs on macros are not yet supported
 
 // Don't know how to deal with a syntax extension appearing after an
 // item attribute. Probably could use a better error message.