@@ -1004,14 +1004,6 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
1004
1004
let expected = ScalarMaybeUninit :: from ( Scalar :: from_bool ( * expected) ) ;
1005
1005
let value_const = self . ecx . read_scalar ( value) . unwrap ( ) ;
1006
1006
if expected != value_const {
1007
- // Poison all places this operand references so that further code
1008
- // doesn't use the invalid value
1009
- match cond {
1010
- Operand :: Move ( ref place) | Operand :: Copy ( ref place) => {
1011
- Self :: remove_const ( & mut self . ecx , place. local ) ;
1012
- }
1013
- Operand :: Constant ( _) => { }
1014
- }
1015
1007
let mut eval_to_int = |op| {
1016
1008
let op = self
1017
1009
. eval_operand ( op, source_info)
@@ -1020,27 +1012,37 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
1020
1012
} ;
1021
1013
let msg = match msg {
1022
1014
AssertKind :: DivisionByZero ( op) => {
1023
- AssertKind :: DivisionByZero ( eval_to_int ( op) )
1015
+ Some ( AssertKind :: DivisionByZero ( eval_to_int ( op) ) )
1024
1016
}
1025
1017
AssertKind :: RemainderByZero ( op) => {
1026
- AssertKind :: RemainderByZero ( eval_to_int ( op) )
1018
+ Some ( AssertKind :: RemainderByZero ( eval_to_int ( op) ) )
1027
1019
}
1028
1020
AssertKind :: BoundsCheck { ref len, ref index } => {
1029
1021
let len = eval_to_int ( len) ;
1030
1022
let index = eval_to_int ( index) ;
1031
- AssertKind :: BoundsCheck { len, index }
1023
+ Some ( AssertKind :: BoundsCheck { len, index } )
1032
1024
}
1033
1025
// Overflow is are already covered by checks on the binary operators.
1034
- AssertKind :: Overflow ( ..) | AssertKind :: OverflowNeg ( _) => return ,
1026
+ AssertKind :: Overflow ( ..) | AssertKind :: OverflowNeg ( _) => None ,
1035
1027
// Need proper const propagator for these.
1036
- _ => return ,
1028
+ _ => None ,
1037
1029
} ;
1038
- self . report_assert_as_lint (
1039
- lint:: builtin:: UNCONDITIONAL_PANIC ,
1040
- source_info,
1041
- "this operation will panic at runtime" ,
1042
- msg,
1043
- ) ;
1030
+ // Poison all places this operand references so that further code
1031
+ // doesn't use the invalid value
1032
+ match cond {
1033
+ Operand :: Move ( ref place) | Operand :: Copy ( ref place) => {
1034
+ Self :: remove_const ( & mut self . ecx , place. local ) ;
1035
+ }
1036
+ Operand :: Constant ( _) => { }
1037
+ }
1038
+ if let Some ( msg) = msg {
1039
+ self . report_assert_as_lint (
1040
+ lint:: builtin:: UNCONDITIONAL_PANIC ,
1041
+ source_info,
1042
+ "this operation will panic at runtime" ,
1043
+ msg,
1044
+ ) ;
1045
+ }
1044
1046
} else {
1045
1047
if self . should_const_prop ( value) {
1046
1048
if let ScalarMaybeUninit :: Scalar ( scalar) = value_const {
0 commit comments