about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir
diff options
context:
space:
mode:
authorMiguel Guarniz <mi9uel9@gmail.com>2022-07-19 17:47:49 -0400
committerMiguel Guarniz <mi9uel9@gmail.com>2022-07-29 18:26:10 -0400
commit0c609a4c1fc182298b920c61d1b32c9a1deb5776 (patch)
treeeeca8a17a68b637395d18a913b476a0f2400c766 /compiler/rustc_middle/src/hir
parent16513d689e4fe30e58a37dd773af5be9210ebcbd (diff)
downloadrust-0c609a4c1fc182298b920c61d1b32c9a1deb5776.tar.gz
rust-0c609a4c1fc182298b920c61d1b32c9a1deb5776.zip
Change enclosing_body_owner to return LocalDefId
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
Diffstat (limited to 'compiler/rustc_middle/src/hir')
-rw-r--r--compiler/rustc_middle/src/hir/map/mod.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index adb591fe09c..47b04c33ec1 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -396,10 +396,10 @@ impl<'hir> Map<'hir> {
         }
     }
 
-    pub fn enclosing_body_owner(self, hir_id: HirId) -> HirId {
+    pub fn enclosing_body_owner(self, hir_id: HirId) -> LocalDefId {
         for (parent, _) in self.parent_iter(hir_id) {
-            if let Some(local_did) = parent.as_owner() && let Some(body) = self.maybe_body_owned_by(local_did) {
-                return self.body_owner(body);
+            if let Some(body) = self.find(parent).map(associated_body).flatten() {
+                return self.body_owner_def_id(body);
             }
         }
 
@@ -671,7 +671,7 @@ impl<'hir> Map<'hir> {
     /// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
     /// Used exclusively for diagnostics, to avoid suggestion function calls.
     pub fn is_inside_const_context(self, hir_id: HirId) -> bool {
-        self.body_const_context(self.local_def_id(self.enclosing_body_owner(hir_id))).is_some()
+        self.body_const_context(self.enclosing_body_owner(hir_id)).is_some()
     }
 
     /// Retrieves the `HirId` for `id`'s enclosing method, unless there's a