diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index cf5ebad4032..f5cb89fa624 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -170,6 +170,7 @@ pub fn def_path_hash(self, def_id: LocalDefId) -> DefPathHash { } #[inline] + #[track_caller] pub fn local_def_id(self, hir_id: HirId) -> LocalDefId { self.opt_local_def_id(hir_id).unwrap_or_else(|| { bug!( @@ -310,6 +311,7 @@ pub fn find_parent_node(self, id: HirId) -> Option { } } + #[track_caller] pub fn get_parent_node(self, hir_id: HirId) -> HirId { self.find_parent_node(hir_id) .unwrap_or_else(|| bug!("No parent for node {:?}", self.node_to_string(hir_id))) @@ -334,12 +336,14 @@ pub fn find_by_def_id(self, id: LocalDefId) -> Option> { } /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found. + #[track_caller] pub fn get(self, id: HirId) -> Node<'hir> { self.find(id).unwrap_or_else(|| bug!("couldn't find hir id {} in the HIR map", id)) } /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found. #[inline] + #[track_caller] pub fn get_by_def_id(self, id: LocalDefId) -> Node<'hir> { self.find_by_def_id(id).unwrap_or_else(|| bug!("couldn't find {:?} in the HIR map", id)) } @@ -377,6 +381,7 @@ pub fn body(self, id: BodyId) -> &'hir Body<'hir> { self.tcx.hir_owner_nodes(id.hir_id.owner).unwrap().bodies[&id.hir_id.local_id] } + #[track_caller] pub fn fn_decl_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> { if let Some(node) = self.find(hir_id) { node.fn_decl() @@ -385,6 +390,7 @@ pub fn fn_decl_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> { } } + #[track_caller] pub fn fn_sig_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> { if let Some(node) = self.find(hir_id) { node.fn_sig() @@ -393,6 +399,7 @@ pub fn fn_sig_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> { } } + #[track_caller] pub fn enclosing_body_owner(self, hir_id: HirId) -> LocalDefId { for (_, node) in self.parent_iter(hir_id) { if let Some(body) = associated_body(node) { @@ -423,6 +430,7 @@ pub fn maybe_body_owned_by(self, id: LocalDefId) -> Option { } /// Given a body owner's id, returns the `BodyId` associated with it. + #[track_caller] pub fn body_owned_by(self, id: LocalDefId) -> BodyId { self.maybe_body_owned_by(id).unwrap_or_else(|| { let hir_id = self.local_def_id_to_hir_id(id);