1
Fork 0

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

@ -158,9 +158,8 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) {
}
let mut maps = IrMaps::new(tcx);
let body_id = tcx.hir().body_owned_by(def_id);
let hir_id = tcx.hir().body_owner(body_id);
let body = tcx.hir().body(body_id);
let body = tcx.hir().body_owned_by(def_id);
let hir_id = tcx.hir().body_owner(body.id());
if let Some(upvars) = tcx.upvars_mentioned(def_id) {
for &var_hir_id in upvars.keys() {
@ -171,17 +170,17 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) {
// gather up the various local variables, significant expressions,
// and so forth:
maps.visit_body(body);
maps.visit_body(&body);
// compute liveness
let mut lsets = Liveness::new(&mut maps, def_id);
let entry_ln = lsets.compute(body, hir_id);
lsets.log_liveness(entry_ln, body_id.hir_id);
let entry_ln = lsets.compute(&body, hir_id);
lsets.log_liveness(entry_ln, body.id().hir_id);
// check for various error conditions
lsets.visit_body(body);
lsets.visit_body(&body);
lsets.warn_about_unused_upvars(entry_ln);
lsets.warn_about_unused_args(body, entry_ln);
lsets.warn_about_unused_args(&body, entry_ln);
}
pub fn provide(providers: &mut Providers) {

View file

@ -16,17 +16,17 @@ pub fn provide(providers: &mut Providers) {
}
let local_def_id = def_id.expect_local();
let body = tcx.hir().body(tcx.hir().maybe_body_owned_by(local_def_id)?);
let body = tcx.hir().maybe_body_owned_by(local_def_id)?;
let mut local_collector = LocalCollector::default();
local_collector.visit_body(body);
local_collector.visit_body(&body);
let mut capture_collector = CaptureCollector {
tcx,
locals: &local_collector.locals,
upvars: FxIndexMap::default(),
};
capture_collector.visit_body(body);
capture_collector.visit_body(&body);
if !capture_collector.upvars.is_empty() {
Some(tcx.arena.alloc(capture_collector.upvars))