about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Watzko <michael@watzko.de>2021-08-28 13:39:09 +0200
committerMichael Watzko <michael@watzko.de>2021-08-28 13:39:09 +0200
commitce636f25e55493f42e7339cb533cb523879b62a5 (patch)
treeed0f1e4fd620154ea003a10b17c44a92043630f1
parent977ae5ac2c5f0a53c8b0e979bd1b2450d66e1030 (diff)
Unimpl Shl{Assign} for signed Saturating types until the correct impl is clear
-rw-r--r--library/core/src/num/saturating.rs122
1 files changed, 63 insertions, 59 deletions
diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs
index 75d7f24307e..f6dd3603c49 100644
--- a/library/core/src/num/saturating.rs
+++ b/library/core/src/num/saturating.rs
@@ -81,30 +81,32 @@ impl<T: fmt::UpperHex> fmt::UpperHex for Saturating<T> {
 #[allow(unused_macros)]
 macro_rules! sh_impl_signed {
     ($t:ident, $f:ident) => {
-        #[unstable(feature = "saturating_int_impl", issue = "87920")]
-        impl Shl<$f> for Saturating<$t> {
-            type Output = Saturating<$t>;
-
-            #[inline]
-            fn shl(self, other: $f) -> Saturating<$t> {
-                if other < 0 {
-                    Saturating(self.0.shr((-other & self::shift_max::$t as $f) as u32))
-                } else {
-                    Saturating(self.0.shl((other & self::shift_max::$t as $f) as u32))
-                }
-            }
-        }
-        forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f,
-        #[unstable(feature = "saturating_int_impl", issue = "87920")] }
-
-        #[unstable(feature = "saturating_int_impl", issue = "87920")]
-        impl ShlAssign<$f> for Saturating<$t> {
-            #[inline]
-            fn shl_assign(&mut self, other: $f) {
-                *self = *self << other;
-            }
-        }
-        forward_ref_op_assign! { impl ShlAssign, shl_assign for Saturating<$t>, $f }
+        // FIXME what is the correct implementation here? see discussion https://github.com/rust-lang/rust/pull/87921#discussion_r695870065
+        //
+        // #[unstable(feature = "saturating_int_impl", issue = "87920")]
+        // impl Shl<$f> for Saturating<$t> {
+        //     type Output = Saturating<$t>;
+        //
+        //     #[inline]
+        //     fn shl(self, other: $f) -> Saturating<$t> {
+        //         if other < 0 {
+        //             Saturating(self.0.shr((-other & self::shift_max::$t as $f) as u32))
+        //         } else {
+        //             Saturating(self.0.shl((other & self::shift_max::$t as $f) as u32))
+        //         }
+        //     }
+        // }
+        // forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f,
+        // #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+        //
+        // #[unstable(feature = "saturating_int_impl", issue = "87920")]
+        // impl ShlAssign<$f> for Saturating<$t> {
+        //     #[inline]
+        //     fn shl_assign(&mut self, other: $f) {
+        //         *self = *self << other;
+        //     }
+        // }
+        // forward_ref_op_assign! { impl ShlAssign, shl_assign for Saturating<$t>, $f }
 
         #[unstable(feature = "saturating_int_impl", issue = "87920")]
         impl Shr<$f> for Saturating<$t> {
@@ -935,38 +937,40 @@ macro_rules! saturating_int_impl_unsigned {
 
 saturating_int_impl_unsigned! { usize u8 u16 u32 u64 u128 }
 
-mod shift_max {
-    #![allow(non_upper_case_globals)]
-
-    #[cfg(target_pointer_width = "16")]
-    mod platform {
-        pub const usize: u32 = super::u16;
-        pub const isize: u32 = super::i16;
-    }
-
-    #[cfg(target_pointer_width = "32")]
-    mod platform {
-        pub const usize: u32 = super::u32;
-        pub const isize: u32 = super::i32;
-    }
-
-    #[cfg(target_pointer_width = "64")]
-    mod platform {
-        pub const usize: u32 = super::u64;
-        pub const isize: u32 = super::i64;
-    }
-
-    pub const i8: u32 = (1 << 3) - 1;
-    pub const i16: u32 = (1 << 4) - 1;
-    pub const i32: u32 = (1 << 5) - 1;
-    pub const i64: u32 = (1 << 6) - 1;
-    pub const i128: u32 = (1 << 7) - 1;
-    pub use self::platform::isize;
-
-    pub const u8: u32 = i8;
-    pub const u16: u32 = i16;
-    pub const u32: u32 = i32;
-    pub const u64: u32 = i64;
-    pub const u128: u32 = i128;
-    pub use self::platform::usize;
-}
+// Related to potential Shl and ShlAssign implementation
+//
+// mod shift_max {
+//     #![allow(non_upper_case_globals)]
+//
+//     #[cfg(target_pointer_width = "16")]
+//     mod platform {
+//         pub const usize: u32 = super::u16;
+//         pub const isize: u32 = super::i16;
+//     }
+//
+//     #[cfg(target_pointer_width = "32")]
+//     mod platform {
+//         pub const usize: u32 = super::u32;
+//         pub const isize: u32 = super::i32;
+//     }
+//
+//     #[cfg(target_pointer_width = "64")]
+//     mod platform {
+//         pub const usize: u32 = super::u64;
+//         pub const isize: u32 = super::i64;
+//     }
+//
+//     pub const i8: u32 = (1 << 3) - 1;
+//     pub const i16: u32 = (1 << 4) - 1;
+//     pub const i32: u32 = (1 << 5) - 1;
+//     pub const i64: u32 = (1 << 6) - 1;
+//     pub const i128: u32 = (1 << 7) - 1;
+//     pub use self::platform::isize;
+//
+//     pub const u8: u32 = i8;
+//     pub const u16: u32 = i16;
+//     pub const u32: u32 = i32;
+//     pub const u64: u32 = i64;
+//     pub const u128: u32 = i128;
+//     pub use self::platform::usize;
+// }