about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-03-16 05:47:18 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-03-25 14:07:19 -0400
commit5e26508744850e9c541e83d27f710cf221360fbc (patch)
tree4b63797d18c7831528959a8d15a2c412b30ce22e
parent7b6270b53794adf62e16918a159e5e5eecb9a60e (diff)
refactor DefPathData variants
In particular, remove the name from the Impl, since that name is
synthesized and is not predictable (it tends to break incr. comp.).

Also rename the variants to be a bit more uniform and remove some
distinctions that we were not really taking advantage of anywhere.
-rw-r--r--src/librustc/front/map/collector.rs25
-rw-r--r--src/librustc/front/map/definitions.rs22
2 files changed, 24 insertions, 23 deletions
diff --git a/src/librustc/front/map/collector.rs b/src/librustc/front/map/collector.rs
index 7f66b56b2d3..4ae03b1b9d7 100644
--- a/src/librustc/front/map/collector.rs
+++ b/src/librustc/front/map/collector.rs
@@ -133,11 +133,16 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
         // Pick the def data. This need not be unique, but the more
         // information we encapsulate into
         let def_data = match i.node {
-            ItemDefaultImpl(..) | ItemImpl(..) => DefPathData::Impl(i.name),
-            ItemEnum(..) | ItemStruct(..) | ItemTrait(..) => DefPathData::Type(i.name),
-            ItemExternCrate(..) | ItemMod(..) => DefPathData::Mod(i.name),
-            ItemStatic(..) | ItemConst(..) | ItemFn(..) => DefPathData::Value(i.name),
-            _ => DefPathData::Misc,
+            ItemDefaultImpl(..) | ItemImpl(..) =>
+                DefPathData::Impl,
+            ItemEnum(..) | ItemStruct(..) | ItemTrait(..) |
+            ItemExternCrate(..) | ItemMod(..) | ItemForeignMod(..) |
+            ItemTy(..) =>
+                DefPathData::TypeNs(i.name),
+            ItemStatic(..) | ItemConst(..) | ItemFn(..) =>
+                DefPathData::ValueNs(i.name),
+            ItemUse(..) =>
+                DefPathData::Misc,
         };
 
         self.insert_def(i.id, NodeItem(i), def_data);
@@ -202,7 +207,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
     fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) {
         self.insert_def(foreign_item.id,
                         NodeForeignItem(foreign_item),
-                        DefPathData::Value(foreign_item.name));
+                        DefPathData::ValueNs(foreign_item.name));
 
         let parent_node = self.parent_node;
         self.parent_node = foreign_item.id;
@@ -222,8 +227,8 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
 
     fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
         let def_data = match ti.node {
-            MethodTraitItem(..) | ConstTraitItem(..) => DefPathData::Value(ti.name),
-            TypeTraitItem(..) => DefPathData::Type(ti.name),
+            MethodTraitItem(..) | ConstTraitItem(..) => DefPathData::ValueNs(ti.name),
+            TypeTraitItem(..) => DefPathData::TypeNs(ti.name),
         };
 
         self.insert(ti.id, NodeTraitItem(ti));
@@ -246,8 +251,8 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
 
     fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
         let def_data = match ii.node {
-            ImplItemKind::Method(..) | ImplItemKind::Const(..) => DefPathData::Value(ii.name),
-            ImplItemKind::Type(..) => DefPathData::Type(ii.name),
+            ImplItemKind::Method(..) | ImplItemKind::Const(..) => DefPathData::ValueNs(ii.name),
+            ImplItemKind::Type(..) => DefPathData::TypeNs(ii.name),
         };
 
         self.insert_def(ii.id, NodeImplItem(ii), def_data);
diff --git a/src/librustc/front/map/definitions.rs b/src/librustc/front/map/definitions.rs
index 4d5da12cad2..82574b85229 100644
--- a/src/librustc/front/map/definitions.rs
+++ b/src/librustc/front/map/definitions.rs
@@ -144,10 +144,9 @@ pub enum DefPathData {
     Misc,
 
     // Different kinds of items and item-like things:
-    Impl(ast::Name),
-    Type(ast::Name),
-    Mod(ast::Name),
-    Value(ast::Name),
+    Impl,
+    TypeNs(ast::Name), // something in the type NS
+    ValueNs(ast::Name), // something in the value NS
     MacroDef(ast::Name),
     ClosureExpr,
 
@@ -159,10 +158,6 @@ pub enum DefPathData {
     StructCtor, // implicit ctor for a tuple-like struct
     Initializer, // initializer for a const
     Binding(ast::Name), // pattern binding
-
-    // An external crate that does not have an `extern crate` in this
-    // crate.
-    DetachedCrate(ast::Name),
 }
 
 impl Definitions {
@@ -247,20 +242,21 @@ impl DefPathData {
     pub fn as_interned_str(&self) -> InternedString {
         use self::DefPathData::*;
         match *self {
-            Impl(name) |
-            Type(name) |
-            Mod(name) |
-            Value(name) |
+            TypeNs(name) |
+            ValueNs(name) |
             MacroDef(name) |
             TypeParam(name) |
             LifetimeDef(name) |
             EnumVariant(name) |
-            DetachedCrate(name) |
             Binding(name) |
             Field(name) => {
                 name.as_str()
             }
 
+            Impl => {
+                InternedString::new("{{impl}}")
+            }
+
             // note that this does not show up in user printouts
             CrateRoot => {
                 InternedString::new("{{root}}")