Skip to content

Commit 1dc5e63

Browse files
committed
rollup merge of rust-lang#20070: aturon/stab-2-clone
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`. r? @alexcrichton
2 parents 6495c27 + 92ccc07 commit 1dc5e63

File tree

20 files changed

+37
-18
lines changed

20 files changed

+37
-18
lines changed

src/liballoc/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub fn weak_count<T>(this: &Arc<T>) -> uint { this.inner().weak.load(atomic::Seq
197197
#[experimental]
198198
pub fn strong_count<T>(this: &Arc<T>) -> uint { this.inner().strong.load(atomic::SeqCst) }
199199

200-
#[unstable = "waiting on stability of Clone"]
200+
#[stable]
201201
impl<T> Clone for Arc<T> {
202202
/// Makes a clone of the `Arc<T>`.
203203
///

src/liballoc/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<T> Default for Box<[T]> {
5858
fn default() -> Box<[T]> { box [] }
5959
}
6060

61-
#[unstable]
61+
#[stable]
6262
impl<T: Clone> Clone for Box<T> {
6363
/// Returns a copy of the owned box.
6464
#[inline]

src/liballoc/rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<T> Drop for Rc<T> {
410410
}
411411
}
412412

413-
#[unstable = "Clone is unstable."]
413+
#[stable]
414414
impl<T> Clone for Rc<T> {
415415
/// Makes a clone of the `Rc<T>`.
416416
///

src/libcollections/bit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ impl Extend<bool> for Bitv {
851851
}
852852
}
853853

854+
#[stable]
854855
impl Clone for Bitv {
855856
#[inline]
856857
fn clone(&self) -> Bitv {

src/libcollections/btree/node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ impl<K, V> Node<K, V> {
390390
}
391391

392392
// FIXME(gereeter) Write an efficient clone_from
393+
#[stable]
393394
impl<K: Clone, V: Clone> Clone for Node<K, V> {
394395
fn clone(&self) -> Node<K, V> {
395396
let mut ret = if self.is_leaf() {

src/libcollections/dlist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ impl<A: Ord> Ord for DList<A> {
758758
}
759759
}
760760

761+
#[stable]
761762
impl<A: Clone> Clone for DList<A> {
762763
fn clone(&self) -> DList<A> {
763764
self.iter().map(|x| x.clone()).collect()

src/libcollections/ring_buf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub struct RingBuf<T> {
4848
ptr: *mut T
4949
}
5050

51+
#[stable]
5152
impl<T: Clone> Clone for RingBuf<T> {
5253
fn clone(&self) -> RingBuf<T> {
5354
self.iter().map(|t| t.clone()).collect()

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<T: Clone> Vec<T> {
469469
}
470470
}
471471

472-
#[unstable]
472+
#[stable]
473473
impl<T:Clone> Clone for Vec<T> {
474474
fn clone(&self) -> Vec<T> { self.as_slice().to_vec() }
475475

src/libcore/array.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use option::Option;
2525
macro_rules! array_impls {
2626
($($N:expr)+) => {
2727
$(
28-
#[unstable = "waiting for Clone to stabilize"]
28+
#[stable]
2929
impl<T:Copy> Clone for [T, ..$N] {
3030
fn clone(&self) -> [T, ..$N] {
3131
*self
@@ -115,4 +115,3 @@ array_impls! {
115115
20 21 22 23 24 25 26 27 28 29
116116
30 31 32
117117
}
118-

src/libcore/borrow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pub enum Cow<'a, T, Sized? B: 'a> where B: ToOwned<T> {
137137
Owned(T)
138138
}
139139

140+
#[stable]
140141
impl<'a, T, Sized? B> Clone for Cow<'a, T, B> where B: ToOwned<T> {
141142
fn clone(&self) -> Cow<'a, T, B> {
142143
match *self {

src/libcore/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<T:Copy> Cell<T> {
208208
}
209209
}
210210

211-
#[unstable = "waiting for `Clone` trait to become stable"]
211+
#[stable]
212212
impl<T:Copy> Clone for Cell<T> {
213213
fn clone(&self) -> Cell<T> {
214214
Cell::new(self.get())
@@ -341,7 +341,7 @@ impl<T> RefCell<T> {
341341
}
342342
}
343343

344-
#[unstable = "waiting for `Clone` to become stable"]
344+
#[stable]
345345
impl<T: Clone> Clone for RefCell<T> {
346346
fn clone(&self) -> RefCell<T> {
347347
RefCell::new(self.borrow().clone())

src/libcore/clone.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
//! explicitly, by convention implementing the `Clone` trait and calling
2020
//! the `clone` method.
2121
22-
#![unstable]
22+
#![stable]
2323

2424
use kinds::Sized;
2525

2626
/// A common trait for cloning an object.
27+
#[stable]
2728
pub trait Clone {
2829
/// Returns a copy of the value.
30+
#[stable]
2931
fn clone(&self) -> Self;
3032

3133
/// Perform copy-assignment from `source`.
@@ -34,12 +36,13 @@ pub trait Clone {
3436
/// but can be overridden to reuse the resources of `a` to avoid unnecessary
3537
/// allocations.
3638
#[inline(always)]
37-
#[experimental = "this function is mostly unused"]
39+
#[unstable = "this function rarely unused"]
3840
fn clone_from(&mut self, source: &Self) {
3941
*self = source.clone()
4042
}
4143
}
4244

45+
#[stable]
4346
impl<'a, Sized? T> Clone for &'a T {
4447
/// Return a shallow copy of the reference.
4548
#[inline]
@@ -48,6 +51,7 @@ impl<'a, Sized? T> Clone for &'a T {
4851

4952
macro_rules! clone_impl {
5053
($t:ty) => {
54+
#[stable]
5155
impl Clone for $t {
5256
/// Return a deep copy of the value.
5357
#[inline]
@@ -95,4 +99,3 @@ extern_fn_clone! { A, B, C, D, E }
9599
extern_fn_clone! { A, B, C, D, E, F }
96100
extern_fn_clone! { A, B, C, D, E, F, G }
97101
extern_fn_clone! { A, B, C, D, E, F, G, H }
98-

src/libcore/hash/sip.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ impl Writer for SipState {
195195
}
196196
}
197197

198+
#[stable]
198199
impl Clone for SipState {
199200
#[inline]
200201
fn clone(&self) -> SipState {

src/libcore/iter.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,7 @@ pub struct Map<A, B, I: Iterator<A>, F: FnMut(A) -> B> {
13861386
}
13871387

13881388
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1389+
#[stable]
13891390
impl<A, B, I, F> Clone for Map<A, B, I, F> where
13901391
I: Clone + Iterator<A>,
13911392
F: Clone + FnMut(A) -> B,
@@ -1460,6 +1461,7 @@ pub struct Filter<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
14601461
}
14611462

14621463
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1464+
#[stable]
14631465
impl<A, I, P> Clone for Filter<A, I, P> where
14641466
I: Clone + Iterator<A>,
14651467
P: Clone + FnMut(&A) -> bool,
@@ -1518,6 +1520,7 @@ pub struct FilterMap<A, B, I, F> where I: Iterator<A>, F: FnMut(A) -> Option<B>
15181520
}
15191521

15201522
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1523+
#[stable]
15211524
impl<A, B, I, F> Clone for FilterMap<A, B, I, F> where
15221525
I: Clone + Iterator<A>,
15231526
F: Clone + FnMut(A) -> Option<B>,
@@ -1693,6 +1696,7 @@ pub struct SkipWhile<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
16931696
}
16941697

16951698
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1699+
#[stable]
16961700
impl<A, I, P> Clone for SkipWhile<A, I, P> where
16971701
I: Clone + Iterator<A>,
16981702
P: Clone + FnMut(&A) -> bool,
@@ -1736,6 +1740,7 @@ pub struct TakeWhile<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
17361740
}
17371741

17381742
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1743+
#[stable]
17391744
impl<A, I, P> Clone for TakeWhile<A, I, P> where
17401745
I: Clone + Iterator<A>,
17411746
P: Clone + FnMut(&A) -> bool,
@@ -1911,6 +1916,7 @@ pub struct Scan<A, B, I, St, F> where I: Iterator<A>, F: FnMut(&mut St, A) -> Op
19111916
}
19121917

19131918
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1919+
#[stable]
19141920
impl<A, B, I, St, F> Clone for Scan<A, B, I, St, F> where
19151921
I: Clone + Iterator<A>,
19161922
St: Clone,
@@ -1955,6 +1961,7 @@ pub struct FlatMap<A, B, I, U, F> where I: Iterator<A>, U: Iterator<B>, F: FnMut
19551961
}
19561962

19571963
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
1964+
#[stable]
19581965
impl<A, B, I, U, F> Clone for FlatMap<A, B, I, U, F> where
19591966
I: Clone + Iterator<A>,
19601967
U: Clone + Iterator<B>,
@@ -2115,6 +2122,7 @@ pub struct Inspect<A, I, F> where I: Iterator<A>, F: FnMut(&A) {
21152122
}
21162123

21172124
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
2125+
#[stable]
21182126
impl<A, I, F> Clone for Inspect<A, I, F> where
21192127
I: Clone + Iterator<A>,
21202128
F: Clone + FnMut(&A),
@@ -2222,6 +2230,7 @@ pub struct Unfold<A, St, F> where F: FnMut(&mut St) -> Option<A> {
22222230
}
22232231

22242232
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
2233+
#[stable]
22252234
impl<A, St, F> Clone for Unfold<A, St, F> where
22262235
F: Clone + FnMut(&mut St) -> Option<A>,
22272236
St: Clone,

src/libcore/option.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ impl<'a, A> DoubleEndedIterator<&'a A> for Iter<'a, A> {
819819

820820
impl<'a, A> ExactSizeIterator<&'a A> for Iter<'a, A> {}
821821

822+
#[stable]
822823
impl<'a, A> Clone for Iter<'a, A> {
823824
fn clone(&self) -> Iter<'a, A> {
824825
Iter { inner: self.inner.clone() }

src/libcore/ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,15 @@ impl<T> Equiv<*const T> for *mut T {
388388
}
389389
}
390390

391+
#[stable]
391392
impl<T> Clone for *const T {
392393
#[inline]
393394
fn clone(&self) -> *const T {
394395
*self
395396
}
396397
}
397398

399+
#[stable]
398400
impl<T> Clone for *mut T {
399401
#[inline]
400402
fn clone(&self) -> *mut T {
@@ -499,4 +501,3 @@ impl<T> PartialOrd for *mut T {
499501
#[inline]
500502
fn ge(&self, other: &*mut T) -> bool { *self >= *other }
501503
}
502-

src/libcore/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ iterator!{struct Items -> *const T, &'a T}
781781
#[experimental = "needs review"]
782782
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
783783

784-
#[experimental = "needs review"]
784+
#[stable]
785785
impl<'a, T> Clone for Items<'a, T> {
786786
fn clone(&self) -> Items<'a, T> { *self }
787787
}
@@ -893,6 +893,7 @@ pub struct Splits<'a, T:'a, P> where P: FnMut(&T) -> bool {
893893
}
894894

895895
// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
896+
#[stable]
896897
impl<'a, T, P> Clone for Splits<'a, T, P> where P: Clone + FnMut(&T) -> bool {
897898
fn clone(&self) -> Splits<'a, T, P> {
898899
Splits {
@@ -1550,4 +1551,3 @@ impl_int_slice! { u16, i16 }
15501551
impl_int_slice! { u32, i32 }
15511552
impl_int_slice! { u64, i64 }
15521553
impl_int_slice! { uint, int }
1553-

src/libcore/tuple.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ macro_rules! tuple_impls {
124124
)+
125125
}
126126

127-
#[unstable = "waiting for Clone to stabilize"]
127+
#[stable]
128128
impl<$($T:Clone),+> Clone for ($($T,)+) {
129129
fn clone(&self) -> ($($T,)+) {
130130
($(e!(self.$idx.clone()),)+)
@@ -326,4 +326,3 @@ tuple_impls! {
326326
(val11, ref11, mut11, 11) -> L
327327
}
328328
}
329-

src/libstd/comm/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<T: Send> Sender<T> {
628628
}
629629
}
630630

631-
#[unstable]
631+
#[stable]
632632
impl<T: Send> Clone for Sender<T> {
633633
fn clone(&self) -> Sender<T> {
634634
let (packet, sleeper, guard) = match *unsafe { self.inner() } {
@@ -756,7 +756,7 @@ impl<T: Send> SyncSender<T> {
756756
}
757757
}
758758

759-
#[unstable]
759+
#[stable]
760760
impl<T: Send> Clone for SyncSender<T> {
761761
fn clone(&self) -> SyncSender<T> {
762762
unsafe { (*self.inner.get()).clone_chan(); }

src/libstd/io/comm_adapters.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl ChanWriter {
132132
}
133133
}
134134

135+
#[stable]
135136
impl Clone for ChanWriter {
136137
fn clone(&self) -> ChanWriter {
137138
ChanWriter { tx: self.tx.clone() }

0 commit comments

Comments
 (0)