Skip to content

Commit a9d075e

Browse files
committed
Revert crate root changes
1 parent 6642462 commit a9d075e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustc/hir/map/mod.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,13 @@ impl<'hir> Map<'hir> {
561561
/// Retrieve the Node corresponding to `id`, returning None if
562562
/// cannot be found.
563563
pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
564-
let result = self.find_entry(id).map(|x| x.node);
564+
let result = self.find_entry(id).and_then(|entry| {
565+
if let Node::Crate = entry.node {
566+
None
567+
} else {
568+
Some(entry.node)
569+
}
570+
});
565571
if result.is_some() {
566572
self.read(id);
567573
}
@@ -632,6 +638,9 @@ impl<'hir> Map<'hir> {
632638
}
633639

634640
if let Some(entry) = self.find_entry(parent_node) {
641+
if let Node::Crate = entry.node {
642+
return Err(id);
643+
}
635644
if found(&entry.node) {
636645
return Ok(parent_node);
637646
} else if bail_early(&entry.node) {

0 commit comments

Comments
 (0)