@@ -501,8 +501,8 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
501501 BinOpKind :: Mul => l. checked_mul ( r) . map ( zext) ,
502502 BinOpKind :: Div if r != 0 => l. checked_div ( r) . map ( zext) ,
503503 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) ,
506506 BinOpKind :: BitXor => Some ( zext ( l ^ r) ) ,
507507 BinOpKind :: BitOr => Some ( zext ( l | r) ) ,
508508 BinOpKind :: BitAnd => Some ( zext ( l & r) ) ,
@@ -521,8 +521,8 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
521521 BinOpKind :: Mul => l. checked_mul ( r) . map ( Constant :: Int ) ,
522522 BinOpKind :: Div => l. checked_div ( r) . map ( Constant :: Int ) ,
523523 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 ) ,
526526 BinOpKind :: BitXor => Some ( Constant :: Int ( l ^ r) ) ,
527527 BinOpKind :: BitOr => Some ( Constant :: Int ( l | r) ) ,
528528 BinOpKind :: BitAnd => Some ( Constant :: Int ( l & r) ) ,
0 commit comments