Auto merge of #125711 - oli-obk:const_block_ice2, r=Nadrieril
Make `body_owned_by` return the `Body` instead of just the `BodyId` fixes #125677 Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly. This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too. I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
This commit is contained in:
commit
d43930dab3
54 changed files with 163 additions and 162 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1163,7 +1163,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
|
|||
|
||||
/// For closures, we first visit the parameters and then the content,
|
||||
/// as we prefer those.
|
||||
fn visit_body(&mut self, body: &'tcx Body<'tcx>) {
|
||||
fn visit_body(&mut self, body: &Body<'tcx>) {
|
||||
for param in body.params {
|
||||
debug!(
|
||||
"param: span {:?}, ty_span {:?}, pat.span {:?}",
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -578,16 +578,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
walk_stmt(self, ex)
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_body(&mut self, body: &'v hir::Body<'v>) -> Self::Result {
|
||||
hir::intravisit::walk_body(self, body)
|
||||
}
|
||||
}
|
||||
|
||||
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() })
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue