@@ -32,7 +32,7 @@ use rustc_index::bit_set::BitSet;
32
32
use rustc_index:: vec:: { Idx , IndexVec } ;
33
33
use rustc_middle:: mir:: visit:: { MutVisitor , MutatingUseContext , PlaceContext , Visitor } ;
34
34
use rustc_middle:: mir:: * ;
35
- use rustc_middle:: ty:: { self , TyCtxt } ;
35
+ use rustc_middle:: ty:: TyCtxt ;
36
36
use std:: borrow:: Cow ;
37
37
38
38
pub struct SimplifyCfg {
@@ -400,33 +400,18 @@ impl<'a, 'tcx> Visitor<'tcx> for DeclMarker<'a, 'tcx> {
400
400
if location. statement_index != block. statements . len ( ) {
401
401
let stmt = & block. statements [ location. statement_index ] ;
402
402
403
- fn can_skip_constant ( c : & ty:: Const < ' tcx > ) -> bool {
404
- // Keep assignments from unevaluated constants around, since the
405
- // evaluation may report errors, even if the use of the constant
406
- // is dead code.
407
- !matches ! ( c. val, ty:: ConstKind :: Unevaluated ( ..) )
408
- }
409
-
410
- fn can_skip_operand ( o : & Operand < ' _ > ) -> bool {
411
- match o {
412
- Operand :: Copy ( _) | Operand :: Move ( _) => true ,
413
- Operand :: Constant ( c) => can_skip_constant ( c. literal ) ,
414
- }
415
- }
416
-
417
403
if let StatementKind :: Assign ( box ( dest, rvalue) ) = & stmt. kind {
418
404
if !dest. is_indirect ( ) && dest. local == * local {
419
405
let can_skip = match rvalue {
420
- Rvalue :: Use ( op) => can_skip_operand ( op) ,
421
- Rvalue :: Discriminant ( _) => true ,
422
- Rvalue :: BinaryOp ( _, l, r) | Rvalue :: CheckedBinaryOp ( _, l, r) => {
423
- can_skip_operand ( l) && can_skip_operand ( r)
424
- }
425
- Rvalue :: Repeat ( op, c) => can_skip_operand ( op) && can_skip_constant ( c) ,
426
- Rvalue :: AddressOf ( _, _) => true ,
427
- Rvalue :: Len ( _) => true ,
428
- Rvalue :: UnaryOp ( _, op) => can_skip_operand ( op) ,
429
- Rvalue :: Aggregate ( _, operands) => operands. iter ( ) . all ( can_skip_operand) ,
406
+ Rvalue :: Use ( _)
407
+ | Rvalue :: Discriminant ( _)
408
+ | Rvalue :: BinaryOp ( _, _, _)
409
+ | Rvalue :: CheckedBinaryOp ( _, _, _)
410
+ | Rvalue :: Repeat ( _, _)
411
+ | Rvalue :: AddressOf ( _, _)
412
+ | Rvalue :: Len ( _)
413
+ | Rvalue :: UnaryOp ( _, _)
414
+ | Rvalue :: Aggregate ( _, _) => true ,
430
415
431
416
_ => false ,
432
417
} ;
0 commit comments