2013-12-08 01:55:27 -06:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// This implements the dead-code warning pass. It follows middle::reachable
|
|
|
|
// closely. The idea is that all reachable symbols are live, codes called
|
|
|
|
// from live codes are live, and everything else is dead.
|
|
|
|
|
2014-01-11 02:21:53 -06:00
|
|
|
use middle::lint::{allow, contains_lint, DeadCode};
|
|
|
|
use middle::privacy;
|
2013-12-08 01:55:27 -06:00
|
|
|
use middle::ty;
|
|
|
|
use middle::typeck;
|
|
|
|
|
|
|
|
use std::hashmap::HashSet;
|
|
|
|
use syntax::ast;
|
|
|
|
use syntax::ast_map;
|
|
|
|
use syntax::ast_util::{local_def, def_id_of_def, is_local};
|
2014-01-11 02:21:53 -06:00
|
|
|
use syntax::attr;
|
2013-12-08 01:55:27 -06:00
|
|
|
use syntax::codemap;
|
|
|
|
use syntax::parse::token;
|
|
|
|
use syntax::visit::Visitor;
|
|
|
|
use syntax::visit;
|
|
|
|
|
2014-01-11 02:21:53 -06:00
|
|
|
pub static DEAD_CODE_LINT_STR: &'static str = "dead_code";
|
|
|
|
|
2013-12-08 01:55:27 -06:00
|
|
|
// Any local node that may call something in its body block should be
|
2014-01-09 07:05:33 -06:00
|
|
|
// explored. For example, if it's a live NodeItem that is a
|
2013-12-08 01:55:27 -06:00
|
|
|
// function, then we should explore its block to check for codes that
|
|
|
|
// may need to be marked as live.
|
|
|
|
fn should_explore(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
|
|
|
|
if !is_local(def_id) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-27 18:09:29 -06:00
|
|
|
|
2014-01-17 06:23:09 -06:00
|
|
|
match tcx.items.find(def_id.node) {
|
|
|
|
Some(ast_map::NodeItem(..))
|
|
|
|
| Some(ast_map::NodeMethod(..))
|
|
|
|
| Some(ast_map::NodeForeignItem(..))
|
|
|
|
| Some(ast_map::NodeTraitMethod(..)) => true,
|
2013-12-08 01:55:27 -06:00
|
|
|
_ => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MarkSymbolVisitor {
|
|
|
|
worklist: ~[ast::NodeId],
|
|
|
|
method_map: typeck::method_map,
|
|
|
|
tcx: ty::ctxt,
|
|
|
|
live_symbols: ~HashSet<ast::NodeId>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MarkSymbolVisitor {
|
|
|
|
fn new(tcx: ty::ctxt,
|
|
|
|
method_map: typeck::method_map,
|
|
|
|
worklist: ~[ast::NodeId]) -> MarkSymbolVisitor {
|
|
|
|
MarkSymbolVisitor {
|
|
|
|
worklist: worklist,
|
|
|
|
method_map: method_map,
|
|
|
|
tcx: tcx,
|
|
|
|
live_symbols: ~HashSet::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-31 15:19:57 -06:00
|
|
|
fn check_def_id(&mut self, def_id: ast::DefId) {
|
|
|
|
if should_explore(self.tcx, def_id) {
|
|
|
|
self.worklist.push(def_id.node);
|
|
|
|
}
|
|
|
|
self.live_symbols.insert(def_id.node);
|
|
|
|
}
|
|
|
|
|
2013-12-11 19:49:46 -06:00
|
|
|
fn lookup_and_handle_definition(&mut self, id: &ast::NodeId) {
|
2013-12-23 13:15:16 -06:00
|
|
|
let def_map = self.tcx.def_map.borrow();
|
|
|
|
let def = match def_map.get().find(id) {
|
2013-12-08 01:55:27 -06:00
|
|
|
Some(&def) => def,
|
2013-12-11 19:49:46 -06:00
|
|
|
None => return
|
2013-12-08 01:55:27 -06:00
|
|
|
};
|
|
|
|
let def_id = match def {
|
|
|
|
ast::DefVariant(enum_id, _, _) => Some(enum_id),
|
|
|
|
ast::DefPrimTy(_) => None,
|
|
|
|
_ => Some(def_id_of_def(def)),
|
|
|
|
};
|
|
|
|
match def_id {
|
2013-12-31 15:19:57 -06:00
|
|
|
Some(def_id) => self.check_def_id(def_id),
|
|
|
|
None => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn lookup_and_handle_method(&mut self, id: &ast::NodeId,
|
|
|
|
span: codemap::Span) {
|
|
|
|
let method_map = self.method_map.borrow();
|
|
|
|
match method_map.get().find(id) {
|
|
|
|
Some(&typeck::method_map_entry { origin, .. }) => {
|
|
|
|
match origin {
|
|
|
|
typeck::method_static(def_id) => {
|
|
|
|
match ty::provided_source(self.tcx, def_id) {
|
|
|
|
Some(p_did) => self.check_def_id(p_did),
|
|
|
|
None => self.check_def_id(def_id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
typeck::method_param(typeck::method_param {
|
|
|
|
trait_id: trait_id,
|
|
|
|
method_num: index,
|
|
|
|
..
|
|
|
|
})
|
|
|
|
| typeck::method_object(typeck::method_object {
|
|
|
|
trait_id: trait_id,
|
|
|
|
method_num: index,
|
|
|
|
..
|
|
|
|
}) => {
|
|
|
|
let def_id = ty::trait_method(self.tcx,
|
|
|
|
trait_id, index).def_id;
|
|
|
|
self.check_def_id(def_id);
|
|
|
|
}
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
}
|
2013-12-31 15:19:57 -06:00
|
|
|
None => {
|
|
|
|
self.tcx.sess.span_bug(span,
|
|
|
|
"method call expression not \
|
|
|
|
in method map?!")
|
|
|
|
}
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mark_live_symbols(&mut self) {
|
|
|
|
let mut scanned = HashSet::new();
|
|
|
|
while self.worklist.len() > 0 {
|
|
|
|
let id = self.worklist.pop();
|
|
|
|
if scanned.contains(&id) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
scanned.insert(id);
|
2013-12-27 18:09:29 -06:00
|
|
|
|
2014-01-17 06:23:09 -06:00
|
|
|
match self.tcx.items.find(id) {
|
|
|
|
Some(ref node) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
self.live_symbols.insert(id);
|
|
|
|
self.visit_node(node);
|
|
|
|
}
|
|
|
|
None => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_node(&mut self, node: &ast_map::Node) {
|
2013-12-08 01:55:27 -06:00
|
|
|
match *node {
|
2014-01-09 07:05:33 -06:00
|
|
|
ast_map::NodeItem(item, _) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
match item.node {
|
2014-01-09 07:05:33 -06:00
|
|
|
ast::ItemFn(..)
|
|
|
|
| ast::ItemTy(..)
|
|
|
|
| ast::ItemEnum(..)
|
|
|
|
| ast::ItemStruct(..)
|
|
|
|
| ast::ItemStatic(..) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
visit::walk_item(self, item, ());
|
|
|
|
}
|
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
}
|
2014-01-09 07:05:33 -06:00
|
|
|
ast_map::NodeTraitMethod(trait_method, _, _) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
visit::walk_trait_method(self, trait_method, ());
|
|
|
|
}
|
2014-01-09 07:05:33 -06:00
|
|
|
ast_map::NodeMethod(method, _, _) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
visit::walk_block(self, method.body, ());
|
|
|
|
}
|
2014-01-09 07:05:33 -06:00
|
|
|
ast_map::NodeForeignItem(foreign_item, _, _, _) => {
|
2013-12-13 23:08:26 -06:00
|
|
|
visit::walk_foreign_item(self, foreign_item, ());
|
|
|
|
}
|
2013-12-08 01:55:27 -06:00
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Visitor<()> for MarkSymbolVisitor {
|
|
|
|
|
2014-01-06 06:00:46 -06:00
|
|
|
fn visit_expr(&mut self, expr: &ast::Expr, _: ()) {
|
2013-12-08 01:55:27 -06:00
|
|
|
match expr.node {
|
|
|
|
ast::ExprMethodCall(..) => {
|
2013-12-31 15:19:57 -06:00
|
|
|
self.lookup_and_handle_method(&expr.id, expr.span);
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
|
|
|
|
visit::walk_expr(self, expr, ())
|
|
|
|
}
|
|
|
|
|
2013-12-16 17:01:36 -06:00
|
|
|
fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId, _: ()) {
|
2013-12-11 19:49:46 -06:00
|
|
|
self.lookup_and_handle_definition(&id);
|
2013-12-16 17:01:36 -06:00
|
|
|
visit::walk_path(self, path, ());
|
2013-12-11 19:49:46 -06:00
|
|
|
}
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_item(&mut self, _item: &ast::Item, _: ()) {
|
2013-12-08 01:55:27 -06:00
|
|
|
// Do not recurse into items. These items will be added to the
|
|
|
|
// worklist and recursed into manually if necessary.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-11 02:21:53 -06:00
|
|
|
fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
|
|
|
|
contains_lint(attrs, allow, DEAD_CODE_LINT_STR)
|
|
|
|
|| attr::contains_name(attrs, "lang")
|
|
|
|
}
|
|
|
|
|
|
|
|
// This visitor seeds items that
|
|
|
|
// 1) We want to explicitly consider as live:
|
|
|
|
// * Item annotated with #[allow(dead_code)]
|
|
|
|
// - This is done so that if we want to suppress warnings for a
|
|
|
|
// group of dead functions, we only have to annotate the "root".
|
|
|
|
// For example, if both `f` and `g` are dead and `f` calls `g`,
|
|
|
|
// then annotating `f` with `#[allow(dead_code)]` will suppress
|
|
|
|
// warning for both `f` and `g`.
|
|
|
|
// * Item annotated with #[lang=".."]
|
|
|
|
// - This is because lang items are always callable from elsewhere.
|
|
|
|
// or
|
|
|
|
// 2) We are not sure to be live or not
|
|
|
|
// * Implementation of a trait method
|
|
|
|
struct LifeSeeder {
|
2013-12-08 01:55:27 -06:00
|
|
|
worklist: ~[ast::NodeId],
|
|
|
|
}
|
|
|
|
|
2014-01-11 02:21:53 -06:00
|
|
|
impl Visitor<()> for LifeSeeder {
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_item(&mut self, item: &ast::Item, _: ()) {
|
2014-01-11 02:21:53 -06:00
|
|
|
if has_allow_dead_code_or_lang_attr(item.attrs) {
|
|
|
|
self.worklist.push(item.id);
|
|
|
|
}
|
2013-12-08 01:55:27 -06:00
|
|
|
match item.node {
|
2014-01-09 07:05:33 -06:00
|
|
|
ast::ItemImpl(_, Some(ref _trait_ref), _, ref methods) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
for method in methods.iter() {
|
|
|
|
self.worklist.push(method.id);
|
|
|
|
}
|
|
|
|
}
|
2014-01-11 02:21:53 -06:00
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
visit::walk_item(self, item, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
fn visit_fn(&mut self, fk: &visit::FnKind,
|
|
|
|
_: &ast::FnDecl, block: &ast::Block,
|
|
|
|
_: codemap::Span, id: ast::NodeId, _: ()) {
|
|
|
|
// Check for method here because methods are not ast::Item
|
|
|
|
match *fk {
|
|
|
|
visit::FkMethod(_, _, method) => {
|
|
|
|
if has_allow_dead_code_or_lang_attr(method.attrs) {
|
|
|
|
self.worklist.push(id);
|
|
|
|
}
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
_ => ()
|
|
|
|
}
|
2014-01-11 02:21:53 -06:00
|
|
|
visit::walk_block(self, block, ());
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn create_and_seed_worklist(tcx: ty::ctxt,
|
|
|
|
exported_items: &privacy::ExportedItems,
|
|
|
|
reachable_symbols: &HashSet<ast::NodeId>,
|
|
|
|
crate: &ast::Crate) -> ~[ast::NodeId] {
|
|
|
|
let mut worklist = ~[];
|
|
|
|
|
|
|
|
// Preferably, we would only need to seed the worklist with reachable
|
|
|
|
// symbols. However, since the set of reachable symbols differs
|
|
|
|
// depending on whether a crate is built as bin or lib, and we want
|
|
|
|
// the warning to be consistent, we also seed the worklist with
|
|
|
|
// exported symbols.
|
|
|
|
for &id in exported_items.iter() {
|
|
|
|
worklist.push(id);
|
|
|
|
}
|
|
|
|
for &id in reachable_symbols.iter() {
|
|
|
|
worklist.push(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seed entry point
|
2013-12-21 19:25:27 -06:00
|
|
|
match tcx.sess.entry_fn.get() {
|
2013-12-08 01:55:27 -06:00
|
|
|
Some((id, _)) => worklist.push(id),
|
|
|
|
None => ()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seed implemeneted trait methods
|
2014-01-11 02:21:53 -06:00
|
|
|
let mut life_seeder = LifeSeeder {
|
2013-12-08 01:55:27 -06:00
|
|
|
worklist: worklist
|
|
|
|
};
|
2014-01-11 02:21:53 -06:00
|
|
|
visit::walk_crate(&mut life_seeder, crate, ());
|
2013-12-08 01:55:27 -06:00
|
|
|
|
2014-01-11 02:21:53 -06:00
|
|
|
return life_seeder.worklist;
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn find_live(tcx: ty::ctxt,
|
|
|
|
method_map: typeck::method_map,
|
|
|
|
exported_items: &privacy::ExportedItems,
|
|
|
|
reachable_symbols: &HashSet<ast::NodeId>,
|
|
|
|
crate: &ast::Crate)
|
|
|
|
-> ~HashSet<ast::NodeId> {
|
|
|
|
let worklist = create_and_seed_worklist(tcx, exported_items,
|
|
|
|
reachable_symbols, crate);
|
|
|
|
let mut symbol_visitor = MarkSymbolVisitor::new(tcx, method_map, worklist);
|
|
|
|
symbol_visitor.mark_live_symbols();
|
|
|
|
symbol_visitor.live_symbols
|
|
|
|
}
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
fn should_warn(item: &ast::Item) -> bool {
|
2013-12-08 01:55:27 -06:00
|
|
|
match item.node {
|
2014-01-09 07:05:33 -06:00
|
|
|
ast::ItemStatic(..)
|
|
|
|
| ast::ItemFn(..)
|
|
|
|
| ast::ItemEnum(..)
|
|
|
|
| ast::ItemStruct(..) => true,
|
2013-12-08 01:55:27 -06:00
|
|
|
_ => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
fn get_struct_ctor_id(item: &ast::Item) -> Option<ast::NodeId> {
|
2013-12-08 01:55:27 -06:00
|
|
|
match item.node {
|
2014-01-09 07:05:33 -06:00
|
|
|
ast::ItemStruct(struct_def, _) => struct_def.ctor_id,
|
2013-12-08 01:55:27 -06:00
|
|
|
_ => None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DeadVisitor {
|
|
|
|
tcx: ty::ctxt,
|
|
|
|
live_symbols: ~HashSet<ast::NodeId>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DeadVisitor {
|
|
|
|
// id := node id of an item's definition.
|
|
|
|
// ctor_id := `Some` if the item is a struct_ctor (tuple struct),
|
|
|
|
// `None` otherwise.
|
|
|
|
// If the item is a struct_ctor, then either its `id` or
|
|
|
|
// `ctor_id` (unwrapped) is in the live_symbols set. More specifically,
|
|
|
|
// DefMap maps the ExprPath of a struct_ctor to the node referred by
|
|
|
|
// `ctor_id`. On the other hand, in a statement like
|
|
|
|
// `type <ident> <generics> = <ty>;` where <ty> refers to a struct_ctor,
|
|
|
|
// DefMap maps <ty> to `id` instead.
|
|
|
|
fn symbol_is_live(&mut self, id: ast::NodeId,
|
|
|
|
ctor_id: Option<ast::NodeId>) -> bool {
|
|
|
|
if self.live_symbols.contains(&id)
|
2013-12-06 12:51:10 -06:00
|
|
|
|| ctor_id.map_or(false,
|
|
|
|
|ctor| self.live_symbols.contains(&ctor)) {
|
2013-12-08 01:55:27 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// If it's a type whose methods are live, then it's live, too.
|
|
|
|
// This is done to handle the case where, for example, the static
|
|
|
|
// method of a private type is used, but the type itself is never
|
|
|
|
// called directly.
|
|
|
|
let def_id = local_def(id);
|
2013-12-19 21:15:06 -06:00
|
|
|
let inherent_impls = self.tcx.inherent_impls.borrow();
|
|
|
|
match inherent_impls.get().find(&def_id) {
|
2013-12-08 01:55:27 -06:00
|
|
|
None => (),
|
|
|
|
Some(ref impl_list) => {
|
2013-12-22 18:31:20 -06:00
|
|
|
let impl_list = impl_list.borrow();
|
|
|
|
for impl_ in impl_list.get().iter() {
|
2013-12-08 01:55:27 -06:00
|
|
|
for method in impl_.methods.iter() {
|
|
|
|
if self.live_symbols.contains(&method.def_id.node) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
false
|
|
|
|
}
|
2013-12-13 23:08:26 -06:00
|
|
|
|
|
|
|
fn warn_dead_code(&mut self, id: ast::NodeId,
|
|
|
|
span: codemap::Span, ident: &ast::Ident) {
|
2014-01-09 20:29:45 -06:00
|
|
|
self.tcx.sess.add_lint(DeadCode, id, span,
|
2013-12-13 23:08:26 -06:00
|
|
|
format!("code is never used: `{}`",
|
|
|
|
token::ident_to_str(ident)));
|
|
|
|
}
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Visitor<()> for DeadVisitor {
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_item(&mut self, item: &ast::Item, _: ()) {
|
2013-12-08 01:55:27 -06:00
|
|
|
let ctor_id = get_struct_ctor_id(item);
|
|
|
|
if !self.symbol_is_live(item.id, ctor_id) && should_warn(item) {
|
2013-12-13 23:08:26 -06:00
|
|
|
self.warn_dead_code(item.id, item.span, &item.ident);
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
visit::walk_item(self, item, ());
|
|
|
|
}
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_foreign_item(&mut self, fi: &ast::ForeignItem, _: ()) {
|
2013-12-13 23:08:26 -06:00
|
|
|
if !self.symbol_is_live(fi.id, None) {
|
|
|
|
self.warn_dead_code(fi.id, fi.span, &fi.ident);
|
|
|
|
}
|
|
|
|
visit::walk_foreign_item(self, fi, ());
|
|
|
|
}
|
|
|
|
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_fn(&mut self, fk: &visit::FnKind,
|
|
|
|
_: &ast::FnDecl, block: &ast::Block,
|
2013-12-08 01:55:27 -06:00
|
|
|
span: codemap::Span, id: ast::NodeId, _: ()) {
|
2014-01-09 07:05:33 -06:00
|
|
|
// Have to warn method here because methods are not ast::Item
|
2013-12-08 01:55:27 -06:00
|
|
|
match *fk {
|
2014-01-09 07:05:33 -06:00
|
|
|
visit::FkMethod(..) => {
|
2013-12-08 01:55:27 -06:00
|
|
|
let ident = visit::name_of_fn(fk);
|
|
|
|
if !self.symbol_is_live(id, None) {
|
2013-12-13 23:08:26 -06:00
|
|
|
self.warn_dead_code(id, span, &ident);
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
visit::walk_block(self, block, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Overwrite so that we don't warn the trait method itself.
|
2014-01-09 07:05:33 -06:00
|
|
|
fn visit_trait_method(&mut self, trait_method: &ast::TraitMethod, _: ()) {
|
2013-12-08 01:55:27 -06:00
|
|
|
match *trait_method {
|
2014-01-09 07:05:33 -06:00
|
|
|
ast::Provided(method) => visit::walk_block(self, method.body, ()),
|
|
|
|
ast::Required(_) => ()
|
2013-12-08 01:55:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn check_crate(tcx: ty::ctxt,
|
|
|
|
method_map: typeck::method_map,
|
|
|
|
exported_items: &privacy::ExportedItems,
|
|
|
|
reachable_symbols: &HashSet<ast::NodeId>,
|
|
|
|
crate: &ast::Crate) {
|
|
|
|
let live_symbols = find_live(tcx, method_map, exported_items,
|
|
|
|
reachable_symbols, crate);
|
|
|
|
let mut visitor = DeadVisitor { tcx: tcx, live_symbols: live_symbols };
|
|
|
|
visit::walk_crate(&mut visitor, crate, ());
|
|
|
|
}
|