diff options
| author | Kiet Tran <ktt3ja@gmail.com> | 2013-12-16 18:01:36 -0500 |
|---|---|---|
| committer | Kiet Tran <ktt3ja@gmail.com> | 2013-12-16 18:01:36 -0500 |
| commit | 05a41dc75f499e5e78e2bee6de6d0634ce8a03c9 (patch) | |
| tree | 737d67a21fee5570e417a77244c310c5539b7e80 | |
| parent | 35e5056b6a89d97d386416da44058cc736994ba9 (diff) | |
| download | rust-05a41dc75f499e5e78e2bee6de6d0634ce8a03c9.tar.gz rust-05a41dc75f499e5e78e2bee6de6d0634ce8a03c9.zip | |
Check even more live Path nodes in dead-code pass
| -rw-r--r-- | src/librustc/middle/dead.rs | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-dead-code-1.rs | 4 |
2 files changed, 6 insertions, 10 deletions
diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 1b127057714..fe4da4181da 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -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, _: ()) { diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index cedc25eb150..b029866060d 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -44,6 +44,7 @@ impl SemiUsedStruct { } struct StructUsedAsField; struct StructUsedInEnum; +struct StructUsedInGeneric; pub struct PubStruct2 { struct_used_as_field: *StructUsedAsField } @@ -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 }; @@ -67,6 +70,7 @@ pub fn pub_fn() { USED_STATIC => (), _ => () } + f::<StructUsedInGeneric>(); } fn priv_fn() { //~ ERROR: code is never used let unused_struct = PrivStruct; |
