Skip to content

Commit 0a9c463

Browse files
committed
Revert "PR #30130 Implement Clone for more arrays"
This reverts commit e22a64e. 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.
1 parent 64c21f9 commit 0a9c463

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

src/libcore/array.rs

+8-28
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use default::Default;
2727
use fmt;
2828
use hash::{Hash, self};
2929
use iter::IntoIterator;
30-
use marker::{Sized, Unsize};
30+
use marker::{Copy, Sized, Unsize};
3131
use option::Option;
3232
use slice::{Iter, IterMut, SliceExt};
3333

@@ -126,6 +126,13 @@ macro_rules! array_impls {
126126
}
127127
}
128128

129+
#[stable(feature = "rust1", since = "1.0.0")]
130+
impl<T:Copy> Clone for [T; $N] {
131+
fn clone(&self) -> [T; $N] {
132+
*self
133+
}
134+
}
135+
129136
#[stable(feature = "rust1", since = "1.0.0")]
130137
impl<T: Hash> Hash for [T; $N] {
131138
fn hash<H: hash::Hasher>(&self, state: &mut H) {
@@ -235,30 +242,3 @@ macro_rules! array_impl_default {
235242
}
236243

237244
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}
238-
239-
macro_rules! array_impl_clone {
240-
{$n:expr, $i:expr, $($idx:expr,)*} => {
241-
#[stable(feature = "rust1", since = "1.0.0")]
242-
impl<T: Clone> Clone for [T; $n] {
243-
fn clone(&self) -> [T; $n] {
244-
[self[$i-$i].clone(), $(self[$i-$idx].clone()),*]
245-
}
246-
}
247-
array_impl_clone!{$i, $($idx,)*}
248-
};
249-
{$n:expr,} => {
250-
#[stable(feature = "rust1", since = "1.0.0")]
251-
impl<T: Clone> Clone for [T; 0] {
252-
fn clone(&self) -> [T; 0] {
253-
[]
254-
}
255-
}
256-
};
257-
}
258-
259-
array_impl_clone! {
260-
32, 31, 30,
261-
29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
262-
19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
263-
9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
264-
}

0 commit comments

Comments
 (0)