Allow multiple exports in a single export statement. Issue #817
This commit is contained in:
parent
c95e3ab6a8
commit
67cc5b9e34
src
@ -564,7 +564,7 @@ tag view_item_ {
|
||||
view_item_use(ident, [@meta_item], node_id);
|
||||
view_item_import(ident, [ident], node_id);
|
||||
view_item_import_glob([ident], node_id);
|
||||
view_item_export(ident, node_id);
|
||||
view_item_export([ident], node_id);
|
||||
}
|
||||
|
||||
type obj_def_ids = {ty: node_id, ctor: node_id};
|
||||
@ -627,11 +627,11 @@ fn is_exported(i: ident, m: _mod) -> bool {
|
||||
let count = 0u;
|
||||
for vi: @ast::view_item in m.view_items {
|
||||
alt vi.node {
|
||||
ast::view_item_export(id, _) {
|
||||
if str::eq(i, id) {
|
||||
// even if it's nonlocal (since it's explicit)
|
||||
|
||||
ret true;
|
||||
ast::view_item_export(ids, _) {
|
||||
for id in ids {
|
||||
if str::eq(i, id) {
|
||||
ret true;
|
||||
}
|
||||
}
|
||||
count += 1u;
|
||||
}
|
||||
@ -640,7 +640,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
|
||||
}
|
||||
// If there are no declared exports then
|
||||
// everything not imported is exported
|
||||
|
||||
// even if it's nonlocal (since it's explicit)
|
||||
ret count == 0u && !nonlocal;
|
||||
}
|
||||
|
||||
|
@ -2353,8 +2353,9 @@ fn parse_import(p: &parser) -> ast::view_item_ {
|
||||
}
|
||||
|
||||
fn parse_export(p: &parser) -> ast::view_item_ {
|
||||
let id = parse_ident(p);
|
||||
ret ast::view_item_export(id, p.get_id());
|
||||
let ids = parse_seq_to_before_end(
|
||||
token::SEMI, option::some(token::COMMA), parse_ident, p);
|
||||
ret ast::view_item_export(ids, p.get_id());
|
||||
}
|
||||
|
||||
fn parse_view_item(p: &parser) -> @ast::view_item {
|
||||
|
@ -1276,7 +1276,11 @@ fn print_view_item(s: &ps, item: &@ast::view_item) {
|
||||
}
|
||||
word(s.s, "::*");
|
||||
}
|
||||
ast::view_item_export(id, _) { head(s, "export"); word(s.s, id); }
|
||||
ast::view_item_export(ids, _) {
|
||||
head(s, "export");
|
||||
commasep(s, inconsistent, ids,
|
||||
fn(s: &ps, w: &str) { word(s.s, w) });
|
||||
}
|
||||
}
|
||||
word(s.s, ";");
|
||||
end(s); // end inner head-block
|
||||
|
16
src/test/run-pass/export-multi.rs
Normal file
16
src/test/run-pass/export-multi.rs
Normal file
@ -0,0 +1,16 @@
|
||||
import m::f;
|
||||
import m::g;
|
||||
|
||||
mod m {
|
||||
export f, g;
|
||||
|
||||
fn f() {}
|
||||
fn g() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
f();
|
||||
g();
|
||||
m::f();
|
||||
m::g();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user