mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Remove on_all_drop_children_bits.
As drop elaboration only tracks places that need dropping, is has become equivalent to `on_all_children_bits`.
This commit is contained in:
parent
c9c0c0cbca
commit
547af00019
@ -75,29 +75,6 @@ pub fn on_all_children_bits<'tcx, F>(
|
|||||||
on_all_children_bits(tcx, body, move_data, move_path_index, &mut each_child);
|
on_all_children_bits(tcx, body, move_data, move_path_index, &mut each_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_all_drop_children_bits<'tcx, F>(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
body: &Body<'tcx>,
|
|
||||||
ctxt: &MoveDataParamEnv<'tcx>,
|
|
||||||
path: MovePathIndex,
|
|
||||||
mut each_child: F,
|
|
||||||
) where
|
|
||||||
F: FnMut(MovePathIndex),
|
|
||||||
{
|
|
||||||
on_all_children_bits(tcx, body, &ctxt.move_data, path, |child| {
|
|
||||||
let place = &ctxt.move_data.move_paths[path].place;
|
|
||||||
let ty = place.ty(body, tcx).ty;
|
|
||||||
debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, place, ty);
|
|
||||||
|
|
||||||
let erased_ty = tcx.erase_regions(ty);
|
|
||||||
if erased_ty.needs_drop(tcx, ctxt.param_env) {
|
|
||||||
each_child(child);
|
|
||||||
} else {
|
|
||||||
debug!("on_all_drop_children_bits - skipping")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
|
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
|
@ -10,7 +10,7 @@ use crate::framework::SwitchIntEdgeEffects;
|
|||||||
use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
|
use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
|
||||||
use crate::on_lookup_result_bits;
|
use crate::on_lookup_result_bits;
|
||||||
use crate::MoveDataParamEnv;
|
use crate::MoveDataParamEnv;
|
||||||
use crate::{drop_flag_effects, on_all_children_bits, on_all_drop_children_bits};
|
use crate::{drop_flag_effects, on_all_children_bits};
|
||||||
use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis, MaybeReachable};
|
use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis, MaybeReachable};
|
||||||
|
|
||||||
/// `MaybeInitializedPlaces` tracks all places that might be
|
/// `MaybeInitializedPlaces` tracks all places that might be
|
||||||
@ -72,7 +72,7 @@ impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
|
if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
|
||||||
let mut maybe_live = false;
|
let mut maybe_live = false;
|
||||||
on_all_drop_children_bits(self.tcx, self.body, self.mdpe, path, |child| {
|
on_all_children_bits(self.tcx, self.body, self.move_data(), path, |child| {
|
||||||
maybe_live |= state.contains(child);
|
maybe_live |= state.contains(child);
|
||||||
});
|
});
|
||||||
!maybe_live
|
!maybe_live
|
||||||
|
@ -23,8 +23,7 @@ use rustc_span::symbol::{sym, Symbol};
|
|||||||
|
|
||||||
pub use self::drop_flag_effects::{
|
pub use self::drop_flag_effects::{
|
||||||
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
|
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
|
||||||
move_path_children_matching, on_all_children_bits, on_all_drop_children_bits,
|
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
|
||||||
on_lookup_result_bits,
|
|
||||||
};
|
};
|
||||||
pub use self::framework::{
|
pub use self::framework::{
|
||||||
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, AnalysisResults, Backward,
|
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, AnalysisResults, Backward,
|
||||||
|
@ -9,9 +9,9 @@ use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, DropFlagState, Unwind}
|
|||||||
use rustc_mir_dataflow::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};
|
use rustc_mir_dataflow::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};
|
||||||
use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||||
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||||
|
use rustc_mir_dataflow::on_all_children_bits;
|
||||||
use rustc_mir_dataflow::on_lookup_result_bits;
|
use rustc_mir_dataflow::on_lookup_result_bits;
|
||||||
use rustc_mir_dataflow::MoveDataParamEnv;
|
use rustc_mir_dataflow::MoveDataParamEnv;
|
||||||
use rustc_mir_dataflow::{on_all_children_bits, on_all_drop_children_bits};
|
|
||||||
use rustc_mir_dataflow::{Analysis, ResultsCursor};
|
use rustc_mir_dataflow::{Analysis, ResultsCursor};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{FieldIdx, VariantIdx};
|
use rustc_target::abi::{FieldIdx, VariantIdx};
|
||||||
@ -172,13 +172,19 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, '_, 'tcx> {
|
|||||||
let mut some_live = false;
|
let mut some_live = false;
|
||||||
let mut some_dead = false;
|
let mut some_dead = false;
|
||||||
let mut children_count = 0;
|
let mut children_count = 0;
|
||||||
on_all_drop_children_bits(self.tcx(), self.body(), self.ctxt.env, path, |child| {
|
on_all_children_bits(
|
||||||
let (live, dead) = self.ctxt.init_data.maybe_live_dead(child);
|
self.tcx(),
|
||||||
debug!("elaborate_drop: state({:?}) = {:?}", child, (live, dead));
|
self.body(),
|
||||||
some_live |= live;
|
self.ctxt.move_data(),
|
||||||
some_dead |= dead;
|
path,
|
||||||
children_count += 1;
|
|child| {
|
||||||
});
|
let (live, dead) = self.ctxt.init_data.maybe_live_dead(child);
|
||||||
|
debug!("elaborate_drop: state({:?}) = {:?}", child, (live, dead));
|
||||||
|
some_live |= live;
|
||||||
|
some_dead |= dead;
|
||||||
|
children_count += 1;
|
||||||
|
},
|
||||||
|
);
|
||||||
((some_live, some_dead), children_count != 1)
|
((some_live, some_dead), children_count != 1)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -298,7 +304,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
|
|||||||
match path {
|
match path {
|
||||||
LookupResult::Exact(path) => {
|
LookupResult::Exact(path) => {
|
||||||
self.init_data.seek_before(self.body.terminator_loc(bb));
|
self.init_data.seek_before(self.body.terminator_loc(bb));
|
||||||
on_all_drop_children_bits(self.tcx, self.body, self.env, path, |child| {
|
on_all_children_bits(self.tcx, self.body, self.move_data(), path, |child| {
|
||||||
let (maybe_live, maybe_dead) = self.init_data.maybe_live_dead(child);
|
let (maybe_live, maybe_dead) = self.init_data.maybe_live_dead(child);
|
||||||
debug!(
|
debug!(
|
||||||
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
|
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
|
||||||
|
Loading…
Reference in New Issue
Block a user