@@ -170,6 +170,7 @@ impl<'hir> Map<'hir> {
170170 }
171171
172172 #[ inline]
173+ #[ track_caller]
173174 pub fn local_def_id ( self , hir_id : HirId ) -> LocalDefId {
174175 self . opt_local_def_id ( hir_id) . unwrap_or_else ( || {
175176 bug ! (
@@ -310,6 +311,7 @@ impl<'hir> Map<'hir> {
310311 }
311312 }
312313
314+ #[ track_caller]
313315 pub fn get_parent_node ( self , hir_id : HirId ) -> HirId {
314316 self . find_parent_node ( hir_id)
315317 . unwrap_or_else ( || bug ! ( "No parent for node {:?}" , self . node_to_string( hir_id) ) )
@@ -334,12 +336,14 @@ impl<'hir> Map<'hir> {
334336 }
335337
336338 /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
339+ #[ track_caller]
337340 pub fn get ( self , id : HirId ) -> Node < ' hir > {
338341 self . find ( id) . unwrap_or_else ( || bug ! ( "couldn't find hir id {} in the HIR map" , id) )
339342 }
340343
341344 /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
342345 #[ inline]
346+ #[ track_caller]
343347 pub fn get_by_def_id ( self , id : LocalDefId ) -> Node < ' hir > {
344348 self . find_by_def_id ( id) . unwrap_or_else ( || bug ! ( "couldn't find {:?} in the HIR map" , id) )
345349 }
@@ -377,6 +381,7 @@ impl<'hir> Map<'hir> {
377381 self . tcx . hir_owner_nodes ( id. hir_id . owner ) . unwrap ( ) . bodies [ & id. hir_id . local_id ]
378382 }
379383
384+ #[ track_caller]
380385 pub fn fn_decl_by_hir_id ( self , hir_id : HirId ) -> Option < & ' hir FnDecl < ' hir > > {
381386 if let Some ( node) = self . find ( hir_id) {
382387 node. fn_decl ( )
@@ -385,6 +390,7 @@ impl<'hir> Map<'hir> {
385390 }
386391 }
387392
393+ #[ track_caller]
388394 pub fn fn_sig_by_hir_id ( self , hir_id : HirId ) -> Option < & ' hir FnSig < ' hir > > {
389395 if let Some ( node) = self . find ( hir_id) {
390396 node. fn_sig ( )
@@ -393,6 +399,7 @@ impl<'hir> Map<'hir> {
393399 }
394400 }
395401
402+ #[ track_caller]
396403 pub fn enclosing_body_owner ( self , hir_id : HirId ) -> LocalDefId {
397404 for ( _, node) in self . parent_iter ( hir_id) {
398405 if let Some ( body) = associated_body ( node) {
@@ -408,7 +415,7 @@ impl<'hir> Map<'hir> {
408415 /// item (possibly associated), a closure, or a `hir::AnonConst`.
409416 pub fn body_owner ( self , BodyId { hir_id } : BodyId ) -> HirId {
410417 let parent = self . get_parent_node ( hir_id) ;
411- assert ! ( self . find( parent) . map_or( false , |n| is_body_owner( n, hir_id) ) ) ;
418+ assert ! ( self . find( parent) . map_or( false , |n| is_body_owner( n, hir_id) ) , "{hir_id:?}" ) ;
412419 parent
413420 }
414421
@@ -419,10 +426,11 @@ impl<'hir> Map<'hir> {
419426 /// Given a `LocalDefId`, returns the `BodyId` associated with it,
420427 /// if the node is a body owner, otherwise returns `None`.
421428 pub fn maybe_body_owned_by ( self , id : LocalDefId ) -> Option < BodyId > {
422- self . get_if_local ( id. to_def_id ( ) ) . map ( associated_body) . flatten ( )
429+ self . find_by_def_id ( id) . and_then ( associated_body)
423430 }
424431
425432 /// Given a body owner's id, returns the `BodyId` associated with it.
433+ #[ track_caller]
426434 pub fn body_owned_by ( self , id : LocalDefId ) -> BodyId {
427435 self . maybe_body_owned_by ( id) . unwrap_or_else ( || {
428436 let hir_id = self . local_def_id_to_hir_id ( id) ;
0 commit comments