about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/hir/map/collector.rs2
-rw-r--r--src/librustc/hir/map/mod.rs24
-rw-r--r--src/librustc/hir/mod.rs2
3 files changed, 7 insertions, 21 deletions
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs
index 2cb8120836e..30441c331e4 100644
--- a/src/librustc/hir/map/collector.rs
+++ b/src/librustc/hir/map/collector.rs
@@ -115,7 +115,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
             hir_body_nodes,
         };
         collector.insert_entry(CRATE_NODE_ID, Entry {
-            parent: ast::DUMMY_NODE_ID,
+            parent: CRATE_NODE_ID,
             dep_node: root_mod_sig_dep_index,
             node: Node::Crate,
         });
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index 747c1ac13dd..4f33120b46d 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -59,13 +59,6 @@ impl<'hir> Entry<'hir> {
         }
     }
 
-    fn to_node(self) -> Option<Node<'hir>> {
-        match self.node {
-            Node::Crate => None,
-            _ => Some(self.node),
-        }
-    }
-
     fn fn_decl(&self) -> Option<&FnDecl> {
         match self.node {
             Node::Item(ref item) => {
@@ -568,7 +561,7 @@ impl<'hir> Map<'hir> {
     /// Retrieve the Node corresponding to `id`, returning None if
     /// cannot be found.
     pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
-        let result = self.find_entry(id).and_then(|x| x.to_node());
+        let result = self.find_entry(id).map(|x| x.node);
         if result.is_some() {
             self.read(id);
         }
@@ -638,16 +631,11 @@ impl<'hir> Map<'hir> {
                 return Err(id);
             }
 
-            if let Some(node) = self.find_entry(parent_node) {
-                match node.to_node() {
-                    Some(ref node) => {
-                        if found(node) {
-                            return Ok(parent_node);
-                        } else if bail_early(node) {
-                            return Err(parent_node);
-                        }
-                    }
-                    None => return Err(parent_node),
+            if let Some(entry) = self.find_entry(parent_node) {
+                if found(&entry.node) {
+                    return Ok(parent_node);
+                } else if bail_early(&entry.node) {
+                    return Err(parent_node);
                 }
                 id = parent_node;
             } else {
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index bae7fa391c0..7ac334d84a9 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -2397,7 +2397,5 @@ pub enum Node<'hir> {
     GenericParam(&'hir GenericParam),
     Visibility(&'hir Visibility),
 
-    /// Roots for node trees. Its DepNodeIndex when in `Entry`
-    /// is the dependency node of the crate's root module.
     Crate,
 }