]> git.lizzy.rs Git - rust.git/commitdiff
test "needs drop" on region-erased, lifted types
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 30 Oct 2017 09:28:46 +0000 (05:28 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 31 Oct 2017 16:41:40 +0000 (12:41 -0400)
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.

src/librustc_mir/dataflow/drop_flag_effects.rs
src/librustc_mir/dataflow/move_paths/builder.rs

index bd41bce67da8ead21670beefeba21af6ba57b5a3..8f34278e1457aebd27d3ba3e5161fec76174e1c5 100644 (file)
@@ -151,7 +151,9 @@ pub(crate) fn on_all_drop_children_bits<'a, 'tcx, F>(
         let ty = lvalue.ty(mir, tcx).to_ty(tcx);
         debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, lvalue, ty);
 
-        if ty.needs_drop(tcx, ctxt.param_env) {
+        let gcx = tcx.global_tcx();
+        let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap();
+        if erased_ty.needs_drop(gcx, ctxt.param_env) {
             each_child(child);
         } else {
             debug!("on_all_drop_children_bits - skipping")
@@ -196,7 +198,9 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'tcx, F>(
         // don't move out of non-Copy things
         let lvalue = &move_data.move_paths[path].lvalue;
         let ty = lvalue.ty(mir, tcx).to_ty(tcx);
-        if !ty.moves_by_default(tcx, param_env, DUMMY_SP) {
+        let gcx = tcx.global_tcx();
+        let erased_ty = gcx.lift(&tcx.erase_regions(&ty)).unwrap();
+        if !erased_ty.moves_by_default(gcx, param_env, DUMMY_SP) {
             continue;
         }
 
index 0790d937cebf014df686036a22f07ea2c78658e4..147a620c40e4ef26fbfcb10e4ccae2a21369e6bb 100644 (file)
@@ -352,8 +352,10 @@ fn gather_move(&mut self, lval: &Lvalue<'tcx>) {
         debug!("gather_move({:?}, {:?})", self.loc, lval);
 
         let tcx = self.builder.tcx;
+        let gcx = tcx.global_tcx();
         let lv_ty = lval.ty(self.builder.mir, tcx).to_ty(tcx);
-        if !lv_ty.moves_by_default(tcx, self.builder.param_env, DUMMY_SP) {
+        let erased_ty = gcx.lift(&tcx.erase_regions(&lv_ty)).unwrap();
+        if !erased_ty.moves_by_default(gcx, self.builder.param_env, DUMMY_SP) {
             debug!("gather_move({:?}, {:?}) - {:?} is Copy. skipping", self.loc, lval, lv_ty);
             return
         }