about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-01-02 11:32:09 -0800
committerbors <bors@rust-lang.org>2014-01-02 11:32:09 -0800
commit0df9b850ac1ed3abd0ff5abfbb716af83501dd5a (patch)
tree380744a8c4feb43d1704d408ab410c85b7eac9c3 /src/libsyntax
parentc29b1be5edcb56f221b0a54653f62147069b41a4 (diff)
parent4cb13ed9823d30ac3163e7e6b3e74becd09a508d (diff)
downloadrust-0df9b850ac1ed3abd0ff5abfbb716af83501dd5a.tar.gz
rust-0df9b850ac1ed3abd0ff5abfbb716af83501dd5a.zip
auto merge of #10696 : fhahn/rust/issue9543-remove-extern-mod-foo, r=pcwalton
This patch for  #9543 throws an `obsolete syntax` error for `extern mod foo (name="bar")` . 
I was wondering if [this](https://github.com/fhahn/rust/compare/mozilla:master...fhahn:issue9543-remove-extern-mod-foo?expand=1#diff-da9d34ca1d0f6beee2838cf02e07345cR4444) is the correct place to do this?

I think the wording of the error message could probably be improved as well.

If this approach is OK, I'm going to run the whole test suite tomorrow and update the old syntax to the new one.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs2
-rw-r--r--src/libsyntax/ast_util.rs2
-rw-r--r--src/libsyntax/fold.rs2
-rw-r--r--src/libsyntax/parse/obsolete.rs6
-rw-r--r--src/libsyntax/parse/parser.rs11
-rw-r--r--src/libsyntax/print/pprust.rs7
-rw-r--r--src/libsyntax/visit.rs2
7 files changed, 19 insertions, 13 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 8e6e0625138..51aa7cd4377 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1057,7 +1057,7 @@ pub enum view_item_ {
     // optional @str: if present, this is a location (containing
     // arbitrary characters) from which to fetch the crate sources
     // For example, extern mod whatever = "github.com/mozilla/rust"
-    view_item_extern_mod(Ident, Option<(@str, StrStyle)>, ~[@MetaItem], NodeId),
+    view_item_extern_mod(Ident, Option<(@str, StrStyle)>, NodeId),
     view_item_use(~[@view_path]),
 }
 
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 87448278687..f93eb6754ad 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -419,7 +419,7 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> {
 
     fn visit_view_item(&mut self, view_item: &view_item, env: ()) {
         match view_item.node {
-            view_item_extern_mod(_, _, _, node_id) => {
+            view_item_extern_mod(_, _, node_id) => {
                 self.operation.visit_id(node_id)
             }
             view_item_use(ref view_paths) => {
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 9edde7c9c87..4a2adc04fbd 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -66,11 +66,9 @@ pub trait ast_fold {
         let inner_view_item = match vi.node {
             view_item_extern_mod(ref ident,
                                  string,
-                                 ref meta_items,
                                  node_id) => {
                 view_item_extern_mod(ident.clone(),
                                      string,
-                                     self.fold_meta_items(*meta_items),
                                      self.new_id(node_id))
             }
             view_item_use(ref view_paths) => {
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)
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 960e28ca84f..79ef9c2cbbe 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1952,7 +1952,7 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
     print_outer_attributes(s, item.attrs);
     print_visibility(s, item.vis);
     match item.node {
-        ast::view_item_extern_mod(id, ref optional_path, ref mta, _) => {
+        ast::view_item_extern_mod(id, ref optional_path, _) => {
             head(s, "extern mod");
             print_ident(s, id);
             for &(ref p, style) in optional_path.iter() {
@@ -1961,11 +1961,6 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
                 space(s.s);
                 print_string(s, *p, style);
             }
-            if !mta.is_empty() {
-                popen(s);
-                commasep(s, consistent, *mta, |p, &i| print_meta_item(p, i));
-                pclose(s);
-            }
         }
 
         ast::view_item_use(ref vps) => {
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 8cc6fc4990f..2e83a038c58 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -139,7 +139,7 @@ pub fn walk_mod<E:Clone, V:Visitor<E>>(visitor: &mut V, module: &_mod, env: E) {
 
 pub fn walk_view_item<E:Clone, V:Visitor<E>>(visitor: &mut V, vi: &view_item, env: E) {
     match vi.node {
-        view_item_extern_mod(name, _, _, _) => {
+        view_item_extern_mod(name, _, _) => {
             visitor.visit_ident(vi.span, name, env)
         }
         view_item_use(ref paths) => {