about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-01-30 17:20:02 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-01-30 18:11:43 -0800
commit49472ec4c9d6564f8ec22d689ccd61528d2dc553 (patch)
tree421550a9d42763d2dceda339dedaf906f2ede3a9 /src/libsyntax
parent040035cd08f9c250d523c9832b25275153d11c3c (diff)
downloadrust-49472ec4c9d6564f8ec22d689ccd61528d2dc553.tar.gz
rust-49472ec4c9d6564f8ec22d689ccd61528d2dc553.zip
librustc: Remove legacy exports from the language. r=brson
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs1
-rw-r--r--src/libsyntax/ast_map.rs24
-rw-r--r--src/libsyntax/ast_util.rs100
-rw-r--r--src/libsyntax/parse/parser.rs26
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/libsyntax/print/pprust.rs29
6 files changed, 31 insertions, 151 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 8736074a5c4..0b250c2e421 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1504,7 +1504,6 @@ pub struct view_item {
 pub enum view_item_ {
     view_item_use(ident, ~[@meta_item], node_id),
     view_item_import(~[@view_path]),
-    view_item_export(~[@view_path])
 }
 
 // Meta-data associated with an item
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index 773e3754e26..a96829ed063 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -96,7 +96,6 @@ pub enum ast_node {
     node_variant(variant, @item, @path),
     node_expr(@expr),
     node_stmt(@stmt),
-    node_export(@view_path, @path),
     // Locals are numbered, because the alias analysis needs to know in which
     // order they are introduced.
     node_arg(arg, uint),
@@ -128,7 +127,6 @@ pub fn mk_ast_map_visitor() -> vt {
         visit_fn: map_fn,
         visit_local: map_local,
         visit_arm: map_arm,
-        visit_view_item: map_view_item,
         visit_block: map_block,
         .. *visit::default_visitor()
     });
@@ -324,23 +322,6 @@ pub fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
     }
 }
 
-pub fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
-    match vi.node {
-      view_item_export(vps) => for vps.each |vp| {
-        let (id, name) = match vp.node {
-          view_path_simple(nm, _, _, id) => {
-            (id, /* FIXME (#2543) */ copy nm)
-          }
-          view_path_glob(pth, id) | view_path_list(pth, _, id) => {
-            (id, path_to_ident(pth))
-          }
-        };
-        cx.map.insert(id, node_export(*vp, extend(cx, name)));
-      },
-      _ => ()
-    }
-}
-
 pub fn map_expr(ex: @expr, cx: ctx, v: vt) {
     cx.map.insert(ex.id, node_expr(ex));
     visit::visit_expr(ex, cx, v);
@@ -396,11 +377,6 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
         fmt!("stmt %s (id=%?)",
              pprust::stmt_to_str(*stmt, itr), id)
       }
-      // FIXMEs are as per #2410
-      Some(node_export(_, path)) => {
-        fmt!("export %s (id=%?)", // add more info here
-             path_to_str(*path, itr), id)
-      }
       Some(node_arg(_, _)) => { // add more info here
         fmt!("arg (id=%?)", id)
       }
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index ac0a54c582c..7b742019f0e 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -215,64 +215,6 @@ pub pure fn float_ty_to_str(t: float_ty) -> ~str {
     match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" }
 }
 
-pub fn is_exported(i: ident, m: _mod) -> bool {
-    let mut local = false;
-    let mut parent_enum : Option<ident> = None;
-    for m.items.each |it| {
-        if it.ident == i { local = true; }
-        match it.node {
-          item_enum(ref enum_definition, _) =>
-            for (*enum_definition).variants.each |v| {
-                if v.node.name == i {
-                    local = true;
-                    parent_enum = Some(/* FIXME (#2543) */ copy it.ident);
-                }
-            },
-          _ => ()
-        }
-        if local { break; }
-    }
-    let mut has_explicit_exports = false;
-    for m.view_items.each |vi| {
-        match vi.node {
-          view_item_export(vps) => {
-            has_explicit_exports = true;
-            for vps.each |vp| {
-                match vp.node {
-                  ast::view_path_simple(id, _, _, _) => {
-                    if id == i { return true; }
-                    match parent_enum {
-                      Some(parent_enum_id) => {
-                        if id == parent_enum_id { return true; }
-                      }
-                      _ => ()
-                    }
-                  }
-
-                  ast::view_path_list(path, ref ids, _) => {
-                    if vec::len(path.idents) == 1u {
-                        if i == path.idents[0] { return true; }
-                        for (*ids).each |id| {
-                            if id.node.name == i { return true; }
-                        }
-                    } else {
-                        fail ~"export of path-qualified list";
-                    }
-                  }
-
-                  _ => ()
-                }
-            }
-          }
-          _ => ()
-        }
-    }
-    // If there are no declared exports then
-    // everything not imported is exported
-    // even if it's local (since it's explicit)
-    return !has_explicit_exports && local;
-}
-
 pub pure fn is_call_expr(e: @expr) -> bool {
     match e.node { expr_call(_, _, _) => true, _ => false }
 }
@@ -476,7 +418,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
         visit_view_item: fn@(vi: @view_item) {
             match vi.node {
               view_item_use(_, _, id) => vfn(id),
-              view_item_import(vps) | view_item_export(vps) => {
+              view_item_import(vps) => {
                   for vec::each(vps) |vp| {
                       match vp.node {
                           view_path_simple(_, _, _, id) => vfn(id),
@@ -662,46 +604,32 @@ pub fn struct_def_is_tuple_like(struct_def: @ast::struct_def) -> bool {
     struct_def.ctor_id.is_some()
 }
 
+pub fn visibility_to_privacy(visibility: visibility) -> Privacy {
+    match visibility {
+        public => Public,
+        inherited | private => Private
+    }
+}
 
-pub fn visibility_to_privacy(visibility: visibility,
-                             legacy_exports: bool) -> Privacy {
-    if legacy_exports {
+pub fn variant_visibility_to_privacy(visibility: visibility,
+                                     enclosing_is_public: bool)
+                                  -> Privacy {
+    if enclosing_is_public {
         match visibility {
-            inherited | public => Public,
+            public | inherited => Public,
             private => Private
         }
     } else {
-        match visibility {
-            public => Public,
-            inherited | private => Private
-        }
+        visibility_to_privacy(visibility)
     }
 }
 
+#[deriving_eq]
 pub enum Privacy {
     Private,
     Public
 }
 
-pub impl Privacy : cmp::Eq {
-    pure fn eq(&self, other: &Privacy) -> bool {
-        ((*self) as uint) == ((*other) as uint)
-    }
-    pure fn ne(&self, other: &Privacy) -> bool { !(*self).eq(other) }
-}
-
-pub fn has_legacy_export_attr(attrs: &[attribute]) -> bool {
-    for attrs.each |attribute| {
-        match attribute.node.value.node {
-          meta_word(ref w) if (*w) == ~"legacy_exports" => {
-            return true;
-          }
-          _ => {}
-        }
-    }
-    return false;
-}
-
 // Local Variables:
 // mode: rust
 // fill-column: 78;
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 25fd13a5999..d41fedebde3 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -50,7 +50,7 @@ use ast::{ty_field, ty_fixed_length_vec, ty_fn, ty_infer, ty_mac, ty_method};
 use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr};
 use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, type_value_ns, uniq};
 use ast::{unnamed_field, unsafe_blk, unsafe_fn, variant, view_item};
-use ast::{view_item_, view_item_export, view_item_import, view_item_use};
+use ast::{view_item_, view_item_import, view_item_use};
 use ast::{view_path, view_path_glob, view_path_list, view_path_simple};
 use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice};
 use ast::{vstore_uniq};
@@ -88,6 +88,7 @@ use core::vec::push;
 use core::vec;
 use std::map::HashMap;
 
+#[deriving_eq]
 enum restriction {
     UNRESTRICTED,
     RESTRICT_STMT_EXPR,
@@ -3735,15 +3736,6 @@ pub impl Parser {
                 vis: visibility,
                 span: mk_sp(lo, self.last_span.hi)
             });
-        } else if self.eat_keyword(~"export") {
-            let view_paths = self.parse_view_paths();
-            self.expect(token::SEMI);
-            return iovi_view_item(@ast::view_item {
-                node: view_item_export(view_paths),
-                attrs: attrs,
-                vis: visibility,
-                span: mk_sp(lo, self.last_span.hi)
-            });
         } else if macros_allowed && !self.is_any_keyword(copy self.token)
                 && self.look_ahead(1) == token::NOT
                 && (is_plain_ident(self.look_ahead(2))
@@ -3916,7 +3908,6 @@ pub impl Parser {
             next_tok = self.look_ahead(2);
         };
         self.token_is_keyword(~"use", tok)
-            || self.token_is_keyword(~"export", tok)
             || (self.token_is_keyword(~"extern", tok) &&
                 self.token_is_keyword(~"mod", next_tok))
     }
@@ -3925,8 +3916,6 @@ pub impl Parser {
         let lo = self.span.lo;
         let node = if self.eat_keyword(~"use") {
             self.parse_use()
-        } else if self.eat_keyword(~"export") {
-            view_item_export(self.parse_view_paths())
         } else if self.eat_keyword(~"extern") {
             self.expect_keyword(~"mod");
             let ident = self.parse_ident();
@@ -3979,8 +3968,8 @@ pub impl Parser {
                     if restricted_to_imports {
                             match view_item.node {
                                 view_item_import(_) => {}
-                                view_item_export(_) | view_item_use(*) =>
-                                    self.fatal(~"exports and \"extern mod\" \
+                                view_item_use(*) =>
+                                    self.fatal(~"\"extern mod\" \
                                                  declarations are not \
                                                  allowed here")
                             }
@@ -4025,13 +4014,6 @@ pub impl Parser {
     }
 }
 
-impl restriction : cmp::Eq {
-    pure fn eq(&self, other: &restriction) -> bool {
-        ((*self) as uint) == ((*other) as uint)
-    }
-    pure fn ne(&self, other: &restriction) -> bool { !(*self).eq(other) }
-}
-
 //
 // Local Variables:
 // mode: rust
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 30d2489a5ee..2093b5caebd 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -486,7 +486,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
         ~"break",
         ~"const", ~"copy",
         ~"do", ~"drop",
-        ~"else", ~"enum", ~"export", ~"extern",
+        ~"else", ~"enum", ~"extern",
         ~"fail", ~"false", ~"fn", ~"for",
         ~"if", ~"impl",
         ~"let", ~"log", ~"loop",
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index a0243215e69..7f03158a4df 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1865,25 +1865,20 @@ 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_use(id, mta, _) => {
-        head(s, ~"extern mod");
-        print_ident(s, id);
-        if !mta.is_empty() {
-            popen(s);
-            commasep(s, consistent, mta, print_meta_item);
-            pclose(s);
+        ast::view_item_use(id, mta, _) => {
+            head(s, ~"extern mod");
+            print_ident(s, id);
+            if !mta.is_empty() {
+                popen(s);
+                commasep(s, consistent, mta, print_meta_item);
+                pclose(s);
+            }
         }
-      }
-
-      ast::view_item_import(vps) => {
-        head(s, ~"use");
-        print_view_paths(s, vps);
-      }
 
-      ast::view_item_export(vps) => {
-        head(s, ~"export");
-        print_view_paths(s, vps);
-      }
+        ast::view_item_import(vps) => {
+            head(s, ~"use");
+            print_view_paths(s, vps);
+        }
     }
     word(s.s, ~";");
     end(s); // end inner head-block