@@ -88,11 +88,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8888 this. cfg . push_assign ( block, scope_id, expr_span, & is_min,
8989 Rvalue :: BinaryOp ( BinOp :: Eq , arg. clone ( ) , minval) ) ;
9090
91- block = this. with_cond (
92- block, expr_span, Operand :: Consume ( is_min) , |this, block| {
93- this. panic ( block, "attempted to negate with overflow" , expr_span) ;
94- block
95- } ) ;
91+ let ( of_block, ok_block) = this. build_cond_br ( block, expr_span,
92+ Operand :: Consume ( is_min) ) ;
93+ this. panic ( of_block, "attempted to negate with overflow" , expr_span) ;
94+ block = ok_block;
9695 }
9796 block. and ( Rvalue :: UnaryOp ( op, arg) )
9897 }
@@ -243,7 +242,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
243242 }
244243 }
245244
246- pub fn build_binary_op ( & mut self , mut block : BasicBlock , op : BinOp , span : Span , ty : ty:: Ty < ' tcx > ,
245+ pub fn build_binary_op ( & mut self , mut block : BasicBlock ,
246+ op : BinOp , span : Span , ty : ty:: Ty < ' tcx > ,
247247 lhs : Operand < ' tcx > , rhs : Operand < ' tcx > ) -> BlockAnd < Rvalue < ' tcx > > {
248248 let scope_id = self . innermost_scope_id ( ) ;
249249 let bool_ty = self . hir . bool_ty ( ) ;
@@ -267,12 +267,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
267267 "arithmetic operation overflowed"
268268 } ;
269269
270- block = self . with_cond ( block, span, Operand :: Consume ( of) , |this, block| {
271- this. panic ( block, msg, span) ;
272- block
273- } ) ;
270+ let ( of_block, ok_block) = self . build_cond_br ( block, span, Operand :: Consume ( of) ) ;
271+ self . panic ( of_block, msg, span) ;
274272
275- block . and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
273+ ok_block . and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
276274 } else {
277275 if ty. is_integral ( ) && ( op == BinOp :: Div || op == BinOp :: Rem ) {
278276 // Checking division and remainder is more complex, since we 1. always check
@@ -292,10 +290,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
292290 self . cfg . push_assign ( block, scope_id, span, & is_zero,
293291 Rvalue :: BinaryOp ( BinOp :: Eq , rhs. clone ( ) , zero) ) ;
294292
295- block = self . with_cond ( block, span, Operand :: Consume ( is_zero) , |this, block| {
296- this. panic ( block, zero_msg, span) ;
297- block
298- } ) ;
293+ let ( zero_block, ok_block) = self . build_cond_br ( block, span,
294+ Operand :: Consume ( is_zero) ) ;
295+ self . panic ( zero_block, zero_msg, span) ;
296+
297+ block = ok_block;
299298
300299 // We only need to check for the overflow in one case:
301300 // MIN / -1, and only for signed values.
@@ -319,10 +318,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
319318 self . cfg . push_assign ( block, scope_id, span, & of,
320319 Rvalue :: BinaryOp ( BinOp :: BitAnd , is_neg_1, is_min) ) ;
321320
322- block = self . with_cond ( block, span, Operand :: Consume ( of) , |this, block| {
323- this. panic ( block, overflow_msg, span) ;
324- block
325- } ) ;
321+ let ( of_block, ok_block) = self . build_cond_br ( block, span,
322+ Operand :: Consume ( of) ) ;
323+ self . panic ( of_block, overflow_msg, span) ;
324+
325+ block = ok_block;
326326 }
327327 }
328328
0 commit comments