Skip to content

Check even more live Path nodes in dead-code pass #11009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,9 @@ impl Visitor<()> for MarkSymbolVisitor {
visit::walk_expr(self, expr, ())
}

fn visit_ty(&mut self, typ: &ast::Ty, _: ()) {
match typ.node {
ast::ty_path(_, _, ref id) => {
self.lookup_and_handle_definition(id);
}
_ => visit::walk_ty(self, typ, ()),
}
}

fn visit_path(&mut self, _: &ast::Path, id: ast::NodeId, _: ()) {
fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId, _: ()) {
self.lookup_and_handle_definition(&id);
visit::walk_path(self, path, ());
}

fn visit_item(&mut self, _item: @ast::item, _: ()) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/compile-fail/lint-dead-code-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl SemiUsedStruct {
}
struct StructUsedAsField;
struct StructUsedInEnum;
struct StructUsedInGeneric;
pub struct PubStruct2 {
struct_used_as_field: *StructUsedAsField
}
Expand All @@ -54,6 +55,8 @@ pub enum pub_enum3 { Foo = STATIC_USED_IN_ENUM_DISCRIMINANT }
enum priv_enum { foo2, bar2 } //~ ERROR: code is never used
enum used_enum { foo3, bar3 }

fn f<T>() {}

pub fn pub_fn() {
used_fn();
let used_struct1 = UsedStruct1 { x: 1 };
Expand All @@ -67,6 +70,7 @@ pub fn pub_fn() {
USED_STATIC => (),
_ => ()
}
f::<StructUsedInGeneric>();
}
fn priv_fn() { //~ ERROR: code is never used
let unused_struct = PrivStruct;
Expand Down