]> git.lizzy.rs Git - rust.git/commitdiff
jump to the cleanup block in the unwind path for open_drop_for_box
authorAriel Ben-Yehuda <ariel.byd@gmail.com>
Fri, 3 Jun 2016 22:49:34 +0000 (01:49 +0300)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Sat, 4 Jun 2016 10:25:10 +0000 (13:25 +0300)
silly bug. Hopefully the last one.

src/librustc_borrowck/borrowck/mir/elaborate_drops.rs

index 6e5303626f116cc8e9473eec75d9cf90bd746a1f..cbe923ead9f1332fb4fa42cb09e0c5ff28ed813c 100644 (file)
@@ -694,7 +694,7 @@ fn open_drop_for_adt<'a>(&mut self, c: &DropCtxt<'a, 'tcx>,
                         targets: variant_drops
                     });
 
-                self.drop_flag_test_block(c, c.is_cleanup, switch_block)
+                self.drop_flag_test_block(c, switch_block)
             }
         }
     }
@@ -749,7 +749,7 @@ fn complete_drop<'a>(
             );
         }
 
-        self.drop_flag_test_block(c, c.is_cleanup, drop_block)
+        self.drop_flag_test_block(c, drop_block)
     }
 
     /// Create a simple conditional drop.
@@ -764,7 +764,7 @@ fn conditional_drop<'a>(&mut self, c: &DropCtxt<'a, 'tcx>)
         let drop_bb = self.drop_block(c);
         self.drop_flags_for_drop(c, drop_bb);
 
-        self.drop_flag_test_block(c, c.is_cleanup, drop_bb)
+        self.drop_flag_test_block(c, drop_bb)
     }
 
     fn new_block<'a>(&mut self,
@@ -791,22 +791,30 @@ fn elaborated_drop_block<'a>(&mut self, c: &DropCtxt<'a, 'tcx>) -> BasicBlock {
 
     fn drop_flag_test_block<'a>(&mut self,
                                 c: &DropCtxt<'a, 'tcx>,
-                                is_cleanup: bool,
                                 on_set: BasicBlock)
-                                -> BasicBlock
+                                -> BasicBlock {
+        self.drop_flag_test_block_with_succ(c, c.is_cleanup, on_set, c.succ)
+    }
+
+    fn drop_flag_test_block_with_succ<'a>(&mut self,
+                                          c: &DropCtxt<'a, 'tcx>,
+                                          is_cleanup: bool,
+                                          on_set: BasicBlock,
+                                          on_unset: BasicBlock)
+                                          -> BasicBlock
     {
         let (maybe_live, maybe_dead) = c.init_data.state(c.path);
         debug!("drop_flag_test_block({:?},{:?},{:?}) - {:?}",
                c, is_cleanup, on_set, (maybe_live, maybe_dead));
 
         match (maybe_live, maybe_dead) {
-            (false, _) => c.succ,
+            (false, _) => on_unset,
             (true, false) => on_set,
             (true, true) => {
                 let flag = self.drop_flag(c.path).unwrap();
                 self.new_block(c, is_cleanup, TerminatorKind::If {
                     cond: Operand::Consume(flag),
-                    targets: (on_set, c.succ)
+                    targets: (on_set, on_unset)
                 })
             }
         }
@@ -841,7 +849,7 @@ fn box_free_block<'a>(
         is_cleanup: bool
     ) -> BasicBlock {
         let block = self.unelaborated_free_block(c, ty, target, is_cleanup);
-        self.drop_flag_test_block(c, is_cleanup, block)
+        self.drop_flag_test_block_with_succ(c, is_cleanup, block, target)
     }
 
     fn unelaborated_free_block<'a>(