@@ -89,15 +89,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
89
89
Rvalue :: BinaryOp ( BinOp :: Eq , arg. clone ( ) , minval) ) ;
90
90
91
91
let err = ConstMathErr :: Overflow ( Op :: Neg ) ;
92
- this . cfg . push ( block , Statement {
93
- source_info : this . source_info ( expr_span ) ,
92
+ let stmt = Statement {
93
+ source_info : source_info,
94
94
kind : StatementKind :: Assert {
95
95
cond : Operand :: Consume ( is_min) ,
96
96
expected : false ,
97
97
msg : AssertMessage :: Math ( err) ,
98
98
cleanup : this. diverge_cleanup ( ) ,
99
99
} ,
100
- } ) ;
100
+ } ;
101
+ this. cfg . push ( block, stmt) ;
101
102
}
102
103
block. and ( Rvalue :: UnaryOp ( op, arg) )
103
104
}
@@ -261,7 +262,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
261
262
}
262
263
}
263
264
264
- pub fn build_binary_op ( & mut self , mut block : Block ,
265
+ pub fn build_binary_op ( & mut self , block : Block ,
265
266
op : BinOp , span : Span , ty : ty:: Ty < ' tcx > ,
266
267
lhs : Operand < ' tcx > , rhs : Operand < ' tcx > ) -> BlockAnd < Rvalue < ' tcx > > {
267
268
let source_info = self . source_info ( span) ;
@@ -291,15 +292,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
291
292
}
292
293
} ) ;
293
294
294
- self . cfg . push ( block , Statement {
295
- source_info : self . source_info ( span ) ,
295
+ let stmt = Statement {
296
+ source_info : source_info,
296
297
kind : StatementKind :: Assert {
297
298
cond : Operand :: Consume ( of) ,
298
299
expected : false ,
299
300
msg : AssertMessage :: Math ( err) ,
300
301
cleanup : self . diverge_cleanup ( ) ,
301
302
} ,
302
- } ) ;
303
+ } ;
304
+ self . cfg . push ( block, stmt) ;
303
305
block. and ( Rvalue :: Use ( Operand :: Consume ( val) ) )
304
306
} else {
305
307
if ty. is_integral ( ) && ( op == BinOp :: Div || op == BinOp :: Rem ) {
@@ -320,15 +322,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
320
322
self . cfg . push_assign ( block, source_info, & is_zero,
321
323
Rvalue :: BinaryOp ( BinOp :: Eq , rhs. clone ( ) , zero) ) ;
322
324
323
- self . cfg . push ( block , Statement {
324
- source_info : self . source_info ( span ) ,
325
+ let stmt = Statement {
326
+ source_info : source_info,
325
327
kind : StatementKind :: Assert {
326
328
cond : Operand :: Consume ( is_zero) ,
327
329
expected : false ,
328
330
msg : AssertMessage :: Math ( zero_err) ,
329
331
cleanup : self . diverge_cleanup ( ) ,
330
332
} ,
331
- } ) ;
333
+ } ;
334
+ self . cfg . push ( block, stmt) ;
332
335
333
336
// We only need to check for the overflow in one case:
334
337
// MIN / -1, and only for signed values.
@@ -352,15 +355,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
352
355
self . cfg . push_assign ( block, source_info, & of,
353
356
Rvalue :: BinaryOp ( BinOp :: BitAnd , is_neg_1, is_min) ) ;
354
357
355
- self . cfg . push ( block , Statement {
356
- source_info : self . source_info ( span ) ,
358
+ let stmt = Statement {
359
+ source_info : source_info,
357
360
kind : StatementKind :: Assert {
358
361
cond : Operand :: Consume ( of) ,
359
362
expected : false ,
360
363
msg : AssertMessage :: Math ( overflow_err) ,
361
364
cleanup : self . diverge_cleanup ( ) ,
362
365
} ,
363
- } ) ;
366
+ } ;
367
+ self . cfg . push ( block, stmt) ;
364
368
}
365
369
}
366
370
0 commit comments