rustc: Warn about dead constants
A few catch-all blocks ended up not having this case for constants. Closes #17925
This commit is contained in:
parent
86509d8d7a
commit
18e41299f9
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue