about summary refs log tree commit diff
path: root/src/libsyntax/ast.rs
diff options
context:
space:
mode:
authorJakub Wieczorek <jakub@jakub.cc>2014-09-20 14:08:10 +0200
committerJakub Wieczorek <jakub@jakub.cc>2014-09-24 21:03:55 +0200
commit3530e4a6471b6948c719f709bc10923c3f5524a5 (patch)
tree9619f9496f20cfcb2ee34cb00b25d590919624af /src/libsyntax/ast.rs
parent2ec795b4f030ec19cf2ddc48fe5e2e158d5c0e42 (diff)
downloadrust-3530e4a6471b6948c719f709bc10923c3f5524a5.tar.gz
rust-3530e4a6471b6948c719f709bc10923c3f5524a5.zip
Use more descriptive names in dead code messages
Diffstat (limited to 'src/libsyntax/ast.rs')
-rw-r--r--src/libsyntax/ast.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 74c69762be1..38d8136c1a1 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1323,6 +1323,22 @@ pub enum Item_ {
     ItemMac(Mac),
 }
 
+impl Item_ {
+    pub fn descriptive_variant(&self) -> &str {
+        match *self {
+            ItemStatic(..) => "static item",
+            ItemFn(..) => "function",
+            ItemMod(..) => "module",
+            ItemForeignMod(..) => "foreign module",
+            ItemTy(..) => "type alias",
+            ItemEnum(..) => "enum",
+            ItemStruct(..) => "struct",
+            ItemTrait(..) => "trait",
+            _ => "item"
+        }
+    }
+}
+
 #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct ForeignItem {
     pub ident: Ident,
@@ -1339,6 +1355,15 @@ pub enum ForeignItem_ {
     ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
 }
 
+impl ForeignItem_ {
+    pub fn descriptive_variant(&self) -> &str {
+        match *self {
+            ForeignItemFn(..) => "foreign function",
+            ForeignItemStatic(..) => "foreign static item"
+        }
+    }
+}
+
 #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum UnboxedClosureKind {
     FnUnboxedClosureKind,