Skip to content

Commit 506086e

Browse files
committed
jump to the cleanup block in the unwind path for open_drop_for_box
silly bug. Hopefully the last one.
1 parent 148f842 commit 506086e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/librustc_borrowck/borrowck/mir/elaborate_drops.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
694694
targets: variant_drops
695695
});
696696

697-
self.drop_flag_test_block(c, c.is_cleanup, switch_block)
697+
self.drop_flag_test_block(c, switch_block)
698698
}
699699
}
700700
}
@@ -749,7 +749,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
749749
);
750750
}
751751

752-
self.drop_flag_test_block(c, c.is_cleanup, drop_block)
752+
self.drop_flag_test_block(c, drop_block)
753753
}
754754

755755
/// Create a simple conditional drop.
@@ -764,7 +764,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
764764
let drop_bb = self.drop_block(c);
765765
self.drop_flags_for_drop(c, drop_bb);
766766

767-
self.drop_flag_test_block(c, c.is_cleanup, drop_bb)
767+
self.drop_flag_test_block(c, drop_bb)
768768
}
769769

770770
fn new_block<'a>(&mut self,
@@ -791,22 +791,30 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
791791

792792
fn drop_flag_test_block<'a>(&mut self,
793793
c: &DropCtxt<'a, 'tcx>,
794-
is_cleanup: bool,
795794
on_set: BasicBlock)
796-
-> BasicBlock
795+
-> BasicBlock {
796+
self.drop_flag_test_block_with_succ(c, c.is_cleanup, on_set, c.succ)
797+
}
798+
799+
fn drop_flag_test_block_with_succ<'a>(&mut self,
800+
c: &DropCtxt<'a, 'tcx>,
801+
is_cleanup: bool,
802+
on_set: BasicBlock,
803+
on_unset: BasicBlock)
804+
-> BasicBlock
797805
{
798806
let (maybe_live, maybe_dead) = c.init_data.state(c.path);
799807
debug!("drop_flag_test_block({:?},{:?},{:?}) - {:?}",
800808
c, is_cleanup, on_set, (maybe_live, maybe_dead));
801809

802810
match (maybe_live, maybe_dead) {
803-
(false, _) => c.succ,
811+
(false, _) => on_unset,
804812
(true, false) => on_set,
805813
(true, true) => {
806814
let flag = self.drop_flag(c.path).unwrap();
807815
self.new_block(c, is_cleanup, TerminatorKind::If {
808816
cond: Operand::Consume(flag),
809-
targets: (on_set, c.succ)
817+
targets: (on_set, on_unset)
810818
})
811819
}
812820
}
@@ -841,7 +849,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
841849
is_cleanup: bool
842850
) -> BasicBlock {
843851
let block = self.unelaborated_free_block(c, ty, target, is_cleanup);
844-
self.drop_flag_test_block(c, is_cleanup, block)
852+
self.drop_flag_test_block_with_succ(c, is_cleanup, block, target)
845853
}
846854

847855
fn unelaborated_free_block<'a>(

0 commit comments

Comments
 (0)