about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-08-26 00:20:24 +0100
committervarkor <github@varkor.com>2018-08-27 21:46:23 +0100
commita9d075e756382248707f48ef23a7088322a79925 (patch)
tree7c3498cde1ccff62d1aa11a417011da24494f7dc /src
parent6642462ef67c4ff4fbf55dce852f1b01ca3f9edf (diff)
Revert crate root changes
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/map/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index 4f33120b46d..6fffde7cab5 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -561,7 +561,13 @@ 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).map(|x| x.node);
+        let result = self.find_entry(id).and_then(|entry| {
+            if let Node::Crate = entry.node {
+                None
+            } else {
+                Some(entry.node)
+            }
+        });
         if result.is_some() {
             self.read(id);
         }
@@ -632,6 +638,9 @@ impl<'hir> Map<'hir> {
             }
 
             if let Some(entry) = self.find_entry(parent_node) {
+                if let Node::Crate = entry.node {
+                    return Err(id);
+                }
                 if found(&entry.node) {
                     return Ok(parent_node);
                 } else if bail_early(&entry.node) {