]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/reachable.rs
Implement the translation item collector.
[rust.git] / src / librustc / middle / reachable.rs
index 86237a2321a722550b6e6aa9e18c5b9480d7e85f..6373bfbc55ee65c70e8276916c76d9ad50e6a057 100644 (file)
@@ -15,8 +15,9 @@
 // makes all other generics or inline functions that it references
 // reachable as well.
 
+use dep_graph::DepNode;
 use front::map as ast_map;
-use middle::def;
+use middle::def::Def;
 use middle::def_id::DefId;
 use middle::ty;
 use middle::privacy;
@@ -107,7 +108,7 @@ fn visit_expr(&mut self, expr: &hir::Expr) {
                             // If this path leads to a constant, then we need to
                             // recurse into the constant to continue finding
                             // items that are reachable.
-                            def::DefConst(..) | def::DefAssociatedConst(..) => {
+                            Def::Const(..) | Def::AssociatedConst(..) => {
                                 self.worklist.push(node_id);
                             }
 
@@ -329,7 +330,7 @@ fn propagate_node(&mut self, node: &ast_map::Node,
 // trait items are used from inlinable code through method call syntax or UFCS, or their
 // trait is a lang item.
 struct CollectPrivateImplItemsVisitor<'a> {
-    exported_items: &'a privacy::ExportedItems,
+    access_levels: &'a privacy::AccessLevels,
     worklist: &'a mut Vec<ast::NodeId>,
 }
 
@@ -337,7 +338,7 @@ impl<'a, 'v> Visitor<'v> for CollectPrivateImplItemsVisitor<'a> {
     fn visit_item(&mut self, item: &hir::Item) {
         // We need only trait impls here, not inherent impls, and only non-exported ones
         if let hir::ItemImpl(_, _, _, Some(_), _, ref impl_items) = item.node {
-            if !self.exported_items.contains(&item.id) {
+            if !self.access_levels.is_reachable(item.id) {
                 for impl_item in impl_items {
                     self.worklist.push(impl_item.id);
                 }
@@ -347,8 +348,9 @@ fn visit_item(&mut self, item: &hir::Item) {
 }
 
 pub fn find_reachable(tcx: &ty::ctxt,
-                      exported_items: &privacy::ExportedItems)
+                      access_levels: &privacy::AccessLevels)
                       -> NodeSet {
+    let _task = tcx.dep_graph.in_task(DepNode::Reachability);
 
     let mut reachable_context = ReachableContext::new(tcx);
 
@@ -357,7 +359,7 @@ pub fn find_reachable(tcx: &ty::ctxt,
     //         If other crates link to us, they're going to expect to be able to
     //         use the lang items, so we need to be sure to mark them as
     //         exported.
-    for id in exported_items {
+    for (id, _) in &access_levels.map {
         reachable_context.worklist.push(*id);
     }
     for (_, item) in tcx.lang_items.items() {
@@ -369,7 +371,7 @@ pub fn find_reachable(tcx: &ty::ctxt,
     }
     {
         let mut collect_private_impl_items = CollectPrivateImplItemsVisitor {
-            exported_items: exported_items,
+            access_levels: access_levels,
             worklist: &mut reachable_context.worklist,
         };
         tcx.map.krate().visit_all_items(&mut collect_private_impl_items);