@@ -413,7 +413,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
413413 location : mir:: Place < ' tcx > ,
414414 target : mir:: BasicBlock ,
415415 unwind : Option < mir:: BasicBlock > ,
416+ test : & mir:: Operand < ' tcx > ,
416417 ) {
418+ let drop_flag = self . codegen_operand ( & mut bx, test) ;
419+ let drop_block = bx. append_sibling_block ( "drop" ) ;
420+ let lltarget = helper. llbb_with_cleanup ( self , target) ;
421+ bx. cond_br ( drop_flag. immediate ( ) , drop_block, lltarget) ;
422+
423+ bx. switch_to_block ( drop_block) ;
424+ self . set_debug_loc ( & mut bx, helper. terminator . source_info ) ;
425+
417426 let ty = location. ty ( self . mir , bx. tcx ( ) ) . ty ;
418427 let ty = self . monomorphize ( ty) ;
419428 let drop_fn = Instance :: resolve_drop_in_place ( bx. tcx ( ) , ty) ;
@@ -1207,8 +1216,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12071216 bx. unreachable ( ) ;
12081217 }
12091218
1210- mir:: TerminatorKind :: Drop { place, target, unwind, is_replace : _ } => {
1211- self . codegen_drop_terminator ( helper, bx, place, target, unwind) ;
1219+ mir:: TerminatorKind :: DropIf { place, target, unwind, is_replace : _, ref test } => {
1220+ self . codegen_drop_terminator ( helper, bx, place, target, unwind, test ) ;
12121221 }
12131222
12141223 mir:: TerminatorKind :: Assert { ref cond, expected, ref msg, target, cleanup } => {
@@ -1241,6 +1250,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12411250 mir:: TerminatorKind :: GeneratorDrop | mir:: TerminatorKind :: Yield { .. } => {
12421251 bug ! ( "generator ops in codegen" )
12431252 }
1253+ mir:: TerminatorKind :: DropIfInit { .. } => {
1254+ bug ! (
1255+ "drop elaboration should have removed this terminator in codegen {:?}" ,
1256+ self . mir
1257+ )
1258+ }
12441259 mir:: TerminatorKind :: FalseEdge { .. } | mir:: TerminatorKind :: FalseUnwind { .. } => {
12451260 bug ! ( "borrowck false edges in codegen" )
12461261 }
0 commit comments