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

@ -49,10 +49,10 @@ pub fn find_param_with_region<'tcx>(
};
let hir = &tcx.hir();
let hir_id = hir.local_def_id_to_hir_id(id.as_local()?);
let body_id = hir.maybe_body_owned_by(hir_id)?;
let body = hir.body(body_id);
let def_id = id.as_local()?;
let hir_id = hir.local_def_id_to_hir_id(def_id);
// FIXME: use def_kind
// Don't perform this on closures
match hir.get(hir_id) {
hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => {
@ -61,11 +61,14 @@ pub fn find_param_with_region<'tcx>(
_ => {}
}
let body_id = hir.maybe_body_owned_by(def_id)?;
let owner_id = hir.body_owner(body_id);
let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap();
let poly_fn_sig = tcx.fn_sig(id);
let fn_sig = tcx.liberate_late_bound_regions(id, poly_fn_sig);
let body = hir.body(body_id);
body.params
.iter()
.take(if fn_sig.c_variadic {