From: Michael Watzko Date: Sat, 28 Aug 2021 11:28:35 +0000 (+0200) Subject: Use wrapping shift for unsigned types X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=acf0a0c3940e3b1589e93f868c4708f4f8c4f4eb;p=rust.git Use wrapping shift for unsigned types --- 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,