// 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;
use syntax::ast;
use syntax::attr;
use rustc_front::hir;
-use rustc_front::visit::Visitor;
-use rustc_front::visit;
+use rustc_front::intravisit::Visitor;
+use rustc_front::intravisit;
// Returns true if the given set of generics implies that the item it's
// associated with must be inlined.
}
impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
-
fn visit_expr(&mut self, expr: &hir::Expr) {
-
match expr.node {
hir::ExprPath(..) => {
let def = match self.tcx.def_map.borrow().get(&expr.id) {
// 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);
}
_ => {}
}
- visit::walk_expr(self, expr)
- }
-
- fn visit_item(&mut self, _item: &hir::Item) {
- // Do not recurse into items. These items will be added to the worklist
- // and recursed into manually if necessary.
+ intravisit::walk_expr(self, expr)
}
}
match item.node {
hir::ItemFn(_, _, _, _, _, ref search_block) => {
if item_might_be_inlined(&*item) {
- visit::walk_block(self, &**search_block)
+ intravisit::walk_block(self, &**search_block)
}
}
self.visit_expr(&*expr);
}
hir::MethodTraitItem(_, Some(ref body)) => {
- visit::walk_block(self, body);
+ intravisit::walk_block(self, body);
}
hir::TypeTraitItem(..) => {}
}
hir::ImplItemKind::Method(ref sig, ref body) => {
let did = self.tcx.map.get_parent_did(search_item);
if method_might_be_inlined(self.tcx, sig, impl_item, did) {
- visit::walk_block(self, body)
+ intravisit::walk_block(self, body)
}
}
hir::ImplItemKind::Type(_) => {}
// 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>,
}
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);
}
}
}
-
- visit::walk_item(self, 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);
// 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() {
}
{
let mut collect_private_impl_items = CollectPrivateImplItemsVisitor {
- exported_items: exported_items,
+ access_levels: access_levels,
worklist: &mut reachable_context.worklist,
};
-
- visit::walk_crate(&mut collect_private_impl_items, tcx.map.krate());
+ tcx.map.krate().visit_all_items(&mut collect_private_impl_items);
}
// Step 2: Mark all symbols that the symbols on the worklist touch.