@@ -88,11 +88,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
88
88
this. cfg . push_assign ( block, scope_id, expr_span, & is_min,
89
89
Rvalue :: BinaryOp ( BinOp :: Eq , arg. clone ( ) , minval) ) ;
90
90
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;
96
95
}
97
96
block. and ( Rvalue :: UnaryOp ( op, arg) )
98
97
}
@@ -243,7 +242,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
243
242
}
244
243
}
245
244
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 > ,
247
247
lhs : Operand < ' tcx > , rhs : Operand < ' tcx > ) -> BlockAnd < Rvalue < ' tcx > > {
248
248
let scope_id = self . innermost_scope_id ( ) ;
249
249
let bool_ty = self . hir . bool_ty ( ) ;
@@ -267,12 +267,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
267
267
"arithmetic operation overflowed"
268
268
} ;
269
269
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) ;
274
272
275
- block . and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
273
+ ok_block . and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
276
274
} else {
277
275
if ty. is_integral ( ) && ( op == BinOp :: Div || op == BinOp :: Rem ) {
278
276
// Checking division and remainder is more complex, since we 1. always check
@@ -292,10 +290,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
292
290
self . cfg . push_assign ( block, scope_id, span, & is_zero,
293
291
Rvalue :: BinaryOp ( BinOp :: Eq , rhs. clone ( ) , zero) ) ;
294
292
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;
299
298
300
299
// We only need to check for the overflow in one case:
301
300
// MIN / -1, and only for signed values.
@@ -319,10 +318,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
319
318
self . cfg . push_assign ( block, scope_id, span, & of,
320
319
Rvalue :: BinaryOp ( BinOp :: BitAnd , is_neg_1, is_min) ) ;
321
320
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;
326
326
}
327
327
}
328
328
0 commit comments