about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicholas Mazzuca <npmazzuca@gmail.com>2016-01-05 22:16:03 -0800
committerNicholas Mazzuca <npmazzuca@gmail.com>2016-01-05 22:16:03 -0800
commit14e1e2aee812978c81d4edf23359e7dca444d678 (patch)
treeb3fcaf4c02e187e91e5d223a73c5a917a39e5dca /src
parentbd58fd8438bd906c8e87b98218a605db84d42c68 (diff)
Fix a breaking change in #30523
While this does fix a breaking change, it is also, technically, a
[breaking-change] to go back to our original way
Diffstat (limited to 'src')
-rw-r--r--src/libcore/num/wrapping.rs30
-rw-r--r--src/librand/isaac.rs12
-rw-r--r--src/test/run-pass/num-wrapping.rs58
3 files changed, 51 insertions, 49 deletions
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs
index 72f0d77f68b..8f9e38bbdf9 100644
--- a/src/libcore/num/wrapping.rs
+++ b/src/libcore/num/wrapping.rs
@@ -42,9 +42,9 @@ macro_rules! sh_impl_signed {
             #[inline(always)]
             fn shl(self, other: $f) -> Wrapping<$t> {
                 if other < 0 {
-                    Wrapping(self.0 >> (-other & self::shift_max::$t as $f))
+                    Wrapping(self.0.wrapping_shr((-other & self::shift_max::$t as $f) as u32))
                 } else {
-                    Wrapping(self.0 << (other & self::shift_max::$t as $f))
+                    Wrapping(self.0.wrapping_shl((other & self::shift_max::$t as $f) as u32))
                 }
             }
         }
@@ -64,9 +64,9 @@ macro_rules! sh_impl_signed {
             #[inline(always)]
             fn shr(self, other: $f) -> Wrapping<$t> {
                 if other < 0 {
-                    Wrapping(self.0 << (-other & self::shift_max::$t as $f))
+                    Wrapping(self.0.wrapping_shl((-other & self::shift_max::$t as $f) as u32))
                 } else {
-                    Wrapping(self.0 >> (other & self::shift_max::$t as $f))
+                    Wrapping(self.0.wrapping_shr((other & self::shift_max::$t as $f) as u32))
                 }
             }
         }
@@ -89,7 +89,7 @@ macro_rules! sh_impl_unsigned {
 
             #[inline(always)]
             fn shl(self, other: $f) -> Wrapping<$t> {
-                Wrapping(self.0 << (other & self::shift_max::$t as $f))
+                Wrapping(self.0.wrapping_shl((other & self::shift_max::$t as $f) as u32))
             }
         }
 
@@ -107,7 +107,7 @@ macro_rules! sh_impl_unsigned {
 
             #[inline(always)]
             fn shr(self, other: $f) -> Wrapping<$t> {
-                Wrapping(self.0 >> (other & self::shift_max::$t as $f))
+                Wrapping(self.0.wrapping_shr((other & self::shift_max::$t as $f) as u32))
             }
         }
 
@@ -124,17 +124,17 @@ macro_rules! sh_impl_unsigned {
 // FIXME (#23545): uncomment the remaining impls
 macro_rules! sh_impl_all {
     ($($t:ident)*) => ($(
-        sh_impl_unsigned! { $t, u8 }
-        sh_impl_unsigned! { $t, u16 }
-        sh_impl_unsigned! { $t, u32 }
-        sh_impl_unsigned! { $t, u64 }
+        //sh_impl_unsigned! { $t, u8 }
+        //sh_impl_unsigned! { $t, u16 }
+        //sh_impl_unsigned! { $t, u32 }
+        //sh_impl_unsigned! { $t, u64 }
         sh_impl_unsigned! { $t, usize }
 
-        sh_impl_signed! { $t, i8 }
-        sh_impl_signed! { $t, i16 }
-        sh_impl_signed! { $t, i32 }
-        sh_impl_signed! { $t, i64 }
-        sh_impl_signed! { $t, isize }
+        //sh_impl_signed! { $t, i8 }
+        //sh_impl_signed! { $t, i16 }
+        //sh_impl_signed! { $t, i32 }
+        //sh_impl_signed! { $t, i64 }
+        //sh_impl_signed! { $t, isize }
     )*)
 }
 
diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs
index 545fd22cc59..28eff87bde3 100644
--- a/src/librand/isaac.rs
+++ b/src/librand/isaac.rs
@@ -170,7 +170,7 @@ impl IsaacRng {
         const MIDPOINT: usize = RAND_SIZE_USIZE / 2;
 
         macro_rules! ind {
-            ($x:expr) => (self.mem[($x >> 2u32).0 as usize & (RAND_SIZE_USIZE - 1)] )
+            ($x:expr) => (self.mem[($x >> 2).0 as usize & (RAND_SIZE_USIZE - 1)] )
         }
 
         let r = [(0, MIDPOINT), (MIDPOINT, 0)];
@@ -452,7 +452,7 @@ impl Isaac64Rng {
         const MP_VEC: [(usize, usize); 2] = [(0, MIDPOINT), (MIDPOINT, 0)];
         macro_rules! ind {
             ($x:expr) => {
-                *self.mem.get_unchecked((($x >> 3u32).0 as usize) & (RAND_SIZE_64 - 1))
+                *self.mem.get_unchecked((($x >> 3).0 as usize) & (RAND_SIZE_64 - 1))
             }
         }
 
@@ -495,10 +495,10 @@ impl Isaac64Rng {
                     }}
                 }
 
-                rngstepp!(0, 21u32);
-                rngstepn!(1, 5u32);
-                rngstepp!(2, 12u32);
-                rngstepn!(3, 33u32);
+                rngstepp!(0, 21);
+                rngstepn!(1, 5);
+                rngstepp!(2, 12);
+                rngstepn!(3, 33);
             }
         }
 
diff --git a/src/test/run-pass/num-wrapping.rs b/src/test/run-pass/num-wrapping.rs
index 228f4cdd1aa..33f7b97ef96 100644
--- a/src/test/run-pass/num-wrapping.rs
+++ b/src/test/run-pass/num-wrapping.rs
@@ -309,22 +309,23 @@ fn test_sh_ops() {
             sh_test!(shl(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2);
         }
     }
-    sh_test_all!(i8);
-    sh_test_all!(u8);
-    sh_test_all!(i16);
-    sh_test_all!(u16);
-    sh_test_all!(i32);
-    sh_test_all!(u32);
-    sh_test_all!(i64);
-    sh_test_all!(u64);
-    sh_test_all!(isize);
+    // FIXME(#23545): Uncomment the remaining tests
+    //sh_test_all!(i8);
+    //sh_test_all!(u8);
+    //sh_test_all!(i16);
+    //sh_test_all!(u16);
+    //sh_test_all!(i32);
+    //sh_test_all!(u32);
+    //sh_test_all!(i64);
+    //sh_test_all!(u64);
+    //sh_test_all!(isize);
     sh_test_all!(usize);
 
-    sh_test_negative_all!(i8);
-    sh_test_negative_all!(i16);
-    sh_test_negative_all!(i32);
-    sh_test_negative_all!(i64);
-    sh_test_negative_all!(isize);
+    //sh_test_negative_all!(i8);
+    //sh_test_negative_all!(i16);
+    //sh_test_negative_all!(i32);
+    //sh_test_negative_all!(i64);
+    //sh_test_negative_all!(isize);
 }
 
 fn test_sh_op_assigns() {
@@ -393,20 +394,21 @@ fn test_sh_op_assigns() {
         }
     }
 
-    sh_assign_test_all!(i8);
-    sh_assign_test_all!(u8);
-    sh_assign_test_all!(i16);
-    sh_assign_test_all!(u16);
-    sh_assign_test_all!(i32);
-    sh_assign_test_all!(u32);
-    sh_assign_test_all!(i64);
-    sh_assign_test_all!(u64);
-    sh_assign_test_all!(isize);
+    // FIXME(#23545): Uncomment the remaining tests
+    //sh_assign_test_all!(i8);
+    //sh_assign_test_all!(u8);
+    //sh_assign_test_all!(i16);
+    //sh_assign_test_all!(u16);
+    //sh_assign_test_all!(i32);
+    //sh_assign_test_all!(u32);
+    //sh_assign_test_all!(i64);
+    //sh_assign_test_all!(u64);
+    //sh_assign_test_all!(isize);
     sh_assign_test_all!(usize);
 
-    sh_assign_test_negative_all!(i8);
-    sh_assign_test_negative_all!(i16);
-    sh_assign_test_negative_all!(i32);
-    sh_assign_test_negative_all!(i64);
-    sh_assign_test_negative_all!(isize);
+    //sh_assign_test_negative_all!(i8);
+    //sh_assign_test_negative_all!(i16);
+    //sh_assign_test_negative_all!(i32);
+    //sh_assign_test_negative_all!(i64);
+    //sh_assign_test_negative_all!(isize);
 }