1
Fork 0

Change enclosing_body_owner to return LocalDefId

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
Miguel Guarniz 2022-07-19 17:47:49 -04:00
parent 16513d689e
commit 0c609a4c1f
7 changed files with 13 additions and 14 deletions

View file

@ -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