1
Fork 0

Rollup merge of #99311 - kckeiks:clean-up-body-owner-methods, r=cjgillot

change maybe_body_owned_by to take local def id

Issue https://github.com/rust-lang/rust/issues/96341
r? `@cjgillot`
This commit is contained in:
Dylan DPC 2022-07-30 20:39:46 +05:30 committed by GitHub
commit c668820365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 58 additions and 51 deletions

View file

@ -766,7 +766,7 @@ 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(encl_body_owner_id);
let encl_body = self.tcx.hir().body(encl_body_id);

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

@ -107,8 +107,7 @@ impl<'tcx> InheritedBuilder<'tcx> {
impl<'a, 'tcx> Inherited<'a, 'tcx> {
fn new(infcx: InferCtxt<'a, 'tcx>, def_id: LocalDefId) -> Self {
let tcx = infcx.tcx;
let item_id = tcx.hir().local_def_id_to_hir_id(def_id);
let body_id = tcx.hir().maybe_body_owned_by(item_id);
let body_id = tcx.hir().maybe_body_owned_by(def_id);
let typeck_results =
infcx.in_progress_typeck_results.expect("building `FnCtxt` without typeck results");

View file

@ -814,8 +814,7 @@ pub fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
return tcx.region_scope_tree(typeck_root_def_id);
}
let id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(id) {
let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(def_id.expect_local()) {
let mut visitor = RegionResolutionVisitor {
tcx,
scope_tree: ScopeTree::default(),

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
}