@@ -694,7 +694,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
694
694
targets : variant_drops
695
695
} ) ;
696
696
697
- self . drop_flag_test_block ( c, c . is_cleanup , switch_block)
697
+ self . drop_flag_test_block ( c, switch_block)
698
698
}
699
699
}
700
700
}
@@ -749,7 +749,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
749
749
) ;
750
750
}
751
751
752
- self . drop_flag_test_block ( c, c . is_cleanup , drop_block)
752
+ self . drop_flag_test_block ( c, drop_block)
753
753
}
754
754
755
755
/// Create a simple conditional drop.
@@ -764,7 +764,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
764
764
let drop_bb = self . drop_block ( c) ;
765
765
self . drop_flags_for_drop ( c, drop_bb) ;
766
766
767
- self . drop_flag_test_block ( c, c . is_cleanup , drop_bb)
767
+ self . drop_flag_test_block ( c, drop_bb)
768
768
}
769
769
770
770
fn new_block < ' a > ( & mut self ,
@@ -791,22 +791,30 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
791
791
792
792
fn drop_flag_test_block < ' a > ( & mut self ,
793
793
c : & DropCtxt < ' a , ' tcx > ,
794
- is_cleanup : bool ,
795
794
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
797
805
{
798
806
let ( maybe_live, maybe_dead) = c. init_data . state ( c. path ) ;
799
807
debug ! ( "drop_flag_test_block({:?},{:?},{:?}) - {:?}" ,
800
808
c, is_cleanup, on_set, ( maybe_live, maybe_dead) ) ;
801
809
802
810
match ( maybe_live, maybe_dead) {
803
- ( false , _) => c . succ ,
811
+ ( false , _) => on_unset ,
804
812
( true , false ) => on_set,
805
813
( true , true ) => {
806
814
let flag = self . drop_flag ( c. path ) . unwrap ( ) ;
807
815
self . new_block ( c, is_cleanup, TerminatorKind :: If {
808
816
cond : Operand :: Consume ( flag) ,
809
- targets : ( on_set, c . succ )
817
+ targets : ( on_set, on_unset )
810
818
} )
811
819
}
812
820
}
@@ -841,7 +849,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
841
849
is_cleanup : bool
842
850
) -> BasicBlock {
843
851
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 )
845
853
}
846
854
847
855
fn unelaborated_free_block < ' a > (
0 commit comments