about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-28 17:16:48 -0700
committerbors <bors@rust-lang.org>2014-03-28 17:16:48 -0700
commitff733c767a2ac48e5f94a37bc8ed3d2f1bc1141c (patch)
treef398acb54f2432247f3c174555010b3055cd7133 /src/libsyntax/parse
parentcbfc0a5e33eb3d97a2995d120536b8dadc0cc0a2 (diff)
parent451e8c1c6178750a4c1789f40749562164a980b7 (diff)
downloadrust-ff733c767a2ac48e5f94a37bc8ed3d2f1bc1141c.tar.gz
rust-ff733c767a2ac48e5f94a37bc8ed3d2f1bc1141c.zip
auto merge of #13162 : alexcrichton/rust/attr-syntax, r=brson
This is the rebasing of #13068 with a fix for #13067 as the first commit.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/attr.rs24
-rw-r--r--src/libsyntax/parse/parser.rs5
-rw-r--r--src/libsyntax/parse/token.rs8
3 files changed, 18 insertions, 19 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index 8f7fb5749a1..ddb6ddb64b4 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -34,9 +34,6 @@ impl<'a> ParserAttr for Parser<'a> {
             debug!("parse_outer_attributes: self.token={:?}",
                    self.token);
             match self.token {
-              token::INTERPOLATED(token::NtAttr(..)) => {
-                attrs.push(self.parse_attribute(false));
-              }
               token::POUND => {
                 attrs.push(self.parse_attribute(false));
               }
@@ -66,11 +63,6 @@ impl<'a> ParserAttr for Parser<'a> {
         debug!("parse_attributes: permit_inner={:?} self.token={:?}",
                permit_inner, self.token);
         let (span, value, mut style) = match self.token {
-            INTERPOLATED(token::NtAttr(attr)) => {
-                assert!(attr.node.style == ast::AttrOuter);
-                self.bump();
-                (attr.span, attr.node.value, ast::AttrOuter)
-            }
             token::POUND => {
                 let lo = self.span.lo;
                 self.bump();
@@ -101,9 +93,8 @@ impl<'a> ParserAttr for Parser<'a> {
         };
 
         if permit_inner && self.eat(&token::SEMI) {
-            // NOTE: uncomment this after a stage0 snap
-            //self.warn("This uses the old attribute syntax. Semicolons
-            //  are not longer required.");
+            self.span_warn(span, "this inner attribute syntax is deprecated. \
+                           The new syntax is `#![foo]`, with a bang and no semicolon.");
             style = ast::AttrInner;
         }
 
@@ -133,9 +124,6 @@ impl<'a> ParserAttr for Parser<'a> {
         let mut next_outer_attrs: Vec<ast::Attribute> = Vec::new();
         loop {
             let attr = match self.token {
-                token::INTERPOLATED(token::NtAttr(..)) => {
-                    self.parse_attribute(true)
-                }
                 token::POUND => {
                     self.parse_attribute(true)
                 }
@@ -163,6 +151,14 @@ impl<'a> ParserAttr for Parser<'a> {
     // | IDENT = lit
     // | IDENT meta_seq
     fn parse_meta_item(&mut self) -> @ast::MetaItem {
+        match self.token {
+            token::INTERPOLATED(token::NtMeta(e)) => {
+                self.bump();
+                return e
+            }
+            _ => {}
+        }
+
         let lo = self.span.lo;
         let ident = self.parse_ident();
         let name = self.id_to_interned_str(ident);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 0ae43db8315..aee843bd857 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[macro_escape];
+#![macro_escape]
 
 use abi;
 use abi::AbiSet;
@@ -811,6 +811,9 @@ impl<'a> Parser<'a> {
     pub fn warn(&mut self, m: &str) {
         self.sess.span_diagnostic.span_warn(self.span, m)
     }
+    pub fn span_warn(&mut self, sp: Span, m: &str) {
+        self.sess.span_diagnostic.span_warn(sp, m)
+    }
     pub fn span_err(&mut self, sp: Span, m: &str) {
         self.sess.span_diagnostic.span_err(sp, m)
     }
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 7bb920bdf56..e3eb1f1f711 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -113,7 +113,7 @@ pub enum Nonterminal {
     NtExpr(@ast::Expr),
     NtTy(  P<ast::Ty>),
     NtIdent(~ast::Ident, bool),
-    NtAttr(@ast::Attribute), // #[foo]
+    NtMeta(@ast::MetaItem), // stuff inside brackets for attributes
     NtPath(~ast::Path),
     NtTT(  @ast::TokenTree), // needs @ed to break a circularity
     NtMatchers(Vec<ast::Matcher> )
@@ -129,7 +129,7 @@ impl fmt::Show for Nonterminal {
             NtExpr(..) => f.pad("NtExpr(..)"),
             NtTy(..) => f.pad("NtTy(..)"),
             NtIdent(..) => f.pad("NtIdent(..)"),
-            NtAttr(..) => f.pad("NtAttr(..)"),
+            NtMeta(..) => f.pad("NtMeta(..)"),
             NtPath(..) => f.pad("NtPath(..)"),
             NtTT(..) => f.pad("NtTT(..)"),
             NtMatchers(..) => f.pad("NtMatchers(..)"),
@@ -241,7 +241,7 @@ pub fn to_str(t: &Token) -> ~str {
       INTERPOLATED(ref nt) => {
         match nt {
             &NtExpr(e) => ::print::pprust::expr_to_str(e),
-            &NtAttr(e) => ::print::pprust::attribute_to_str(e),
+            &NtMeta(e) => ::print::pprust::meta_item_to_str(e),
             _ => {
                 ~"an interpolated " +
                     match *nt {
@@ -249,7 +249,7 @@ pub fn to_str(t: &Token) -> ~str {
                         NtBlock(..) => ~"block",
                         NtStmt(..) => ~"statement",
                         NtPat(..) => ~"pattern",
-                        NtAttr(..) => fail!("should have been handled"),
+                        NtMeta(..) => fail!("should have been handled"),
                         NtExpr(..) => fail!("should have been handled above"),
                         NtTy(..) => ~"type",
                         NtIdent(..) => ~"identifier",