Only run MaybeInitializedPlaces once for drop elaboration.
This commit is contained in:
parent
5173d85043
commit
3acfa092db
8 changed files with 129 additions and 120 deletions
|
@ -4,7 +4,9 @@ use rustc_middle::ty::GenericArgsRef;
|
|||
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, VariantDef};
|
||||
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
use rustc_mir_dataflow::{self, move_path_children_matching, Analysis, MoveDataParamEnv};
|
||||
use rustc_mir_dataflow::{
|
||||
self, move_path_children_matching, Analysis, MaybeUnreachable, MoveDataParamEnv,
|
||||
};
|
||||
use rustc_target::abi::FieldIdx;
|
||||
|
||||
use crate::MirPass;
|
||||
|
@ -41,6 +43,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops {
|
|||
let TerminatorKind::Drop { place, .. } = &terminator.kind else { continue };
|
||||
|
||||
maybe_inits.seek_before_primary_effect(body.terminator_loc(bb));
|
||||
let MaybeUnreachable::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 {
|
||||
|
@ -50,7 +53,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUninitDrops {
|
|||
let should_keep = is_needs_drop_and_init(
|
||||
tcx,
|
||||
param_env,
|
||||
maybe_inits.get(),
|
||||
maybe_inits,
|
||||
&mdpe.move_data,
|
||||
place.ty(body, tcx).ty,
|
||||
mpi,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue