]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/consts.rs
Merge pull request #3294 from mikerite/fix-3276
[rust.git] / clippy_lints / src / consts.rs
index b84430e6819f61a3b3b6fa34ef6b2e5956cec2b6..5d509ef76f3f2c071ef37fda6d6188ef5017089b 100644 (file)
@@ -230,6 +230,7 @@ pub fn expr(&mut self, e: &Expr) -> Option<Constant> {
         }
     }
 
+    #[allow(clippy::cast_possible_wrap)]
     fn constant_not(&self, o: &Constant, ty: ty::Ty<'_>) -> Option<Constant> {
         use self::Constant::*;
         match *o {
@@ -343,10 +344,10 @@ fn binop(&mut self, op: BinOp, left: &Expr, right: &Expr) -> Option<Constant> {
                             BinOpKind::Div if r != 0 => l.checked_div(r).map(zext),
                             BinOpKind::Rem if r != 0 => l.checked_rem(r).map(zext),
                             BinOpKind::Shr => l.checked_shr(
-                                    (r as u128).try_into().expect("shift too large")
+                                    r.try_into().expect("invalid shift")
                                 ).map(zext),
                             BinOpKind::Shl => l.checked_shl(
-                                    (r as u128).try_into().expect("shift too large")
+                                    r.try_into().expect("invalid shift")
                                 ).map(zext),
                             BinOpKind::BitXor => Some(zext(l ^ r)),
                             BinOpKind::BitOr => Some(zext(l | r)),