We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6642462 commit a9d075eCopy full SHA for a9d075e
src/librustc/hir/map/mod.rs
@@ -561,7 +561,13 @@ impl<'hir> Map<'hir> {
561
/// Retrieve the Node corresponding to `id`, returning None if
562
/// cannot be found.
563
pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
564
- let result = self.find_entry(id).map(|x| x.node);
+ 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
+ });
571
if result.is_some() {
572
self.read(id);
573
}
@@ -632,6 +638,9 @@ impl<'hir> Map<'hir> {
632
638
633
639
634
640
if let Some(entry) = self.find_entry(parent_node) {
641
642
+ return Err(id);
643
635
644
if found(&entry.node) {
636
645
return Ok(parent_node);
637
646
} else if bail_early(&entry.node) {
0 commit comments