Skip to content

Commit

Permalink
librustc: Fix cross-crate reexports. rs=blocking-servo
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Nov 16, 2012
1 parent cb355bf commit 6430517
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 27 deletions.
18 changes: 9 additions & 9 deletions src/libcore/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

use m_float = f64;

use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
use f64::logarithm;
use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
use f64::{erf, erfc, exp, expm1, exp2, abs_sub};
use f64::{mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp};
use f64::{lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix};
use f64::{modf, pow, round, sinh, tanh, tgamma, trunc};
use f64::signbit;
use f64::{j0, j1, jn, y0, y1, yn};
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
pub use f64::logarithm;
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
pub use f64::{erf, erfc, exp, expm1, exp2, abs_sub};
pub use f64::{mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp};
pub use f64::{lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix};
pub use f64::{modf, pow, round, sinh, tanh, tgamma, trunc};
pub use f64::signbit;
pub use f64::{j0, j1, jn, y0, y1, yn};
use cmp::{Eq, Ord};
use num::from_int;

Expand Down
46 changes: 28 additions & 18 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ impl Resolver {
// avoid creating cycles in the
// module graph.

let resolution = @ImportResolution(Private, dummy_sp());
let resolution = @ImportResolution(Public, dummy_sp());
resolution.outstanding_references = 0;

match existing_module.parent_link {
Expand Down Expand Up @@ -3199,23 +3199,26 @@ impl Resolver {
fn add_exports_of_namebindings(exports2: &mut ~[Export2],
ident: ident,
namebindings: @NameBindings,
ns: Namespace,
reexport: bool) {
for [ TypeNS, ValueNS ].each |ns| {
match (namebindings.def_for_namespace(*ns),
namebindings.privacy_for_namespace(*ns)) {
(Some(d), Some(Public)) => {
debug!("(computing exports) YES: %s '%s' \
=> %?",
if reexport { ~"reexport" } else { ~"export"},
self.session.str_of(ident),
def_id_of_def(d));
exports2.push(Export2 {
reexport: reexport,
name: self.session.str_of(ident),
def_id: def_id_of_def(d)
});
}
_ => ()
match (namebindings.def_for_namespace(ns),
namebindings.privacy_for_namespace(ns)) {
(Some(d), Some(Public)) => {
debug!("(computing exports) YES: %s '%s' => %?",
if reexport { ~"reexport" } else { ~"export"},
self.session.str_of(ident),
def_id_of_def(d));
exports2.push(Export2 {
reexport: reexport,
name: self.session.str_of(ident),
def_id: def_id_of_def(d)
});
}
(Some(_), Some(privacy)) => {
debug!("(computing reexports) NO: privacy %?", privacy);
}
(d_opt, p_opt) => {
debug!("(computing reexports) NO: %?, %?", d_opt, p_opt);
}
}
}
Expand All @@ -3227,7 +3230,13 @@ impl Resolver {
self.add_exports_of_namebindings(exports2,
*ident,
*namebindings,
false)
TypeNS,
false);
self.add_exports_of_namebindings(exports2,
*ident,
*namebindings,
ValueNS,
false);
}

for module_.import_resolutions.each_ref |ident, importresolution| {
Expand All @@ -3244,6 +3253,7 @@ impl Resolver {
self.add_exports_of_namebindings(exports2,
*ident,
target.bindings,
*ns,
true)
}
_ => ()
Expand Down
11 changes: 11 additions & 0 deletions src/test/auxiliary/pub_use_mods_xcrate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub mod a {
pub mod b {
pub mod c {
fn f(){}
fn g(){}
}
}

pub use b::c;
}

8 changes: 8 additions & 0 deletions src/test/run-pass/pub_use_mods_xcrate_exe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// xfail-fast
// aux-build:pub_use_mods_xcrate.rs

extern mod pub_use_mods_xcrate;
use pub_use_mods_xcrate::a::c;

fn main(){}

0 comments on commit 6430517

Please sign in to comment.