diff options
| -rw-r--r-- | src/librustc/middle/dead.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-dead-code-1.rs | 7 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index ff372038100..61b013d795e 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -441,6 +441,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { fn should_warn_about_item(&mut self, item: &ast::Item) -> bool { let should_warn = match item.node { ast::ItemStatic(..) + | ast::ItemConst(..) | ast::ItemFn(..) | ast::ItemEnum(..) | ast::ItemStruct(..) => true, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 274bb2e39e0..be79b18bfe9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1334,6 +1334,7 @@ impl Item_ { pub fn descriptive_variant(&self) -> &str { match *self { ItemStatic(..) => "static item", + ItemConst(..) => "constant item", ItemFn(..) => "function", ItemMod(..) => "module", ItemForeignMod(..) => "foreign module", @@ -1341,7 +1342,8 @@ impl Item_ { ItemEnum(..) => "enum", ItemStruct(..) => "struct", ItemTrait(..) => "trait", - _ => "item" + ItemMac(..) | + ItemImpl(..) => "item" } } } diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index a4320b8dc77..998e7c01792 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -35,6 +35,13 @@ pub static used_static2: int = used_static; const USED_STATIC: int = 0; const STATIC_USED_IN_ENUM_DISCRIMINANT: int = 10; +pub const pub_const: int = 0; +const priv_const: int = 0; //~ ERROR: constant item is never used +const used_const: int = 0; +pub const used_const2: int = used_const; +const USED_CONST: int = 0; +const CONST_USED_IN_ENUM_DISCRIMINANT: int = 10; + pub type typ = *const UsedStruct4; pub struct PubStruct; struct PrivStruct; //~ ERROR: struct is never used |
