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

@ -766,10 +766,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// If this didn't hold, we would not have to report an error in
// the first place.
assert_ne!(hir::HirId::make_owner(encl_item_id), encl_body_owner_id);
assert_ne!(encl_item_id, encl_body_owner_id);
let encl_body_id =
self.tcx.hir().body_owned_by(self.tcx.hir().local_def_id(encl_body_owner_id));
let encl_body_id = self.tcx.hir().body_owned_by(encl_body_owner_id);
let encl_body = self.tcx.hir().body(encl_body_id);
err.encl_body_span = Some(encl_body.value.span);

View file

@ -58,7 +58,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!("FnCtxt::check_asm: {} deferred checks", deferred_asm_checks.len());
for (asm, hir_id) in deferred_asm_checks.drain(..) {
let enclosing_id = self.tcx.hir().enclosing_body_owner(hir_id);
InlineAsmCtxt::new_in_fn(self).check_asm(asm, enclosing_id);
InlineAsmCtxt::new_in_fn(self)
.check_asm(asm, self.tcx.hir().local_def_id_to_hir_id(enclosing_id));
}
}

View file

@ -100,7 +100,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
ExprKind::MethodCall(segment, ..) | ExprKind::Path(QPath::TypeRelative(_, segment)),
..
}) => {
let body_owner = tcx.hir().local_def_id(tcx.hir().enclosing_body_owner(hir_id));
let body_owner = tcx.hir().enclosing_body_owner(hir_id);
let tables = tcx.typeck(body_owner);
// This may fail in case the method/path does not actually exist.
// As there is no relevant param for `def_id`, we simply return
@ -134,7 +134,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
| ExprKind::Struct(&QPath::Resolved(_, path), ..),
..
}) => {
let body_owner = tcx.hir().local_def_id(tcx.hir().enclosing_body_owner(hir_id));
let body_owner = tcx.hir().enclosing_body_owner(hir_id);
let _tables = tcx.typeck(body_owner);
&*path
}