@@ -501,8 +501,8 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
501
501
BinOpKind :: Mul => l. checked_mul ( r) . map ( zext) ,
502
502
BinOpKind :: Div if r != 0 => l. checked_div ( r) . map ( zext) ,
503
503
BinOpKind :: Rem if r != 0 => l. checked_rem ( r) . map ( zext) ,
504
- BinOpKind :: Shr => l. checked_shr ( r. try_into ( ) . expect ( "invalid shift" ) ) . map ( zext) ,
505
- BinOpKind :: Shl => l. checked_shl ( r. try_into ( ) . expect ( "invalid shift" ) ) . map ( zext) ,
504
+ BinOpKind :: Shr => l. checked_shr ( r. try_into ( ) . ok ( ) ? ) . map ( zext) ,
505
+ BinOpKind :: Shl => l. checked_shl ( r. try_into ( ) . ok ( ) ? ) . map ( zext) ,
506
506
BinOpKind :: BitXor => Some ( zext ( l ^ r) ) ,
507
507
BinOpKind :: BitOr => Some ( zext ( l | r) ) ,
508
508
BinOpKind :: BitAnd => Some ( zext ( l & r) ) ,
@@ -521,8 +521,8 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
521
521
BinOpKind :: Mul => l. checked_mul ( r) . map ( Constant :: Int ) ,
522
522
BinOpKind :: Div => l. checked_div ( r) . map ( Constant :: Int ) ,
523
523
BinOpKind :: Rem => l. checked_rem ( r) . map ( Constant :: Int ) ,
524
- BinOpKind :: Shr => l. checked_shr ( r. try_into ( ) . expect ( "shift too large" ) ) . map ( Constant :: Int ) ,
525
- BinOpKind :: Shl => l. checked_shl ( r. try_into ( ) . expect ( "shift too large" ) ) . map ( Constant :: Int ) ,
524
+ BinOpKind :: Shr => l. checked_shr ( r. try_into ( ) . ok ( ) ? ) . map ( Constant :: Int ) ,
525
+ BinOpKind :: Shl => l. checked_shl ( r. try_into ( ) . ok ( ) ? ) . map ( Constant :: Int ) ,
526
526
BinOpKind :: BitXor => Some ( Constant :: Int ( l ^ r) ) ,
527
527
BinOpKind :: BitOr => Some ( Constant :: Int ( l | r) ) ,
528
528
BinOpKind :: BitAnd => Some ( Constant :: Int ( l & r) ) ,
0 commit comments