From a9d075e756382248707f48ef23a7088322a79925 Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 26 Aug 2018 00:20:24 +0100 Subject: [PATCH] Revert crate root changes --- src/librustc/hir/map/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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> { - 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) {