Stop using MoveDataParamEnv for places that don't need a param-env
This commit is contained in:
parent
4db3d12e6f
commit
f990239b34
6 changed files with 53 additions and 64 deletions
|
@ -62,7 +62,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
|||
let elaborate_patch = {
|
||||
let env = MoveDataParamEnv { move_data, param_env };
|
||||
|
||||
let mut inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
||||
let mut inits = MaybeInitializedPlaces::new(tcx, body, &env.move_data)
|
||||
.skipping_unreachable_unwind()
|
||||
.into_engine(tcx, body)
|
||||
.pass_name("elaborate_drops")
|
||||
|
@ -70,7 +70,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
|||
.into_results_cursor(body);
|
||||
let dead_unwinds = compute_dead_unwinds(body, &mut inits);
|
||||
|
||||
let uninits = MaybeUninitializedPlaces::new(tcx, body, &env)
|
||||
let uninits = MaybeUninitializedPlaces::new(tcx, body, &env.move_data)
|
||||
.mark_inactive_variants_as_uninit()
|
||||
.skipping_unreachable_unwind(dead_unwinds)
|
||||
.into_engine(tcx, body)
|
||||
|
@ -443,9 +443,13 @@ impl<'b, 'mir, 'tcx> ElaborateDropsCtxt<'b, 'mir, 'tcx> {
|
|||
|
||||
fn drop_flags_for_args(&mut self) {
|
||||
let loc = Location::START;
|
||||
rustc_mir_dataflow::drop_flag_effects_for_function_entry(self.body, self.env, |path, ds| {
|
||||
self.set_drop_flag(loc, path, ds);
|
||||
})
|
||||
rustc_mir_dataflow::drop_flag_effects_for_function_entry(
|
||||
self.body,
|
||||
&self.env.move_data,
|
||||
|path, ds| {
|
||||
self.set_drop_flag(loc, path, ds);
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn drop_flags_for_locs(&mut self) {
|
||||
|
@ -478,7 +482,7 @@ impl<'b, 'mir, 'tcx> ElaborateDropsCtxt<'b, 'mir, 'tcx> {
|
|||
let loc = Location { block: bb, statement_index: i };
|
||||
rustc_mir_dataflow::drop_flag_effects_for_location(
|
||||
self.body,
|
||||
self.env,
|
||||
&self.env.move_data,
|
||||
loc,
|
||||
|path, ds| self.set_drop_flag(loc, path, ds),
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ use rustc_middle::mir::{Body, TerminatorKind};
|
|||
use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, VariantDef};
|
||||
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
use rustc_mir_dataflow::{move_path_children_matching, Analysis, MaybeReachable, MoveDataParamEnv};
|
||||
use rustc_mir_dataflow::{move_path_children_matching, Analysis, MaybeReachable};
|
||||
use rustc_target::abi::FieldIdx;
|
||||
|
||||
use crate::MirPass;
|
||||
|
@ -24,8 +24,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops {
|
|||
let move_data =
|
||||
MoveData::gather_moves(body, tcx, param_env, |ty| ty.needs_drop(tcx, param_env));
|
||||
|
||||
let mdpe = MoveDataParamEnv { move_data, param_env };
|
||||
let mut maybe_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe)
|
||||
let mut maybe_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
|
||||
.into_engine(tcx, body)
|
||||
.pass_name("remove_uninit_drops")
|
||||
.iterate_to_fixpoint()
|
||||
|
@ -40,7 +39,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops {
|
|||
let MaybeReachable::Reachable(maybe_inits) = maybe_inits.get() else { continue };
|
||||
|
||||
// If there's no move path for the dropped place, it's probably a `Deref`. Let it alone.
|
||||
let LookupResult::Exact(mpi) = mdpe.move_data.rev_lookup.find(place.as_ref()) else {
|
||||
let LookupResult::Exact(mpi) = move_data.rev_lookup.find(place.as_ref()) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -48,7 +47,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops {
|
|||
tcx,
|
||||
param_env,
|
||||
maybe_inits,
|
||||
&mdpe.move_data,
|
||||
&move_data,
|
||||
place.ty(body, tcx).ty,
|
||||
mpi,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue