Change maybe_body_owned_by to take local def id

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
Miguel Guarniz 2022-07-15 23:13:04 -04:00
parent 3924dac7bb
commit 25bdc8965e
19 changed files with 50 additions and 47 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 local_did = id.as_local()?;
let hir_id = hir.local_def_id_to_hir_id(local_did);
// 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(local_did)?;
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 {