Skip to content

Commit d3f6706

Browse files
committed
Remove on_all_drop_children_bits.
As drop elaboration only tracks places that need dropping, is has become equivalent to `on_all_children_bits`.
1 parent 8c58c27 commit d3f6706

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

compiler/rustc_mir_dataflow/src/drop_flag_effects.rs

-23
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,6 @@ pub fn on_all_children_bits<'tcx, F>(
7575
on_all_children_bits(tcx, body, move_data, move_path_index, &mut each_child);
7676
}
7777

78-
pub fn on_all_drop_children_bits<'tcx, F>(
79-
tcx: TyCtxt<'tcx>,
80-
body: &Body<'tcx>,
81-
ctxt: &MoveDataParamEnv<'tcx>,
82-
path: MovePathIndex,
83-
mut each_child: F,
84-
) where
85-
F: FnMut(MovePathIndex),
86-
{
87-
on_all_children_bits(tcx, body, &ctxt.move_data, path, |child| {
88-
let place = &ctxt.move_data.move_paths[path].place;
89-
let ty = place.ty(body, tcx).ty;
90-
debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, place, ty);
91-
92-
let erased_ty = tcx.erase_regions(ty);
93-
if erased_ty.needs_drop(tcx, ctxt.param_env) {
94-
each_child(child);
95-
} else {
96-
debug!("on_all_drop_children_bits - skipping")
97-
}
98-
})
99-
}
100-
10178
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
10279
tcx: TyCtxt<'tcx>,
10380
body: &Body<'tcx>,

compiler/rustc_mir_dataflow/src/impls/initialized.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::framework::SwitchIntEdgeEffects;
1010
use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
1111
use crate::on_lookup_result_bits;
1212
use crate::MoveDataParamEnv;
13-
use crate::{drop_flag_effects, on_all_children_bits, on_all_drop_children_bits};
13+
use crate::{drop_flag_effects, on_all_children_bits};
1414
use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis, MaybeReachable};
1515

1616
/// `MaybeInitializedPlaces` tracks all places that might be
@@ -72,7 +72,7 @@ impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
7272
) -> bool {
7373
if let LookupResult::Exact(path) = self.move_data().rev_lookup.find(place.as_ref()) {
7474
let mut maybe_live = false;
75-
on_all_drop_children_bits(self.tcx, self.body, self.mdpe, path, |child| {
75+
on_all_children_bits(self.tcx, self.body, self.move_data(), path, |child| {
7676
maybe_live |= state.contains(child);
7777
});
7878
!maybe_live

compiler/rustc_mir_dataflow/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ use rustc_span::symbol::{sym, Symbol};
2323

2424
pub use self::drop_flag_effects::{
2525
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
26-
move_path_children_matching, on_all_children_bits, on_all_drop_children_bits,
27-
on_lookup_result_bits,
26+
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
2827
};
2928
pub use self::framework::{
3029
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, AnalysisResults, Backward,

compiler/rustc_mir_transform/src/elaborate_drops.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, DropFlagState, Unwind}
99
use rustc_mir_dataflow::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};
1010
use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
1111
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
12+
use rustc_mir_dataflow::on_all_children_bits;
1213
use rustc_mir_dataflow::on_lookup_result_bits;
1314
use rustc_mir_dataflow::MoveDataParamEnv;
14-
use rustc_mir_dataflow::{on_all_children_bits, on_all_drop_children_bits};
1515
use rustc_mir_dataflow::{Analysis, ResultsCursor};
1616
use rustc_span::Span;
1717
use rustc_target::abi::{FieldIdx, VariantIdx};
@@ -172,13 +172,19 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, '_, 'tcx> {
172172
let mut some_live = false;
173173
let mut some_dead = false;
174174
let mut children_count = 0;
175-
on_all_drop_children_bits(self.tcx(), self.body(), self.ctxt.env, path, |child| {
176-
let (live, dead) = self.ctxt.init_data.maybe_live_dead(child);
177-
debug!("elaborate_drop: state({:?}) = {:?}", child, (live, dead));
178-
some_live |= live;
179-
some_dead |= dead;
180-
children_count += 1;
181-
});
175+
on_all_children_bits(
176+
self.tcx(),
177+
self.body(),
178+
self.ctxt.move_data(),
179+
path,
180+
|child| {
181+
let (live, dead) = self.ctxt.init_data.maybe_live_dead(child);
182+
debug!("elaborate_drop: state({:?}) = {:?}", child, (live, dead));
183+
some_live |= live;
184+
some_dead |= dead;
185+
children_count += 1;
186+
},
187+
);
182188
((some_live, some_dead), children_count != 1)
183189
}
184190
};
@@ -298,7 +304,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
298304
match path {
299305
LookupResult::Exact(path) => {
300306
self.init_data.seek_before(self.body.terminator_loc(bb));
301-
on_all_drop_children_bits(self.tcx, self.body, self.env, path, |child| {
307+
on_all_children_bits(self.tcx, self.body, self.move_data(), path, |child| {
302308
let (maybe_live, maybe_dead) = self.init_data.maybe_live_dead(child);
303309
debug!(
304310
"collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",

0 commit comments

Comments
 (0)