1
Fork 0

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:
bors 2024-05-30 08:00:11 +00:00
commit d43930dab3
54 changed files with 163 additions and 162 deletions

View file

@ -125,7 +125,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
});
}
fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
fn visit_body(&mut self, body: &hir::Body<'tcx>) {
lint_callback!(self, check_body, body);
hir_visit::walk_body(self, body);
lint_callback!(self, check_body_post, body);

View file

@ -68,11 +68,11 @@ impl_lint_pass!(NonLocalDefinitions => [NON_LOCAL_DEFINITIONS]);
// instead check_mod is called after every body has been handled.
impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
fn check_body(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) {
fn check_body(&mut self, _cx: &LateContext<'tcx>, _body: &Body<'tcx>) {
self.body_depth += 1;
}
fn check_body_post(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) {
fn check_body_post(&mut self, _cx: &LateContext<'tcx>, _body: &Body<'tcx>) {
self.body_depth -= 1;
}

View file

@ -7,8 +7,8 @@ use rustc_session::lint::LintPass;
macro_rules! late_lint_methods {
($macro:path, $args:tt) => (
$macro!($args, [
fn check_body(a: &'tcx rustc_hir::Body<'tcx>);
fn check_body_post(a: &'tcx rustc_hir::Body<'tcx>);
fn check_body(a: &rustc_hir::Body<'tcx>);
fn check_body_post(a: &rustc_hir::Body<'tcx>);
fn check_crate();
fn check_crate_post();
fn check_mod(a: &'tcx rustc_hir::Mod<'tcx>, b: rustc_hir::HirId);