File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments