Skip to content

Commit f733bbe

Browse files
y21guilliamxavier
andauthored
Check if RHS in shift is negative
Co-authored-by: Guilliam Xavier <[email protected]>
1 parent f5eaa77 commit f733bbe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_utils/src/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
654654
BinOpKind::Rem if r != 0 => l.checked_rem(r).map(zext),
655655
// Using << or >> where the right-hand argument is greater than or equal to the number of bits
656656
// in the type of the left-hand argument, or is negative panicks.
657-
BinOpKind::Shr if r < bits && !l.is_negative() => l.checked_shr(r.try_into().ok()?).map(zext),
658-
BinOpKind::Shl if r < bits && !l.is_negative() => l.checked_shl(r.try_into().ok()?).map(zext),
657+
BinOpKind::Shr if r < bits && !r.is_negative() => l.checked_shr(r.try_into().ok()?).map(zext),
658+
BinOpKind::Shl if r < bits && !r.is_negative() => l.checked_shl(r.try_into().ok()?).map(zext),
659659
BinOpKind::BitXor => Some(zext(l ^ r)),
660660
BinOpKind::BitOr => Some(zext(l | r)),
661661
BinOpKind::BitAnd => Some(zext(l & r)),

0 commit comments

Comments
 (0)