From acf0a0c3940e3b1589e93f868c4708f4f8c4f4eb Mon Sep 17 00:00:00 2001 From: Michael Watzko Date: Sat, 28 Aug 2021 13:28:35 +0200 Subject: [PATCH] Use wrapping shift for unsigned types --- library/core/src/num/saturating.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs index 2e84f065713..b2705ca0cc4 100644 --- a/library/core/src/num/saturating.rs +++ b/library/core/src/num/saturating.rs @@ -141,7 +141,7 @@ impl Shl<$f> for Saturating<$t> { #[inline] fn shl(self, other: $f) -> Saturating<$t> { - Saturating(self.0.shl((other & self::shift_max::$t as $f) as u32)) + Saturating(self.0.wrapping_shl(other as u32)) } } forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f, @@ -162,7 +162,7 @@ impl Shr<$f> for Saturating<$t> { #[inline] fn shr(self, other: $f) -> Saturating<$t> { - Saturating(self.0.shr((other & self::shift_max::$t as $f) as u32)) + Saturating(self.0.wrapping_shr(other as u32)) } } forward_ref_binop! { impl Shr, shr for Saturating<$t>, $f, -- 2.44.0