about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2013-11-26 23:54:32 +0100
committerFlorian Hahn <flo@fhahn.com>2014-01-01 23:36:57 +0100
commitf42a36cded2ac71e36b2572c54da0fc623af2eca (patch)
tree80886ea0826589bc767f3b50171dd33894d026ef /src/libsyntax/parse
parent51ace54597984b221321d1cac0f80c50f9e00f71 (diff)
downloadrust-f42a36cded2ac71e36b2572c54da0fc623af2eca.tar.gz
rust-f42a36cded2ac71e36b2572c54da0fc623af2eca.zip
Remove `extern mod foo (name="bar")` syntax, closes #9543
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/obsolete.rs6
-rw-r--r--src/libsyntax/parse/parser.rs11
2 files changed, 15 insertions, 2 deletions
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index d739fca99da..df6fbe98aed 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -45,6 +45,7 @@ pub enum ObsoleteSyntax {
     ObsoleteBoxedClosure,
     ObsoleteClosureType,
     ObsoleteMultipleImport,
+    ObsoleteExternModAttributesInParens
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -145,6 +146,11 @@ impl ParserObsoleteMethods for Parser {
                 "multiple imports",
                 "only one import is allowed per `use` statement"
             ),
+            ObsoleteExternModAttributesInParens => (
+                "`extern mod` with linkage attribute list",
+                "use `extern mod foo = \"bar\";` instead of \
+                `extern mod foo (name = \"bar\")`"
+            )
         };
 
         self.report(sp, kind, kind_str, desc);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 729d0320435..5e2b022d175 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4446,11 +4446,18 @@ impl Parser {
             self.span_err(*self.span, "an ABI may not be specified here");
         }
 
+
+        if *self.token == token::LPAREN {
+            // `extern mod foo (name = "bar"[,vers = "version"]) is obsolete,
+            // `extern mod foo = "bar#[version]";` should be used.
+            // Parse obsolete options to avoid wired parser errors
+            self.parse_optional_meta();
+            self.obsolete(*self.span, ObsoleteExternModAttributesInParens);
+        }
         // extern mod foo;
-        let metadata = self.parse_optional_meta();
         self.expect(&token::SEMI);
         iovi_view_item(ast::view_item {
-            node: view_item_extern_mod(ident, maybe_path, metadata, ast::DUMMY_NODE_ID),
+            node: view_item_extern_mod(ident, maybe_path, ast::DUMMY_NODE_ID),
             attrs: attrs,
             vis: visibility,
             span: mk_sp(lo, self.last_span.hi)