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> {
561
561
/// Retrieve the Node corresponding to `id`, returning None if
562
562
/// cannot be found.
563
563
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
+ } ) ;
565
571
if result. is_some ( ) {
566
572
self . read ( id) ;
567
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
+ if let Node :: Crate = entry. node {
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 ) {
You can’t perform that action at this time.
0 commit comments