Skip to content

Commit

Permalink
Rollup merge of #30864 - jseyfried:no_record_exports, r=nrc
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 15, 2016
2 parents d9d902e + a353490 commit 22cbdd4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 161 deletions.
8 changes: 5 additions & 3 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
// This code is here instead of in visit_item so that the
// crate module gets processed as well.
if self.prev_level.is_some() {
for export in self.export_map.get(&id).expect("module isn't found in export map") {
if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) {
self.update(node_id, Some(AccessLevel::Exported));
if let Some(exports) = self.export_map.get(&id) {
for export in exports {
if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) {
self.update(node_id, Some(AccessLevel::Exported));
}
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ use resolve_imports::Shadowable;
pub mod diagnostics;

mod check_unused;
mod record_exports;
mod build_reduced_graph;
mod resolve_imports;

Expand Down Expand Up @@ -4014,9 +4013,6 @@ pub fn create_resolver<'a, 'tcx>(session: &'a Session,
resolve_imports::resolve_imports(&mut resolver);
session.abort_if_errors();

record_exports::record(&mut resolver);
session.abort_if_errors();

resolver
}

Expand Down
154 changes: 0 additions & 154 deletions src/librustc_resolve/record_exports.rs

This file was deleted.

17 changes: 17 additions & 0 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
id: directive.id,
is_public: directive.is_public
};

self.add_export(module_, target, &import_resolution[namespace]);
*used_public = name_binding.is_public();
}
UnboundResult => {
Expand Down Expand Up @@ -827,6 +829,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
dest_import_resolution[ns] = ImportResolution {
id: id, is_public: is_public, target: Some(target.clone())
};
self.add_export(module_, *name, &dest_import_resolution[ns]);
}
_ => {}
}
Expand Down Expand Up @@ -919,6 +922,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
id: id,
is_public: is_public
};
self.add_export(module_, name, &dest_import_resolution[namespace]);
}
} else {
// FIXME #30159: This is required for backwards compatability.
Expand All @@ -935,6 +939,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
name);
}

fn add_export(&mut self, module: Module<'b>, name: Name, resolution: &ImportResolution<'b>) {
if !resolution.is_public { return }
let node_id = match module.def_id() {
Some(def_id) => self.resolver.ast_map.as_local_node_id(def_id).unwrap(),
None => return,
};
let export = match resolution.target.as_ref().unwrap().binding.def() {
Some(def) => Export { name: name, def_id: def.def_id() },
None => return,
};
self.resolver.export_map.entry(node_id).or_insert(Vec::new()).push(export);
}

/// Checks that imported names and items don't have the same name.
fn check_for_conflicting_import(&mut self,
import_resolution: &ImportResolutionPerNamespace,
Expand Down

0 comments on commit 22cbdd4

Please sign in to comment.