Skip to content

Commit 49472ec

Browse files
committed
librustc: Remove legacy exports from the language. r=brson
1 parent 040035c commit 49472ec

File tree

14 files changed

+75
-387
lines changed

14 files changed

+75
-387
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,11 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder,
331331
item_impl(*) | item_struct(*) => {
332332
let (ident, did) = (item.ident, item.id);
333333
debug!("(encoding info for module) ... encoding impl %s \
334-
(%?/%?), exported? %?",
334+
(%?/%?)",
335335
ecx.tcx.sess.str_of(ident),
336336
did,
337337
ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx
338-
.sess.parse_sess.interner),
339-
ast_util::is_exported(ident, md));
338+
.sess.parse_sess.interner));
340339

341340
ebml_w.start_tag(tag_mod_impl);
342341
ebml_w.wr_str(def_to_str(local_def(did)));

src/librustc/middle/privacy.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ use syntax::ast::{provided, required};
2929
use syntax::ast;
3030
use syntax::ast_map::{node_item, node_method};
3131
use syntax::ast_map;
32-
use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local};
33-
use syntax::ast_util::{visibility_to_privacy};
32+
use syntax::ast_util::{Private, Public, is_local};
33+
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
3434
use syntax::codemap::span;
3535
use syntax::visit;
3636

3737
pub fn check_crate(tcx: ty::ctxt,
3838
method_map: &method_map,
3939
crate: @ast::crate) {
4040
let privileged_items = @DVec();
41-
let legacy_exports = has_legacy_export_attr(crate.node.attrs);
4241

4342
// Adds structs that are privileged to this scope.
4443
let add_privileged_items: @fn(&[@ast::item]) -> uint = |items| {
@@ -65,20 +64,20 @@ pub fn check_crate(tcx: ty::ctxt,
6564
|it| { it.vis },
6665
~"unbound enum parent when checking \
6766
dereference of enum type");
68-
visibility_to_privacy(parent_vis, legacy_exports)
67+
visibility_to_privacy(parent_vis)
6968
}
7069
else {
7170
// WRONG
7271
Public
7372
};
7473
debug!("parental_privacy = %?", parental_privacy);
75-
debug!("vis = %?, priv = %?, legacy_exports = %?",
74+
debug!("vis = %?, priv = %?",
7675
variant_info.vis,
77-
visibility_to_privacy(variant_info.vis, legacy_exports),
78-
legacy_exports);
76+
visibility_to_privacy(variant_info.vis))
7977
// inherited => privacy of the enum item
80-
if visibility_to_privacy(variant_info.vis,
81-
parental_privacy == Public) == Private {
78+
if variant_visibility_to_privacy(variant_info.vis,
79+
parental_privacy == Public)
80+
== Private {
8281
tcx.sess.span_err(span,
8382
~"can only dereference enums \
8483
with a single, public variant");

src/librustc/middle/resolve.rs

Lines changed: 28 additions & 209 deletions
Large diffs are not rendered by default.

src/librustc/middle/trans/monomorphize.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ pub fn monomorphic_fn(ccx: @crate_ctxt,
111111
ast_map::node_stmt(*) => {
112112
ccx.tcx.sess.bug(~"Can't monomorphize a stmt")
113113
}
114-
ast_map::node_export(*) => {
115-
ccx.tcx.sess.bug(~"Can't monomorphize an export")
116-
}
117114
ast_map::node_arg(*) => ccx.tcx.sess.bug(~"Can't monomorphize an arg"),
118115
ast_map::node_block(*) => {
119116
ccx.tcx.sess.bug(~"Can't monomorphize a block")
@@ -255,7 +252,6 @@ pub fn monomorphic_fn(ccx: @crate_ctxt,
255252
ast_map::node_expr(*) |
256253
ast_map::node_stmt(*) |
257254
ast_map::node_trait_method(*) |
258-
ast_map::node_export(*) |
259255
ast_map::node_arg(*) |
260256
ast_map::node_block(*) |
261257
ast_map::node_local(*) => {

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3756,7 +3756,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
37563756

37573757
ast_map::node_stmt(*) | ast_map::node_expr(*) |
37583758
ast_map::node_arg(*) | ast_map::node_local(*) |
3759-
ast_map::node_export(*) | ast_map::node_block(*) => {
3759+
ast_map::node_block(*) => {
37603760
cx.sess.bug(fmt!("cannot find item_path for node %?", node));
37613761
}
37623762
}

src/librustc/middle/typeck/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ use std::map;
7272
use std::smallintmap;
7373
use syntax::ast::{provided, required, spanned};
7474
use syntax::ast_map::node_id_to_str;
75-
use syntax::ast_util::{has_legacy_export_attr};
7675
use syntax::ast_util::{local_def, respan, split_trait_methods};
7776
use syntax::codemap::span;
7877
use syntax::print::pprust::*;

src/libsyntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,6 @@ pub struct view_item {
15041504
pub enum view_item_ {
15051505
view_item_use(ident, ~[@meta_item], node_id),
15061506
view_item_import(~[@view_path]),
1507-
view_item_export(~[@view_path])
15081507
}
15091508
15101509
// Meta-data associated with an item

src/libsyntax/ast_map.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub enum ast_node {
9696
node_variant(variant, @item, @path),
9797
node_expr(@expr),
9898
node_stmt(@stmt),
99-
node_export(@view_path, @path),
10099
// Locals are numbered, because the alias analysis needs to know in which
101100
// order they are introduced.
102101
node_arg(arg, uint),
@@ -128,7 +127,6 @@ pub fn mk_ast_map_visitor() -> vt {
128127
visit_fn: map_fn,
129128
visit_local: map_local,
130129
visit_arm: map_arm,
131-
visit_view_item: map_view_item,
132130
visit_block: map_block,
133131
.. *visit::default_visitor()
134132
});
@@ -324,23 +322,6 @@ pub fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
324322
}
325323
}
326324

327-
pub fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
328-
match vi.node {
329-
view_item_export(vps) => for vps.each |vp| {
330-
let (id, name) = match vp.node {
331-
view_path_simple(nm, _, _, id) => {
332-
(id, /* FIXME (#2543) */ copy nm)
333-
}
334-
view_path_glob(pth, id) | view_path_list(pth, _, id) => {
335-
(id, path_to_ident(pth))
336-
}
337-
};
338-
cx.map.insert(id, node_export(*vp, extend(cx, name)));
339-
},
340-
_ => ()
341-
}
342-
}
343-
344325
pub fn map_expr(ex: @expr, cx: ctx, v: vt) {
345326
cx.map.insert(ex.id, node_expr(ex));
346327
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 {
396377
fmt!("stmt %s (id=%?)",
397378
pprust::stmt_to_str(*stmt, itr), id)
398379
}
399-
// FIXMEs are as per #2410
400-
Some(node_export(_, path)) => {
401-
fmt!("export %s (id=%?)", // add more info here
402-
path_to_str(*path, itr), id)
403-
}
404380
Some(node_arg(_, _)) => { // add more info here
405381
fmt!("arg (id=%?)", id)
406382
}

src/libsyntax/ast_util.rs

Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -215,64 +215,6 @@ pub pure fn float_ty_to_str(t: float_ty) -> ~str {
215215
match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" }
216216
}
217217

218-
pub fn is_exported(i: ident, m: _mod) -> bool {
219-
let mut local = false;
220-
let mut parent_enum : Option<ident> = None;
221-
for m.items.each |it| {
222-
if it.ident == i { local = true; }
223-
match it.node {
224-
item_enum(ref enum_definition, _) =>
225-
for (*enum_definition).variants.each |v| {
226-
if v.node.name == i {
227-
local = true;
228-
parent_enum = Some(/* FIXME (#2543) */ copy it.ident);
229-
}
230-
},
231-
_ => ()
232-
}
233-
if local { break; }
234-
}
235-
let mut has_explicit_exports = false;
236-
for m.view_items.each |vi| {
237-
match vi.node {
238-
view_item_export(vps) => {
239-
has_explicit_exports = true;
240-
for vps.each |vp| {
241-
match vp.node {
242-
ast::view_path_simple(id, _, _, _) => {
243-
if id == i { return true; }
244-
match parent_enum {
245-
Some(parent_enum_id) => {
246-
if id == parent_enum_id { return true; }
247-
}
248-
_ => ()
249-
}
250-
}
251-
252-
ast::view_path_list(path, ref ids, _) => {
253-
if vec::len(path.idents) == 1u {
254-
if i == path.idents[0] { return true; }
255-
for (*ids).each |id| {
256-
if id.node.name == i { return true; }
257-
}
258-
} else {
259-
fail ~"export of path-qualified list";
260-
}
261-
}
262-
263-
_ => ()
264-
}
265-
}
266-
}
267-
_ => ()
268-
}
269-
}
270-
// If there are no declared exports then
271-
// everything not imported is exported
272-
// even if it's local (since it's explicit)
273-
return !has_explicit_exports && local;
274-
}
275-
276218
pub pure fn is_call_expr(e: @expr) -> bool {
277219
match e.node { expr_call(_, _, _) => true, _ => false }
278220
}
@@ -476,7 +418,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
476418
visit_view_item: fn@(vi: @view_item) {
477419
match vi.node {
478420
view_item_use(_, _, id) => vfn(id),
479-
view_item_import(vps) | view_item_export(vps) => {
421+
view_item_import(vps) => {
480422
for vec::each(vps) |vp| {
481423
match vp.node {
482424
view_path_simple(_, _, _, id) => vfn(id),
@@ -662,46 +604,32 @@ pub fn struct_def_is_tuple_like(struct_def: @ast::struct_def) -> bool {
662604
struct_def.ctor_id.is_some()
663605
}
664606

607+
pub fn visibility_to_privacy(visibility: visibility) -> Privacy {
608+
match visibility {
609+
public => Public,
610+
inherited | private => Private
611+
}
612+
}
665613

666-
pub fn visibility_to_privacy(visibility: visibility,
667-
legacy_exports: bool) -> Privacy {
668-
if legacy_exports {
614+
pub fn variant_visibility_to_privacy(visibility: visibility,
615+
enclosing_is_public: bool)
616+
-> Privacy {
617+
if enclosing_is_public {
669618
match visibility {
670-
inherited | public => Public,
619+
public | inherited => Public,
671620
private => Private
672621
}
673622
} else {
674-
match visibility {
675-
public => Public,
676-
inherited | private => Private
677-
}
623+
visibility_to_privacy(visibility)
678624
}
679625
}
680626

627+
#[deriving_eq]
681628
pub enum Privacy {
682629
Private,
683630
Public
684631
}
685632

686-
pub impl Privacy : cmp::Eq {
687-
pure fn eq(&self, other: &Privacy) -> bool {
688-
((*self) as uint) == ((*other) as uint)
689-
}
690-
pure fn ne(&self, other: &Privacy) -> bool { !(*self).eq(other) }
691-
}
692-
693-
pub fn has_legacy_export_attr(attrs: &[attribute]) -> bool {
694-
for attrs.each |attribute| {
695-
match attribute.node.value.node {
696-
meta_word(ref w) if (*w) == ~"legacy_exports" => {
697-
return true;
698-
}
699-
_ => {}
700-
}
701-
}
702-
return false;
703-
}
704-
705633
// Local Variables:
706634
// mode: rust
707635
// fill-column: 78;

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use ast::{ty_field, ty_fixed_length_vec, ty_fn, ty_infer, ty_mac, ty_method};
5050
use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr};
5151
use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, type_value_ns, uniq};
5252
use ast::{unnamed_field, unsafe_blk, unsafe_fn, variant, view_item};
53-
use ast::{view_item_, view_item_export, view_item_import, view_item_use};
53+
use ast::{view_item_, view_item_import, view_item_use};
5454
use ast::{view_path, view_path_glob, view_path_list, view_path_simple};
5555
use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice};
5656
use ast::{vstore_uniq};
@@ -88,6 +88,7 @@ use core::vec::push;
8888
use core::vec;
8989
use std::map::HashMap;
9090

91+
#[deriving_eq]
9192
enum restriction {
9293
UNRESTRICTED,
9394
RESTRICT_STMT_EXPR,
@@ -3735,15 +3736,6 @@ pub impl Parser {
37353736
vis: visibility,
37363737
span: mk_sp(lo, self.last_span.hi)
37373738
});
3738-
} else if self.eat_keyword(~"export") {
3739-
let view_paths = self.parse_view_paths();
3740-
self.expect(token::SEMI);
3741-
return iovi_view_item(@ast::view_item {
3742-
node: view_item_export(view_paths),
3743-
attrs: attrs,
3744-
vis: visibility,
3745-
span: mk_sp(lo, self.last_span.hi)
3746-
});
37473739
} else if macros_allowed && !self.is_any_keyword(copy self.token)
37483740
&& self.look_ahead(1) == token::NOT
37493741
&& (is_plain_ident(self.look_ahead(2))
@@ -3916,7 +3908,6 @@ pub impl Parser {
39163908
next_tok = self.look_ahead(2);
39173909
};
39183910
self.token_is_keyword(~"use", tok)
3919-
|| self.token_is_keyword(~"export", tok)
39203911
|| (self.token_is_keyword(~"extern", tok) &&
39213912
self.token_is_keyword(~"mod", next_tok))
39223913
}
@@ -3925,8 +3916,6 @@ pub impl Parser {
39253916
let lo = self.span.lo;
39263917
let node = if self.eat_keyword(~"use") {
39273918
self.parse_use()
3928-
} else if self.eat_keyword(~"export") {
3929-
view_item_export(self.parse_view_paths())
39303919
} else if self.eat_keyword(~"extern") {
39313920
self.expect_keyword(~"mod");
39323921
let ident = self.parse_ident();
@@ -3979,8 +3968,8 @@ pub impl Parser {
39793968
if restricted_to_imports {
39803969
match view_item.node {
39813970
view_item_import(_) => {}
3982-
view_item_export(_) | view_item_use(*) =>
3983-
self.fatal(~"exports and \"extern mod\" \
3971+
view_item_use(*) =>
3972+
self.fatal(~"\"extern mod\" \
39843973
declarations are not \
39853974
allowed here")
39863975
}
@@ -4025,13 +4014,6 @@ pub impl Parser {
40254014
}
40264015
}
40274016

4028-
impl restriction : cmp::Eq {
4029-
pure fn eq(&self, other: &restriction) -> bool {
4030-
((*self) as uint) == ((*other) as uint)
4031-
}
4032-
pure fn ne(&self, other: &restriction) -> bool { !(*self).eq(other) }
4033-
}
4034-
40354017
//
40364018
// Local Variables:
40374019
// mode: rust

src/libsyntax/parse/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
486486
~"break",
487487
~"const", ~"copy",
488488
~"do", ~"drop",
489-
~"else", ~"enum", ~"export", ~"extern",
489+
~"else", ~"enum", ~"extern",
490490
~"fail", ~"false", ~"fn", ~"for",
491491
~"if", ~"impl",
492492
~"let", ~"log", ~"loop",

0 commit comments

Comments
 (0)