about summary refs log tree commit diff
path: root/src/libcore/array.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-12-07 02:16:13 +0000
committerbors <bors@rust-lang.org>2015-12-07 02:16:13 +0000
commite819d8aa3cd2319fa57e7336e167069ef7002d6a (patch)
tree75670a56bca0942333b80fa08f6dbe1b5ba06c3f /src/libcore/array.rs
parent64c21f9ee2c6a7e6a530d4bb889676c296e1fe68 (diff)
parent0ca2a9e71a9d907b79c3ca296163d313dc3234eb (diff)
downloadrust-e819d8aa3cd2319fa57e7336e167069ef7002d6a.tar.gz
rust-e819d8aa3cd2319fa57e7336e167069ef7002d6a.zip
Auto merge of #30247 - bluss:revert-array-clone, r=alexcrichton
Revert "PR #30130 Implement `Clone` for more arrays"

This reverts commit e22a64e8d8d4da46c74f878ce1c23ad1c88982e8.

This caused a regression such that types like `[[u8; 256]; 4]`
no longer implemented Clone. This previously worked due to Clone
for `[T; N]` (N in 0 to 32) being implemented for T: Copy.

Due to fixed size arrays not implementing Clone for sizes above 32,
the new implementation requiring T: Clone would not allow
`[[u8; 256]; 4]` to be Clone.

Fixes #30244

Due to changing back, this is technically a [breaking-change],
albeit for a behavior that existed for a very short time.
Diffstat (limited to 'src/libcore/array.rs')
-rw-r--r--src/libcore/array.rs36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs
index 613ed0d14ee..0c5eada2165 100644
--- a/src/libcore/array.rs
+++ b/src/libcore/array.rs
@@ -27,7 +27,7 @@ use default::Default;
 use fmt;
 use hash::{Hash, self};
 use iter::IntoIterator;
-use marker::{Sized, Unsize};
+use marker::{Copy, Sized, Unsize};
 use option::Option;
 use slice::{Iter, IterMut, SliceExt};
 
@@ -127,6 +127,13 @@ macro_rules! array_impls {
             }
 
             #[stable(feature = "rust1", since = "1.0.0")]
+            impl<T:Copy> Clone for [T; $N] {
+                fn clone(&self) -> [T; $N] {
+                    *self
+                }
+            }
+
+            #[stable(feature = "rust1", since = "1.0.0")]
             impl<T: Hash> Hash for [T; $N] {
                 fn hash<H: hash::Hasher>(&self, state: &mut H) {
                     Hash::hash(&self[..], state)
@@ -235,30 +242,3 @@ macro_rules! array_impl_default {
 }
 
 array_impl_default!{32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T}
-
-macro_rules! array_impl_clone {
-    {$n:expr, $i:expr, $($idx:expr,)*} => {
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl<T: Clone> Clone for [T; $n] {
-            fn clone(&self) -> [T; $n] {
-                [self[$i-$i].clone(), $(self[$i-$idx].clone()),*]
-            }
-        }
-        array_impl_clone!{$i, $($idx,)*}
-    };
-    {$n:expr,} => {
-        #[stable(feature = "rust1", since = "1.0.0")]
-        impl<T: Clone> Clone for [T; 0] {
-            fn clone(&self) -> [T; 0] {
-                []
-            }
-        }
-    };
-}
-
-array_impl_clone! {
-                                32, 31, 30,
-    29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
-    19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
-     9,  8,  7,  6,  5,  4,  3,  2,  1,  0,
-}