Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0302cfd

Browse files
committedDec 8, 2017
MERGEME Switched refactoring to use trait methods (on tcx/mir/param_env) rather than closures.
1 parent ff3a7f0 commit 0302cfd

File tree

3 files changed

+129
-120
lines changed

3 files changed

+129
-120
lines changed
 

‎src/librustc_mir/dataflow/drop_flag_effects.rs

Lines changed: 89 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,44 @@
99
// except according to those terms.
1010

1111
use rustc::mir::{self, Mir, Location, Place};
12-
use rustc::ty::{self, TyCtxt};
12+
use rustc::ty::{self, TyCtxt, ParamEnv};
1313
use util::elaborate_drops::DropFlagState;
1414

1515
use super::indexes::MovePathIndex;
1616
use super::move_paths::{MoveData, LookupResult, InitKind};
1717

18+
pub(crate) trait PlaceOneDropFlag<'tcx> {
19+
fn place_contents_drop_state_cannot_differ(&self, &Place<'tcx>) -> bool;
20+
}
21+
22+
pub(crate) trait PlaceNeedsDrop<'tcx> {
23+
fn needs_drop(&self, &Place<'tcx>) -> bool;
24+
}
25+
26+
impl<'a, 'gcx, 'tcx> PlaceOneDropFlag<'tcx> for (TyCtxt<'a, 'gcx, 'tcx>, &'a Mir<'tcx>) {
27+
fn place_contents_drop_state_cannot_differ(&self, place: &Place<'tcx>) -> bool {
28+
place_contents_drop_state_cannot_differ(self.0, self.1, place)
29+
}
30+
}
31+
32+
impl<'a, 'gcx, 'tcx> PlaceOneDropFlag<'tcx> for (TyCtxt<'a, 'gcx, 'tcx>,
33+
&'a Mir<'tcx>,
34+
ParamEnv<'gcx>)
35+
{
36+
fn place_contents_drop_state_cannot_differ(&self, place: &Place<'tcx>) -> bool {
37+
place_contents_drop_state_cannot_differ(self.0, self.1, place)
38+
}
39+
}
40+
41+
impl<'a, 'gcx, 'tcx> PlaceNeedsDrop<'tcx> for (TyCtxt<'a, 'gcx, 'tcx>,
42+
&'a Mir<'tcx>,
43+
ParamEnv<'gcx>)
44+
{
45+
fn needs_drop(&self, place: &Place<'tcx>) -> bool {
46+
place_needs_drop(self.0, self.1, self.2, place)
47+
}
48+
}
49+
1850
pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>,
1951
path: MovePathIndex,
2052
mut cond: F)
@@ -55,7 +87,7 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>,
5587
/// is no need to maintain separate drop flags to track such state.
5688
///
5789
/// FIXME: we have to do something for moving slice patterns.
58-
pub(crate) fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(
90+
fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(
5991
tcx: TyCtxt<'a, 'gcx, 'tcx>,
6092
mir: &Mir<'tcx>,
6193
place: &Place<'tcx>) -> bool
@@ -83,119 +115,114 @@ pub(crate) fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(
83115
}
84116
}
85117

86-
pub(crate) fn place_needs_drop<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
87-
mir: &Mir<'tcx>,
88-
param_env: ty::ParamEnv<'gcx>,
89-
place: &Place<'tcx>)
90-
-> bool
118+
fn place_needs_drop<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
119+
mir: &Mir<'tcx>,
120+
param_env: ty::ParamEnv<'gcx>,
121+
place: &Place<'tcx>)
122+
-> bool
91123
{
92124
let ty = place.ty(mir, tcx).to_ty(tcx);
93-
// debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, place, ty);
94-
95125
let gcx = tcx.global_tcx();
96126
let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap();
97127
erased_ty.needs_drop(gcx, param_env)
98128
}
99129

100-
pub(crate) fn on_lookup_result_bits<'tcx, F, U>(move_data: &MoveData<'tcx>,
101-
lookup_result: LookupResult,
102-
has_uniform_drop_state: U,
103-
each_child: F)
104-
where F: FnMut(MovePathIndex), U: Fn(&Place<'tcx>) -> bool
130+
pub(crate) fn on_lookup_result_bits<'tcx, F, PO>(tcx_mir: &PO,
131+
move_data: &MoveData<'tcx>,
132+
lookup_result: LookupResult,
133+
each_child: F)
134+
where F: FnMut(MovePathIndex), PO: PlaceOneDropFlag<'tcx>,
105135
{
106136
match lookup_result {
107137
LookupResult::Parent(..) => {
108138
// access to untracked value - do not touch children
109139
}
110140
LookupResult::Exact(e) => {
111-
on_all_children_bits(move_data, e, has_uniform_drop_state, each_child)
141+
on_all_children_bits(tcx_mir, move_data, e, each_child)
112142
}
113143
}
114144
}
115145

116-
pub(crate) fn on_all_children_bits<'tcx, F, U>(move_data: &MoveData<'tcx>,
117-
move_path_index: MovePathIndex,
118-
has_uniform_drop_state: U,
119-
mut each_child: F)
120-
where F: FnMut(MovePathIndex), U: Fn(&Place<'tcx>) -> bool
146+
pub(crate) fn on_all_children_bits<'tcx, F, PO>(tcx_mir: &PO,
147+
move_data: &MoveData<'tcx>,
148+
move_path_index: MovePathIndex,
149+
mut each_child: F)
150+
where F: FnMut(MovePathIndex), PO: PlaceOneDropFlag<'tcx>
121151
{
122-
fn is_terminal_path<'tcx, U>(move_data: &MoveData<'tcx>,
123-
path: MovePathIndex,
124-
has_uniform_drop_state: U) -> bool
125-
where U: Fn(&Place<'tcx>) -> bool
152+
fn is_terminal_path<'tcx, PO>(tcx_mir: &PO,
153+
move_data: &MoveData<'tcx>,
154+
path: MovePathIndex) -> bool
155+
where PO: PlaceOneDropFlag<'tcx>
126156
{
127-
// lvalue_contents_drop_state_cannot_differ
128-
has_uniform_drop_state(&move_data.move_paths[path].place)
157+
let place = &move_data.move_paths[path].place;
158+
tcx_mir.place_contents_drop_state_cannot_differ(place)
129159
}
130160

131-
fn on_all_children_bits<'tcx, F, U>(move_data: &MoveData<'tcx>,
132-
move_path_index: MovePathIndex,
133-
has_uniform_drop_state: &U,
134-
each_child: &mut F)
135-
where F: FnMut(MovePathIndex), U: Fn(&Place<'tcx>) -> bool
161+
fn on_all_children_bits<'tcx, F, PO>(tcx_mir: &PO,
162+
move_data: &MoveData<'tcx>,
163+
move_path_index: MovePathIndex,
164+
each_child: &mut F)
165+
where F: FnMut(MovePathIndex), PO: PlaceOneDropFlag<'tcx>
136166
{
137167
each_child(move_path_index);
138168

139-
if is_terminal_path(move_data, move_path_index, has_uniform_drop_state) {
169+
if is_terminal_path(tcx_mir, move_data, move_path_index) {
140170
return
141171
}
142172

143173
let mut next_child_index = move_data.move_paths[move_path_index].first_child;
144174
while let Some(child_index) = next_child_index {
145-
on_all_children_bits(move_data, child_index, has_uniform_drop_state, each_child);
175+
on_all_children_bits(tcx_mir, move_data, child_index, each_child);
146176
next_child_index = move_data.move_paths[child_index].next_sibling;
147177
}
148178
}
149-
on_all_children_bits(move_data, move_path_index, &has_uniform_drop_state, &mut each_child);
179+
on_all_children_bits(tcx_mir, move_data, move_path_index, &mut each_child);
150180
}
151181

152-
pub(crate) fn on_all_drop_children_bits<'tcx, F, U, N>(move_data: &MoveData<'tcx>,
153-
path: MovePathIndex,
154-
has_uniform_drop_state: U,
155-
needs_drop: N,
156-
mut each_child: F)
157-
where F: FnMut(MovePathIndex),
158-
U: Fn(&Place<'tcx>) -> bool,
159-
N: Fn(&Place<'tcx>) -> bool,
182+
pub(crate) fn on_all_drop_children_bits<'tcx, F, PO>(tcx_mir_param_env: &PO,
183+
move_data: &MoveData<'tcx>,
184+
path: MovePathIndex,
185+
mut each_child: F)
186+
where F: FnMut(MovePathIndex), PO: PlaceOneDropFlag<'tcx> + PlaceNeedsDrop<'tcx>
160187
{
161-
on_all_children_bits(move_data, path, has_uniform_drop_state, |child| {
188+
on_all_children_bits(tcx_mir_param_env, move_data, path, |child| {
162189
let place = &move_data.move_paths[path].place;
163190
// let ty = place.ty(mir, tcx).to_ty(tcx);
164191
// debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, place, ty);
165192

166193
// let gcx = tcx.global_tcx();
167194
// let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap();
168195
// if erased_ty.needs_drop(gcx, ctxt.param_env) {
169-
if needs_drop(place) {
196+
if tcx_mir_param_env.needs_drop(place) {
170197
each_child(child);
171198
} else {
172199
debug!("on_all_drop_children_bits - skipping")
173200
}
174201
})
175202
}
176203

177-
pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F, U>(
204+
pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F, PO>(
205+
tcx_mir: &PO,
178206
mir: &Mir<'tcx>,
179207
move_data: &MoveData<'tcx>,
180-
has_uniform_drop_state: U,
181208
mut callback: F)
182-
where F: FnMut(MovePathIndex, DropFlagState), U: Fn(&Place<'tcx>) -> bool
209+
where F: FnMut(MovePathIndex, DropFlagState), PO: PlaceOneDropFlag<'tcx>
183210
{
184211
for arg in mir.args_iter() {
185212
let place = Place::Local(arg);
186213
let lookup_result = move_data.rev_lookup.find(&place);
187-
on_lookup_result_bits(move_data,
214+
on_lookup_result_bits(tcx_mir,
215+
move_data,
188216
lookup_result,
189-
&has_uniform_drop_state,
190217
|mpi| callback(mpi, DropFlagState::Present));
191218
}
192219
}
193220

194-
pub(crate) fn drop_flag_effects_for_location<'tcx, F, U>(move_data: &MoveData<'tcx>,
195-
loc: Location,
196-
has_uniform_drop_state: U,
197-
mut callback: F)
198-
where F: FnMut(MovePathIndex, DropFlagState), U: Fn(&Place<'tcx>) -> bool
221+
pub(crate) fn drop_flag_effects_for_location<'tcx, F, PO>(tcx_mir: &PO,
222+
move_data: &MoveData<'tcx>,
223+
loc: Location,
224+
mut callback: F)
225+
where F: FnMut(MovePathIndex, DropFlagState), PO: PlaceOneDropFlag<'tcx>
199226
{
200227
debug!("drop_flag_effects_for_location({:?})", loc);
201228

@@ -204,38 +231,38 @@ pub(crate) fn drop_flag_effects_for_location<'tcx, F, U>(move_data: &MoveData<'t
204231
let path = mi.move_path_index(move_data);
205232
debug!("moving out of path {:?}", move_data.move_paths[path]);
206233

207-
on_all_children_bits(move_data,
234+
on_all_children_bits(tcx_mir,
235+
move_data,
208236
path,
209-
&has_uniform_drop_state,
210237
|mpi| callback(mpi, DropFlagState::Absent))
211238
}
212239

213240
debug!("drop_flag_effects: assignment for location({:?})", loc);
214241

215242
for_location_inits(
243+
tcx_mir,
216244
move_data,
217245
loc,
218-
has_uniform_drop_state,
219246
|mpi| callback(mpi, DropFlagState::Present)
220247
);
221248
}
222249

223-
pub(crate) fn for_location_inits<'tcx, F, U>(
250+
pub(crate) fn for_location_inits<'tcx, F, PO>(
251+
tcx_mir: &PO,
224252
move_data: &MoveData<'tcx>,
225253
loc: Location,
226-
has_uniform_drop_state: U,
227254
mut callback: F)
228-
where F: FnMut(MovePathIndex), U: Fn(&Place<'tcx>) -> bool
255+
where F: FnMut(MovePathIndex), PO: PlaceOneDropFlag<'tcx>
229256
{
230257
for ii in &move_data.init_loc_map[loc] {
231258
let init = move_data.inits[*ii];
232259
match init.kind {
233260
InitKind::Deep => {
234261
let path = init.path;
235262

236-
on_all_children_bits(move_data,
263+
on_all_children_bits(tcx_mir,
264+
move_data,
237265
path,
238-
&has_uniform_drop_state,
239266
&mut callback)
240267
},
241268
InitKind::Shallow => {

‎src/librustc_mir/dataflow/impls/mod.rs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use super::{BitDenotation, BlockSets, InitialFlow};
2929
use super::drop_flag_effects_for_function_entry;
3030
use super::drop_flag_effects_for_location;
3131
use super::{on_lookup_result_bits, for_location_inits};
32-
use super::place_contents_drop_state_cannot_differ;
3332

3433
mod storage_liveness;
3534

@@ -336,9 +335,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
336335
fn start_block_effect(&self, sets: &mut BlockSets<MovePathIndex>)
337336
{
338337
drop_flag_effects_for_function_entry(
338+
&(self.tcx, self.mir),
339339
self.mir,
340340
&self.mdpe.move_data,
341-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
342341
|path, s| {
343342
assert!(s == DropFlagState::Present);
344343
sets.on_entry.add(&path);
@@ -350,9 +349,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
350349
location: Location)
351350
{
352351
drop_flag_effects_for_location(
352+
&(self.tcx, self.mir),
353353
&self.mdpe.move_data,
354354
location,
355-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
356355
|path, s| Self::update_bits(sets, path, s))
357356
}
358357

@@ -361,9 +360,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
361360
location: Location)
362361
{
363362
drop_flag_effects_for_location(
363+
&(self.tcx, self.mir),
364364
&self.mdpe.move_data,
365365
location,
366-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
367366
|path, s| Self::update_bits(sets, path, s))
368367
}
369368

@@ -374,10 +373,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'gcx, 'tcx> {
374373
dest_place: &mir::Place) {
375374
// when a call returns successfully, that means we need to set
376375
// the bits for that dest_place to 1 (initialized).
377-
on_lookup_result_bits(self.move_data(),
376+
on_lookup_result_bits(&(self.tcx, self.mir),
377+
self.move_data(),
378378
self.move_data().rev_lookup.find(dest_place),
379-
|place| place_contents_drop_state_cannot_differ(
380-
self.tcx, self.mir, place),
381379
|mpi| { in_out.add(&mpi); });
382380
}
383381
}
@@ -395,8 +393,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
395393
for e in sets.on_entry.words_mut() { *e = !0; }
396394

397395
drop_flag_effects_for_function_entry(
398-
self.mir, &self.mdpe.move_data,
399-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
396+
&(self.tcx, self.mir),
397+
self.mir,
398+
&self.mdpe.move_data,
400399
|path, s| {
401400
assert!(s == DropFlagState::Present);
402401
sets.on_entry.remove(&path);
@@ -408,9 +407,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
408407
location: Location)
409408
{
410409
drop_flag_effects_for_location(
410+
&(self.tcx, self.mir),
411411
&self.mdpe.move_data,
412412
location,
413-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
414413
|path, s| Self::update_bits(sets, path, s))
415414
}
416415

@@ -419,9 +418,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
419418
location: Location)
420419
{
421420
drop_flag_effects_for_location(
421+
&(self.tcx, self.mir),
422422
&self.mdpe.move_data,
423423
location,
424-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
425424
|path, s| Self::update_bits(sets, path, s))
426425
}
427426

@@ -432,10 +431,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MaybeUninitializedLvals<'a, 'gcx, 'tcx> {
432431
dest_place: &mir::Place) {
433432
// when a call returns successfully, that means we need to set
434433
// the bits for that dest_place to 0 (initialized).
435-
on_lookup_result_bits(self.move_data(),
434+
on_lookup_result_bits(&(self.tcx, self.mir),
435+
self.move_data(),
436436
self.move_data().rev_lookup.find(dest_place),
437-
|place| place_contents_drop_state_cannot_differ(
438-
self.tcx, self.mir, place),
439437
|mpi| { in_out.remove(&mpi); });
440438
}
441439
}
@@ -452,8 +450,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'gcx, 'tcx
452450
for e in sets.on_entry.words_mut() { *e = 0; }
453451

454452
drop_flag_effects_for_function_entry(
455-
self.mir, &self.mdpe.move_data,
456-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
453+
&(self.tcx, self.mir),
454+
self.mir,
455+
&self.mdpe.move_data,
457456
|path, s| {
458457
assert!(s == DropFlagState::Present);
459458
sets.on_entry.add(&path);
@@ -465,9 +464,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'gcx, 'tcx
465464
location: Location)
466465
{
467466
drop_flag_effects_for_location(
467+
&(self.tcx, self.mir),
468468
&self.mdpe.move_data,
469469
location,
470-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
471470
|path, s| Self::update_bits(sets, path, s))
472471
}
473472

@@ -476,9 +475,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'gcx, 'tcx
476475
location: Location)
477476
{
478477
drop_flag_effects_for_location(
478+
&(self.tcx, self.mir),
479479
&self.mdpe.move_data,
480480
location,
481-
|lv| place_contents_drop_state_cannot_differ(self.tcx, self.mir, lv),
482481
|path, s| Self::update_bits(sets, path, s))
483482
}
484483

@@ -489,10 +488,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for DefinitelyInitializedLvals<'a, 'gcx, 'tcx
489488
dest_place: &mir::Place) {
490489
// when a call returns successfully, that means we need to set
491490
// the bits for that dest_place to 1 (initialized).
492-
on_lookup_result_bits(self.move_data(),
491+
on_lookup_result_bits(&(self.tcx, self.mir),
492+
self.move_data(),
493493
self.move_data().rev_lookup.find(dest_place),
494-
|place| place_contents_drop_state_cannot_differ(
495-
self.tcx, self.mir, place),
496494
|mpi| { in_out.add(&mpi); });
497495
}
498496
}
@@ -535,9 +533,8 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MovingOutStatements<'a, 'gcx, 'tcx> {
535533
}
536534
}
537535

538-
for_location_inits(move_data, location,
539-
|place| place_contents_drop_state_cannot_differ(
540-
self.tcx, mir, place),
536+
for_location_inits(
537+
&(self.tcx, self.mir), move_data, location,
541538
|mpi| for moi in &path_map[mpi] {
542539
assert!(moi.index() < bits_per_block);
543540
sets.kill_set.add(&moi);
@@ -549,7 +546,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MovingOutStatements<'a, 'gcx, 'tcx> {
549546
sets: &mut BlockSets<MoveOutIndex>,
550547
location: Location)
551548
{
552-
let (tcx, mir, move_data) = (self.tcx, self.mir, self.move_data());
549+
let (mir, move_data) = (self.mir, self.move_data());
553550
let term = mir[location.block].terminator();
554551
let loc_map = &move_data.loc_map;
555552
let path_map = &move_data.path_map;
@@ -562,9 +559,8 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MovingOutStatements<'a, 'gcx, 'tcx> {
562559
zero_to_one(sets.gen_set.words_mut(), *move_index);
563560
}
564561

565-
for_location_inits(move_data, location,
566-
|place| place_contents_drop_state_cannot_differ(
567-
tcx, self.mir, place),
562+
for_location_inits(
563+
&(self.tcx, self.mir), move_data, location,
568564
|mpi| for moi in &path_map[mpi] {
569565
assert!(moi.index() < bits_per_block);
570566
sets.kill_set.add(&moi);
@@ -581,10 +577,9 @@ impl<'a, 'gcx, 'tcx> BitDenotation for MovingOutStatements<'a, 'gcx, 'tcx> {
581577
let bits_per_block = self.bits_per_block();
582578

583579
let path_map = &move_data.path_map;
584-
on_lookup_result_bits(move_data,
580+
on_lookup_result_bits(&(self.tcx, self.mir),
581+
move_data,
585582
move_data.rev_lookup.find(dest_place),
586-
|place| place_contents_drop_state_cannot_differ(
587-
self.tcx, self.mir, place),
588583
|mpi| for moi in &path_map[mpi] {
589584
assert!(moi.index() < bits_per_block);
590585
in_out.remove(&moi);

‎src/librustc_mir/transform/elaborate_drops.rs

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use dataflow::{MaybeInitializedLvals, MaybeUninitializedLvals};
1313
use dataflow::{DataflowResults};
1414
use dataflow::{on_all_children_bits, on_all_drop_children_bits};
1515
use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits};
16-
use dataflow::{place_contents_drop_state_cannot_differ, place_needs_drop};
1716
use dataflow::MoveDataParamEnv;
1817
use dataflow::{self, do_dataflow, DebugFormatted};
1918
use rustc::hir;
@@ -129,10 +128,9 @@ fn find_dead_unwinds<'a, 'tcx>(
129128
debug!("find_dead_unwinds @ {:?}: path({:?})={:?}", bb, location, path);
130129

131130
let mut maybe_live = false;
132-
on_all_drop_children_bits(&env.move_data,
131+
on_all_drop_children_bits(&(tcx, mir, env.param_env),
132+
&env.move_data,
133133
path,
134-
|lv| place_contents_drop_state_cannot_differ(tcx, mir, lv),
135-
|lv| place_needs_drop(tcx, mir, env.param_env, lv),
136134
|child| {
137135
let (child_maybe_live, _) = init_data.state(child);
138136
maybe_live |= child_maybe_live;
@@ -160,8 +158,8 @@ impl InitializationData {
160158
loc: Location)
161159
{
162160
drop_flag_effects_for_location(
161+
&(tcx, mir),
163162
&env.move_data, loc,
164-
|lv| place_contents_drop_state_cannot_differ(tcx, mir, lv),
165163
|path, df| {
166164
debug!("at location {:?}: setting {:?} to {:?}",
167165
loc, path, df);
@@ -220,12 +218,9 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
220218
let mut some_live = false;
221219
let mut some_dead = false;
222220
let mut children_count = 0;
223-
let tcx = self.tcx();
224-
let mir = self.mir();
225221
on_all_drop_children_bits(
222+
&(self.tcx(), self.mir(), self.param_env()),
226223
&self.ctxt.env.move_data, path,
227-
|lv| place_contents_drop_state_cannot_differ(tcx, mir, lv),
228-
|lv| place_needs_drop(tcx, mir, self.param_env(), lv),
229224
|child| {
230225
let (live, dead) = self.init_data.state(child);
231226
debug!("elaborate_drop: state({:?}) = {:?}",
@@ -251,10 +246,9 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
251246
self.ctxt.set_drop_flag(loc, path, DropFlagState::Absent);
252247
}
253248
DropFlagMode::Deep => {
254-
let tcx = self.tcx();
255-
let mir = self.mir();
256-
on_all_children_bits(self.ctxt.move_data(), path,
257-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
249+
on_all_children_bits(&(self.tcx(), self.mir()),
250+
self.ctxt.move_data(),
251+
path,
258252
|child| {
259253
self.ctxt.set_drop_flag(loc, child, DropFlagState::Absent)
260254
})
@@ -405,11 +399,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
405399
}
406400
};
407401

408-
let (tcx, mir, param_env) = (self.tcx, self.mir, self.param_env());
409402
on_all_drop_children_bits(
403+
&(self.tcx, self.mir, self.param_env()),
410404
&self.env.move_data, path,
411-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
412-
|p| place_needs_drop(tcx, mir, param_env, p),
413405
|child| {
414406
let (maybe_live, maybe_dead) = init_data.state(child);
415407
debug!("collect_drop_flags: collecting {:?} from {:?}@{:?} - {:?}",
@@ -536,10 +528,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
536528
target,
537529
Unwind::To(unwind),
538530
bb);
539-
let (tcx, mir) = (self.tcx, self.mir);
540531
on_all_children_bits(
532+
&(self.tcx, self.mir),
541533
self.move_data(), path,
542-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
543534
|child| {
544535
self.set_drop_flag(Location { block: target, statement_index: 0 },
545536
child, DropFlagState::Present);
@@ -599,22 +590,20 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
599590

600591
let loc = Location { block: tgt, statement_index: 0 };
601592
let path = self.move_data().rev_lookup.find(place);
602-
let (tcx, mir) = (self.tcx, self.mir);
603593
on_lookup_result_bits(
594+
&(self.tcx, self.mir),
604595
self.move_data(), path,
605-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
606596
|child| self.set_drop_flag(loc, child, DropFlagState::Present));
607597
}
608598
}
609599
}
610600

611601
fn drop_flags_for_args(&mut self) {
612602
let loc = Location { block: START_BLOCK, statement_index: 0 };
613-
let (tcx, mir) = (self.tcx, self.mir);
614603
dataflow::drop_flag_effects_for_function_entry(
615-
mir,
604+
&(self.tcx, self.mir),
605+
self.mir,
616606
&self.env.move_data,
617-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
618607
|path, ds| {
619608
self.set_drop_flag(loc, path, ds);
620609
})
@@ -658,10 +647,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
658647
}
659648
}
660649
let loc = Location { block: bb, statement_index: i };
661-
let (tcx, mir) = (self.tcx, self.mir);
662650
dataflow::drop_flag_effects_for_location(
651+
&(self.tcx, self.mir),
663652
&self.env.move_data, loc,
664-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
665653
|path, ds| {
666654
if ds == DropFlagState::Absent || allow_initializations {
667655
self.set_drop_flag(loc, path, ds)
@@ -679,10 +667,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
679667

680668
let loc = Location { block: bb, statement_index: data.statements.len() };
681669
let path = self.move_data().rev_lookup.find(place);
682-
let (tcx, mir) = (self.tcx, self.mir);
683670
on_lookup_result_bits(
671+
&(self.tcx, self.mir),
684672
self.move_data(), path,
685-
|p| place_contents_drop_state_cannot_differ(tcx, mir, p),
686673
|child| self.set_drop_flag(loc, child, DropFlagState::Present)
687674
);
688675
}

0 commit comments

Comments
 (0)
Please sign in to comment.