Skip to content

Commit

Permalink
Mark live codes in struct/enum for dead-code pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ktt3ja committed Dec 16, 2013
1 parent c810ee8 commit fb4a1d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/librustc/middle/dead.rs
Expand Up @@ -107,6 +107,8 @@ impl MarkSymbolVisitor {
match item.node {
ast::item_fn(..)
| ast::item_ty(..)
| ast::item_enum(..)
| ast::item_struct(..)
| ast::item_static(..) => {
visit::walk_item(self, item, ());
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/compile-fail/lint-dead-code-1.rs
Expand Up @@ -27,6 +27,7 @@ static priv_static: int = 0; //~ ERROR: code is never used
static used_static: int = 0;
pub static used_static2: int = used_static;
static USED_STATIC: int = 0;
static STATIC_USED_IN_ENUM_DISCRIMINANT: uint = 10;

pub type typ = ~UsedStruct4;
pub struct PubStruct();
Expand All @@ -41,8 +42,15 @@ struct SemiUsedStruct;
impl SemiUsedStruct {
fn la_la_la() {}
}
struct StructUsedAsField;
struct StructUsedInEnum;
pub struct PubStruct2 {
struct_used_as_field: *StructUsedAsField
}

pub enum pub_enum { foo1, bar1 }
pub enum pub_enum2 { a(~StructUsedInEnum) }
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 }

Expand Down

5 comments on commit fb4a1d8

@bors
Copy link
Contributor

@bors bors commented on fb4a1d8 Dec 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at ktt3ja@fb4a1d8

@bors
Copy link
Contributor

@bors bors commented on fb4a1d8 Dec 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ktt3ja/rust/issue-10956 = fb4a1d8 into auto

@bors
Copy link
Contributor

@bors bors commented on fb4a1d8 Dec 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ktt3ja/rust/issue-10956 = fb4a1d8 merged ok, testing candidate = e7b0e0a

@bors
Copy link
Contributor

@bors bors commented on fb4a1d8 Dec 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on fb4a1d8 Dec 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = e7b0e0a

Please sign in to comment.