Make body_owned_by return the body directly.

Almost all callers want this anyway, and now we can use it to also return fed bodies
This commit is contained in:
Oli Scherer 2024-05-29 10:03:40 +00:00
parent ceb45d5519
commit a34c26e7ec
38 changed files with 136 additions and 131 deletions

View file

@ -457,10 +457,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
};
let mut local_visitor = FindInferSourceVisitor::new(self, typeck_results, arg);
if let Some(body_id) = self.tcx.hir().maybe_body_owned_by(
if let Some(body) = self.tcx.hir().maybe_body_owned_by(
self.tcx.typeck_root_def_id(body_def_id.to_def_id()).expect_local(),
) {
let expr = self.tcx.hir().body(body_id).value;
let expr = body.value;
local_visitor.visit_expr(expr);
}

View file

@ -62,14 +62,13 @@ pub fn find_param_with_region<'tcx>(
_ => {}
}
let body_id = hir.maybe_body_owned_by(def_id)?;
let body = hir.maybe_body_owned_by(def_id)?;
let owner_id = hir.body_owner(body_id);
let owner_id = hir.body_owner(body.id());
let fn_decl = hir.fn_decl_by_hir_id(owner_id)?;
let poly_fn_sig = tcx.fn_sig(id).instantiate_identity();
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 {

View file

@ -580,10 +580,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}
self.tcx.hir().maybe_body_owned_by(cause.body_id).and_then(|body_id| {
let body = self.tcx.hir().body(body_id);
self.tcx.hir().maybe_body_owned_by(cause.body_id).and_then(|body| {
IfVisitor { err_span: span, found_if: false }
.visit_body(body)
.visit_body(&body)
.is_break()
.then(|| TypeErrorAdditionalDiags::AddLetForLetChains { span: span.shrink_to_lo() })
})