]> git.lizzy.rs Git - rust.git/commitdiff
Some hir cleanups
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 10 Nov 2022 08:47:16 +0000 (08:47 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 20 Dec 2022 15:01:37 +0000 (15:01 +0000)
compiler/rustc_middle/src/hir/map/mod.rs

index 0450abed51b0652338a9bd7799d0dd2e566c62db..cf5ebad40328a06c9c3a822e724ada89d3f38a06 100644 (file)
@@ -408,7 +408,7 @@ pub fn enclosing_body_owner(self, hir_id: HirId) -> LocalDefId {
     /// item (possibly associated), a closure, or a `hir::AnonConst`.
     pub fn body_owner(self, BodyId { hir_id }: BodyId) -> HirId {
         let parent = self.get_parent_node(hir_id);
-        assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)));
+        assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)), "{hir_id:?}");
         parent
     }
 
@@ -419,7 +419,7 @@ pub fn body_owner_def_id(self, id: BodyId) -> LocalDefId {
     /// Given a `LocalDefId`, returns the `BodyId` associated with it,
     /// if the node is a body owner, otherwise returns `None`.
     pub fn maybe_body_owned_by(self, id: LocalDefId) -> Option<BodyId> {
-        self.get_if_local(id.to_def_id()).map(associated_body).flatten()
+        self.find_by_def_id(id).and_then(associated_body)
     }
 
     /// Given a body owner's id, returns the `BodyId` associated with it.