@@ -88,11 +88,10 @@ impl<'a,'tcx> Builder<'a,'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 }
@@ -246,7 +245,8 @@ impl<'a,'tcx> Builder<'a,'tcx> {
246245 }
247246 }
248247
249- pub fn build_binary_op ( & mut self , mut block : BasicBlock , op : BinOp , span : Span , ty : ty:: Ty < ' tcx > ,
248+ pub fn build_binary_op ( & mut self , mut block : BasicBlock ,
249+ op : BinOp , span : Span , ty : ty:: Ty < ' tcx > ,
250250 lhs : Operand < ' tcx > , rhs : Operand < ' tcx > ) -> BlockAnd < Rvalue < ' tcx > > {
251251 let scope_id = self . innermost_scope_id ( ) ;
252252 let bool_ty = self . hir . bool_ty ( ) ;
@@ -270,12 +270,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
270270 "arithmetic operation overflowed"
271271 } ;
272272
273- block = self . with_cond ( block, span, Operand :: Consume ( of) , |this, block| {
274- this. panic ( block, msg, span) ;
275- block
276- } ) ;
273+ let ( of_block, ok_block) = self . build_cond_br ( block, span, Operand :: Consume ( of) ) ;
274+ self . panic ( of_block, msg, span) ;
277275
278- block . and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
276+ ok_block . and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
279277 } else {
280278 if ty. is_integral ( ) && ( op == BinOp :: Div || op == BinOp :: Rem ) {
281279 // Checking division and remainder is more complex, since we 1. always check
@@ -295,10 +293,11 @@ impl<'a,'tcx> Builder<'a,'tcx> {
295293 self . cfg . push_assign ( block, scope_id, span, & is_zero,
296294 Rvalue :: BinaryOp ( BinOp :: Eq , rhs. clone ( ) , zero) ) ;
297295
298- block = self . with_cond ( block, span, Operand :: Consume ( is_zero) , |this, block| {
299- this. panic ( block, zero_msg, span) ;
300- block
301- } ) ;
296+ let ( zero_block, ok_block) = self . build_cond_br ( block, span,
297+ Operand :: Consume ( is_zero) ) ;
298+ self . panic ( zero_block, zero_msg, span) ;
299+
300+ block = ok_block;
302301
303302 // We only need to check for the overflow in one case:
304303 // MIN / -1, and only for signed values.
@@ -322,10 +321,11 @@ impl<'a,'tcx> Builder<'a,'tcx> {
322321 self . cfg . push_assign ( block, scope_id, span, & of,
323322 Rvalue :: BinaryOp ( BinOp :: BitAnd , is_neg_1, is_min) ) ;
324323
325- block = self . with_cond ( block, span, Operand :: Consume ( of) , |this, block| {
326- this. panic ( block, overflow_msg, span) ;
327- block
328- } ) ;
324+ let ( of_block, ok_block) = self . build_cond_br ( block, span,
325+ Operand :: Consume ( of) ) ;
326+ self . panic ( of_block, overflow_msg, span) ;
327+
328+ block = ok_block;
329329 }
330330 }
331331
0 commit comments