File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ fn bit_op() {
108
108
check_fail ( r#"const GOAL: i8 = 1 << 8"# , |e| {
109
109
e == ConstEvalError :: MirEvalError ( MirEvalError :: Panic ( "Overflow in Shl" . to_string ( ) ) )
110
110
} ) ;
111
+ check_number ( r#"const GOAL: i32 = 100000000i32 << 11"# , ( 100000000i32 << 11 ) as i128 ) ;
111
112
}
112
113
113
114
#[ test]
Original file line number Diff line number Diff line change @@ -1037,13 +1037,18 @@ impl Evaluator<'_> {
1037
1037
BinOp :: Shr => l128. checked_shr ( shift_amount) ,
1038
1038
_ => unreachable ! ( ) ,
1039
1039
} ;
1040
+ if shift_amount as usize >= lc. len ( ) * 8 {
1041
+ return Err ( MirEvalError :: Panic ( format ! (
1042
+ "Overflow in {op:?}"
1043
+ ) ) ) ;
1044
+ }
1040
1045
if let Some ( r) = r {
1041
1046
break ' b r;
1042
1047
}
1043
1048
} ;
1044
1049
return Err ( MirEvalError :: Panic ( format ! ( "Overflow in {op:?}" ) ) ) ;
1045
1050
} ;
1046
- check_overflow ( r ) ?
1051
+ Owned ( r . to_le_bytes ( ) [ ..lc . len ( ) ] . to_vec ( ) )
1047
1052
}
1048
1053
BinOp :: Offset => not_supported ! ( "offset binop" ) ,
1049
1054
}
You can’t perform that action at this time.
0 commit comments