mirror of https://github.com/rust-lang/rust.git
Build the export_map2 from visibility markers, unless #[legacy_exports];
This commit is contained in:
parent
9c6ae65865
commit
546f3dbbf5
|
@ -2868,6 +2868,64 @@ impl Resolver {
|
|||
|
||||
fn record_exports_for_module(module_: @Module) {
|
||||
let mut exports2 = ~[];
|
||||
|
||||
if module_.legacy_exports {
|
||||
self.add_exports_for_legacy_module(&mut exports2, module_);
|
||||
} else {
|
||||
self.add_exports_for_module(&mut exports2, module_);
|
||||
}
|
||||
match copy module_.def_id {
|
||||
Some(def_id) => {
|
||||
self.export_map2.insert(def_id.node, move exports2);
|
||||
debug!("(computing exports) writing exports for %d (some)",
|
||||
def_id.node);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn add_exports_of_namebindings(exports2: &mut ~[Export2],
|
||||
atom: Atom,
|
||||
namebindings: @NameBindings,
|
||||
reexport: bool) {
|
||||
for [ModuleNS, TypeNS, ValueNS].each |ns| {
|
||||
match namebindings.def_for_namespace(*ns) {
|
||||
Some(d) if d.privacy == Public => {
|
||||
vec::push(*exports2, Export2 {
|
||||
reexport: reexport,
|
||||
name: self.session.str_of(atom),
|
||||
def_id: def_id_of_def(d.def)
|
||||
});
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_exports_for_module(exports2: &mut ~[Export2], module_: @Module) {
|
||||
|
||||
for module_.children.each_ref |atom, namebindings| {
|
||||
self.add_exports_of_namebindings(exports2, *atom,
|
||||
*namebindings, false)
|
||||
}
|
||||
|
||||
for module_.import_resolutions.each_ref |atom, importresolution| {
|
||||
for [ModuleNS, TypeNS, ValueNS].each |ns| {
|
||||
match importresolution.target_for_namespace(*ns) {
|
||||
Some(target) => {
|
||||
self.add_exports_of_namebindings(exports2, *atom,
|
||||
target.bindings,
|
||||
true)
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_exports_for_legacy_module(exports2: &mut ~[Export2],
|
||||
module_: @Module) {
|
||||
for module_.exported_names.each |name, _exp_node_id| {
|
||||
for self.namespaces.each |namespace| {
|
||||
match self.resolve_definition_of_name_in_module(module_,
|
||||
|
@ -2882,7 +2940,7 @@ impl Resolver {
|
|||
for %?",
|
||||
self.session.str_of(name),
|
||||
module_.def_id);
|
||||
vec::push(exports2, Export2 {
|
||||
vec::push(*exports2, Export2 {
|
||||
reexport: false,
|
||||
name: self.session.str_of(name),
|
||||
def_id: def_id_of_def(target_def)
|
||||
|
@ -2893,7 +2951,7 @@ impl Resolver {
|
|||
%?",
|
||||
self.session.str_of(name),
|
||||
module_.def_id);
|
||||
vec::push(exports2, Export2 {
|
||||
vec::push(*exports2, Export2 {
|
||||
reexport: true,
|
||||
name: self.session.str_of(name),
|
||||
def_id: def_id_of_def(target_def)
|
||||
|
@ -2902,15 +2960,6 @@ impl Resolver {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
match copy module_.def_id {
|
||||
Some(def_id) => {
|
||||
self.export_map2.insert(def_id.node, move exports2);
|
||||
debug!("(computing exports) writing exports for %d (some)",
|
||||
def_id.node);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
// AST resolution
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#[legacy_exports];
|
||||
|
||||
fn foo(x: &uint) -> uint {
|
||||
*x
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#[legacy_exports];
|
||||
|
||||
export foo;
|
||||
|
||||
use comm::*;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#[legacy_exports];
|
||||
#[abi = "rust-intrinsic"]
|
||||
extern mod rusti {
|
||||
#[legacy_exports];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[link(name="cci_iter_lib", vers="0.0")];
|
||||
#[legacy_modes];
|
||||
#[legacy_exports];
|
||||
|
||||
#[inline]
|
||||
fn iter<T>(v: ~[T], f: fn(T)) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#[legacy_modes];
|
||||
#[legacy_exports];
|
||||
|
||||
use dvec::DVec;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#[link(name="cci_no_inline_lib", vers="0.0")];
|
||||
#[legacy_exports];
|
||||
|
||||
// same as cci_iter_lib, more-or-less, but not marked inline
|
||||
fn iter(v: ~[uint], f: fn(uint)) {
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.1")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 10 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.2")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 20 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.3")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 30 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.1")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 10 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.2")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 20 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.3")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 30 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.1")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 10 }
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
vers = "0.2")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn g() -> int { 20 }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#[link(name = "crateresolve4a", vers = "0.1")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 10 }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#[link(name = "crateresolve4a", vers= "0.2")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn g() -> int { 20 }
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// aux-build:crateresolve4a-2.rs
|
||||
#[link(name = "crateresolve4b", vers = "0.1")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod crateresolve4a(vers="0.2");
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// aux-build:crateresolve4a-2.rs
|
||||
#[link(name = "crateresolve4b", vers = "0.2")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod crateresolve4a(vers="0.1");
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
vers = "0.1")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn structural() -> { name: ~str, val: int } {
|
||||
{ name: ~"crateresolve5", val: 10 }
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
vers = "0.2")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn structural() -> { name: ~str, val: int } {
|
||||
{ name: ~"crateresolve5", val: 10 }
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
calories = "100")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 100 }
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
calories = "200")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
fn f() -> int { 200 }
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
vers = "0.1")];
|
||||
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod rustrt {
|
||||
#[legacy_exports];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[link(name = "a", vers = "0.0")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
trait i<T> { }
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#[link(name = "req")];
|
||||
#[crate_type = "lib"];
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod std;
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#[legacy_exports];
|
||||
unsafe fn f(xs: ~[int]) {
|
||||
xs.map(|_x| { unsafe fn q() { fail; } });
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
Could probably be more minimal.
|
||||
*/
|
||||
#[legacy_exports];
|
||||
|
||||
use libc::size_t;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// xfail-fast - check-fast doesn't understand aux-build
|
||||
// aux-build:cci_borrow_lib.rs
|
||||
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod cci_borrow_lib;
|
||||
use cci_borrow_lib::foo;
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// This test makes sure we can do cross-crate inlining on functions
|
||||
// that use capture clauses.
|
||||
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod cci_capture_clause;
|
||||
|
||||
use comm::recv;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// aux-build:cci_nested_lib.rs
|
||||
|
||||
#[legacy_modes];
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod cci_nested_lib;
|
||||
use cci_nested_lib::*;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// xfail-fast - check-fast doesn't understand aux-build
|
||||
// aux-build:cci_no_inline_lib.rs
|
||||
|
||||
#[legacy_exports];
|
||||
|
||||
extern mod cci_no_inline_lib;
|
||||
use cci_no_inline_lib::iter;
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// aux-build:crateresolve4b-1.rs
|
||||
// aux-build:crateresolve4b-2.rs
|
||||
|
||||
#[legacy_exports];
|
||||
|
||||
mod a {
|
||||
#[legacy_exports];
|
||||
extern mod crateresolve4b(vers = "0.1");
|
||||
|
|
Loading…
Reference in New Issue