Skip to content

Commit 3e850c3

Browse files
committed
librustc: Stop reexporting all of core in every crate. rs=really-bad-bug
1 parent f4e107e commit 3e850c3

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/librustc/front/core_inject.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ fn inject_libcore_ref(sess: Session,
3232

3333
let vi1 = @{node: ast::view_item_use(sess.ident_of(~"core"), ~[], n1),
3434
attrs: ~[],
35-
vis: ast::public,
35+
vis: ast::private,
3636
span: dummy_sp()};
3737
let vp = spanned(ast::view_path_glob(
3838
ident_to_path(dummy_sp(), sess.ident_of(~"core")),
3939
n2));
4040
let vi2 = @{node: ast::view_item_import(~[vp]),
4141
attrs: ~[],
42-
vis: ast::public,
42+
vis: ast::private,
4343
span: dummy_sp()};
4444

4545
let vis = vec::append(~[vi1, vi2], crate.node.module.view_items);

src/librustc/middle/resolve.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ impl Resolver {
16911691
// avoid creating cycles in the
16921692
// module graph.
16931693

1694-
let resolution = @ImportResolution(Public, dummy_sp());
1694+
let resolution = @ImportResolution(Private, dummy_sp());
16951695
resolution.outstanding_references = 0;
16961696

16971697
match existing_module.parent_link {
@@ -2159,7 +2159,8 @@ impl Resolver {
21592159
let span = import_directive.span;
21602160
let p = import_directive.privacy;
21612161
resolution_result =
2162-
self.resolve_glob_import(p, module_,
2162+
self.resolve_glob_import(p,
2163+
module_,
21632164
containing_module,
21642165
span);
21652166
}
@@ -2284,7 +2285,6 @@ impl Resolver {
22842285
fn get_binding(import_resolution: @ImportResolution,
22852286
namespace: Namespace)
22862287
-> NamespaceResult {
2287-
22882288
// Import resolutions must be declared with "pub"
22892289
// in order to be exported.
22902290
if import_resolution.privacy == Private {
@@ -2506,14 +2506,13 @@ impl Resolver {
25062506
containing_module: @Module,
25072507
span: span)
25082508
-> ResolveResult<()> {
2509-
25102509
// This function works in a highly imperative manner; it eagerly adds
25112510
// everything it can to the list of import resolutions of the module
25122511
// node.
2512+
debug!("(resolving glob import) resolving %? glob import", privacy);
25132513

25142514
// We must bail out if the node has unresolved imports of any kind
25152515
// (including globs).
2516-
25172516
if !(*containing_module).all_imports_resolved() {
25182517
debug!("(resolving glob import) target module has unresolved \
25192518
imports; bailing out");
@@ -2590,8 +2589,7 @@ impl Resolver {
25902589
match module_.import_resolutions.find(ident) {
25912590
None => {
25922591
// Create a new import resolution from this child.
2593-
dest_import_resolution = @ImportResolution(privacy,
2594-
span);
2592+
dest_import_resolution = @ImportResolution(privacy, span);
25952593
module_.import_resolutions.insert
25962594
(ident, dest_import_resolution);
25972595
}
@@ -2602,10 +2600,11 @@ impl Resolver {
26022600

26032601

26042602
debug!("(resolving glob import) writing resolution `%s` in `%s` \
2605-
to `%s`",
2603+
to `%s`, privacy=%?",
26062604
self.session.str_of(ident),
26072605
self.module_to_str(containing_module),
2608-
self.module_to_str(module_));
2606+
self.module_to_str(module_),
2607+
dest_import_resolution.privacy);
26092608

26102609
// Merge the child item into the import resolution.
26112610
if (*name_bindings).defined_in_namespace(ValueNS) {
@@ -3142,14 +3141,18 @@ impl Resolver {
31423141

31433142
fn record_exports_for_module_subtree(module_: @Module) {
31443143
// If this isn't a local crate, then bail out. We don't need to record
3145-
// exports for local crates.
3144+
// exports for nonlocal crates.
31463145

31473146
match module_.def_id {
31483147
Some(def_id) if def_id.crate == local_crate => {
31493148
// OK. Continue.
3149+
debug!("(recording exports for module subtree) recording \
3150+
exports for local module");
31503151
}
31513152
None => {
31523153
// Record exports for the root module.
3154+
debug!("(recording exports for module subtree) recording \
3155+
exports for root module");
31533156
}
31543157
Some(_) => {
31553158
// Bail out.
@@ -3222,15 +3225,21 @@ impl Resolver {
32223225
}
32233226
32243227
fn add_exports_for_module(exports2: &mut ~[Export2], module_: @Module) {
3225-
32263228
for module_.children.each_ref |ident, namebindings| {
32273229
debug!("(computing exports) maybe export '%s'",
32283230
self.session.str_of(*ident));
3229-
self.add_exports_of_namebindings(exports2, *ident,
3230-
*namebindings, false)
3231+
self.add_exports_of_namebindings(exports2,
3232+
*ident,
3233+
*namebindings,
3234+
false)
32313235
}
32323236
32333237
for module_.import_resolutions.each_ref |ident, importresolution| {
3238+
if importresolution.privacy != Public {
3239+
debug!("(computing exports) not reexporting private `%s`",
3240+
self.session.str_of(*ident));
3241+
loop;
3242+
}
32343243
for [ TypeNS, ValueNS ].each |ns| {
32353244
match importresolution.target_for_namespace(*ns) {
32363245
Some(target) => {

0 commit comments

Comments
 (0)