@@ -337,23 +337,28 @@ impl<'hir> Map<'hir> {
337337    } 
338338
339339    fn  find_entry ( & self ,  id :  HirId )  -> Option < Entry < ' hir > >  { 
340-         Some ( self . get_entry ( id) ) 
341-     } 
342- 
343-     fn  get_entry ( & self ,  id :  HirId )  -> Entry < ' hir >  { 
344340        if  id. local_id  == ItemLocalId :: from_u32 ( 0 )  { 
345341            let  owner = self . tcx . hir_owner ( id. owner ) ; 
346-             Entry  {  parent :  owner. parent ,  node :  owner. node  } 
342+             owner . map ( |owner|  Entry  {  parent :  owner. parent ,  node :  owner. node  } ) 
347343        }  else  { 
348344            let  owner = self . tcx . hir_owner_nodes ( id. owner ) ; 
349-             let  node = owner. nodes [ id. local_id ] . as_ref ( ) . unwrap ( ) ; 
350-             // FIXME(eddyb) use a single generic type insted of having both 
351-             // `Entry` and `ParentedNode`, which are effectively the same. 
352-             // Alternatively, rewrite code using `Entry` to use `ParentedNode`. 
353-             Entry  {  parent :  HirId  {  owner :  id. owner ,  local_id :  node. parent  } ,  node :  node. node  } 
345+             owner. and_then ( |owner| { 
346+                 let  node = owner. nodes [ id. local_id ] . as_ref ( ) ; 
347+                 // FIXME(eddyb) use a single generic type insted of having both 
348+                 // `Entry` and `ParentedNode`, which are effectively the same. 
349+                 // Alternatively, rewrite code using `Entry` to use `ParentedNode`. 
350+                 node. map ( |node| Entry  { 
351+                     parent :  HirId  {  owner :  id. owner ,  local_id :  node. parent  } , 
352+                     node :  node. node , 
353+                 } ) 
354+             } ) 
354355        } 
355356    } 
356357
358+     fn  get_entry ( & self ,  id :  HirId )  -> Entry < ' hir >  { 
359+         self . find_entry ( id) . unwrap ( ) 
360+     } 
361+ 
357362    pub  fn  item ( & self ,  id :  HirId )  -> & ' hir  Item < ' hir >  { 
358363        match  self . find ( id) . unwrap ( )  { 
359364            Node :: Item ( item)  => item, 
@@ -376,7 +381,7 @@ impl<'hir> Map<'hir> {
376381    } 
377382
378383    pub  fn  body ( & self ,  id :  BodyId )  -> & ' hir  Body < ' hir >  { 
379-         self . tcx . hir_owner_nodes ( id. hir_id . owner ) . bodies . get ( & id. hir_id . local_id ) . unwrap ( ) 
384+         self . tcx . hir_owner_nodes ( id. hir_id . owner ) . unwrap ( ) . bodies . get ( & id. hir_id . local_id ) . unwrap ( ) 
380385    } 
381386
382387    pub  fn  fn_decl_by_hir_id ( & self ,  hir_id :  HirId )  -> Option < & ' hir  FnDecl < ' hir > >  { 
@@ -536,8 +541,9 @@ impl<'hir> Map<'hir> {
536541
537542    /// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found. 
538543pub  fn  find ( & self ,  hir_id :  HirId )  -> Option < Node < ' hir > >  { 
539-         let  node = self . get_entry ( hir_id) . node ; 
540-         if  let  Node :: Crate ( ..)  = node {  None  }  else  {  Some ( node)  } 
544+         self . find_entry ( hir_id) . and_then ( |entry| { 
545+             if  let  Node :: Crate ( ..)  = entry. node  {  None  }  else  {  Some ( entry. node )  } 
546+         } ) 
541547    } 
542548
543549    /// Similar to `get_parent`; returns the parent HIR Id, or just `hir_id` if there 
0 commit comments