Skip to content

Commit

Permalink
EmbargoVisitor::reexports isn't needed
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Nov 5, 2015
1 parent 5092b09 commit 1d69397
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,6 @@ struct EmbargoVisitor<'a, 'tcx: 'a> {
// may jump across private boundaries through reexport statements or type aliases.
exported_items: ExportedItems,

// This sets contains all the destination nodes which are publicly
// re-exported. This is *not* a set of all reexported nodes, only a set of
// all nodes which are reexported *and* reachable from external crates. This
// means that the destination of the reexport is exported, and hence the
// destination must also be exported.
reexports: NodeSet,

// Items that are directly public without help of reexports or type aliases.
// These two fields are closely related to one another in that they are only
// used for generation of the `public_items` set, not for privacy checking at
Expand Down Expand Up @@ -237,7 +230,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
_ => {
self.prev_public = self.prev_public && item.vis == hir::Public;
self.prev_exported = (self.prev_exported && item.vis == hir::Public) ||
self.reexports.contains(&item.id);
self.exported_items.contains(&item.id);

self.maybe_insert_id(item.id);
}
Expand Down Expand Up @@ -347,7 +340,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
for foreign_item in &foreign_mod.items {
let public = self.prev_public && foreign_item.vis == hir::Public;
let exported = (self.prev_exported && foreign_item.vis == hir::Public) ||
self.reexports.contains(&foreign_item.id);
self.exported_items.contains(&foreign_item.id);

if public {
self.public_items.insert(foreign_item.id);
Expand Down Expand Up @@ -387,7 +380,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
assert!(self.export_map.contains_key(&id), "wut {}", id);
for export in self.export_map.get(&id).unwrap() {
if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) {
self.reexports.insert(node_id);
self.exported_items.insert(node_id);
}
}
}
Expand Down Expand Up @@ -1532,17 +1525,14 @@ pub fn check_crate(tcx: &ty::ctxt,
tcx: tcx,
exported_items: NodeSet(),
public_items: NodeSet(),
reexports: NodeSet(),
export_map: export_map,
prev_exported: true,
prev_public: true,
};
loop {
let before = (visitor.exported_items.len(), visitor.public_items.len(),
visitor.reexports.len());
let before = (visitor.exported_items.len(), visitor.public_items.len());
visit::walk_crate(&mut visitor, krate);
let after = (visitor.exported_items.len(), visitor.public_items.len(),
visitor.reexports.len());
let after = (visitor.exported_items.len(), visitor.public_items.len());
if after == before {
break
}
Expand Down

0 comments on commit 1d69397

Please sign in to comment.