Skip to content

Commit 82b287a

Browse files
committed
test "needs drop" on region-erased, lifted types
This will be important in next commit, since the input types will be tagged not with `'gcx` but rather `'tcx`. Also, using the region-erased, lifted types enables better caching.
1 parent b2c248e commit 82b287a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/librustc_mir/dataflow/drop_flag_effects.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ pub(crate) fn on_all_drop_children_bits<'a, 'tcx, F>(
151151
let ty = lvalue.ty(mir, tcx).to_ty(tcx);
152152
debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, lvalue, ty);
153153

154-
if ty.needs_drop(tcx, ctxt.param_env) {
154+
let gcx = tcx.global_tcx();
155+
let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap();
156+
if erased_ty.needs_drop(gcx, ctxt.param_env) {
155157
each_child(child);
156158
} else {
157159
debug!("on_all_drop_children_bits - skipping")
@@ -196,7 +198,9 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'tcx, F>(
196198
// don't move out of non-Copy things
197199
let lvalue = &move_data.move_paths[path].lvalue;
198200
let ty = lvalue.ty(mir, tcx).to_ty(tcx);
199-
if !ty.moves_by_default(tcx, param_env, DUMMY_SP) {
201+
let gcx = tcx.global_tcx();
202+
let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap();
203+
if !erased_ty.moves_by_default(gcx, param_env, DUMMY_SP) {
200204
continue;
201205
}
202206

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,10 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
352352
debug!("gather_move({:?}, {:?})", self.loc, lval);
353353

354354
let tcx = self.builder.tcx;
355+
let gcx = tcx.global_tcx();
355356
let lv_ty = lval.ty(self.builder.mir, tcx).to_ty(tcx);
356-
if !lv_ty.moves_by_default(tcx, self.builder.param_env, DUMMY_SP) {
357+
let erased_ty = gcx.lift(&tcx.erase_regions(&lv_ty)).unwrap();
358+
if !erased_ty.moves_by_default(gcx, self.builder.param_env, DUMMY_SP) {
357359
debug!("gather_move({:?}, {:?}) - {:?} is Copy. skipping", self.loc, lval, lv_ty);
358360
return
359361
}

0 commit comments

Comments
 (0)