Skip to content

Stabilize clone #20070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn weak_count<T>(this: &Arc<T>) -> uint { this.inner().weak.load(atomic::Seq
#[experimental]
pub fn strong_count<T>(this: &Arc<T>) -> uint { this.inner().strong.load(atomic::SeqCst) }

#[unstable = "waiting on stability of Clone"]
#[stable]
impl<T> Clone for Arc<T> {
/// Duplicate an atomically reference counted wrapper.
///
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<T> Default for Box<[T]> {
fn default() -> Box<[T]> { box [] }
}

#[unstable]
#[stable]
impl<T: Clone> Clone for Box<T> {
/// Returns a copy of the owned box.
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<T> Drop for Rc<T> {
}
}

#[unstable = "Clone is unstable."]
#[stable]
impl<T> Clone for Rc<T> {
/// Makes a clone of the `Rc<T>`.
///
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ impl Extend<bool> for Bitv {
}
}

#[stable]
impl Clone for Bitv {
#[inline]
fn clone(&self) -> Bitv {
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ impl<K, V> Node<K, V> {
}

// FIXME(gereeter) Write an efficient clone_from
#[stable]
impl<K: Clone, V: Clone> Clone for Node<K, V> {
fn clone(&self) -> Node<K, V> {
let mut ret = if self.is_leaf() {
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ impl<A: Ord> Ord for DList<A> {
}
}

#[stable]
impl<A: Clone> Clone for DList<A> {
fn clone(&self) -> DList<A> {
self.iter().map(|x| x.clone()).collect()
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/ring_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct RingBuf<T> {
ptr: *mut T
}

#[stable]
impl<T: Clone> Clone for RingBuf<T> {
fn clone(&self) -> RingBuf<T> {
self.iter().map(|t| t.clone()).collect()
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl<T: Clone> Vec<T> {
}
}

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

Expand Down
3 changes: 1 addition & 2 deletions src/libcore/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use option::Option;
macro_rules! array_impls {
($($N:expr)+) => {
$(
#[unstable = "waiting for Clone to stabilize"]
#[stable]
impl<T:Copy> Clone for [T, ..$N] {
fn clone(&self) -> [T, ..$N] {
*self
Expand Down Expand Up @@ -115,4 +115,3 @@ array_impls! {
20 21 22 23 24 25 26 27 28 29
30 31 32
}

1 change: 1 addition & 0 deletions src/libcore/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub enum Cow<'a, T, Sized? B: 'a> where B: ToOwned<T> {
Owned(T)
}

#[stable]
impl<'a, T, Sized? B> Clone for Cow<'a, T, B> where B: ToOwned<T> {
fn clone(&self) -> Cow<'a, T, B> {
match *self {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<T:Copy> Cell<T> {
}
}

#[unstable = "waiting for `Clone` trait to become stable"]
#[stable]
impl<T:Copy> Clone for Cell<T> {
fn clone(&self) -> Cell<T> {
Cell::new(self.get())
Expand Down Expand Up @@ -341,7 +341,7 @@ impl<T> RefCell<T> {
}
}

#[unstable = "waiting for `Clone` to become stable"]
#[stable]
impl<T: Clone> Clone for RefCell<T> {
fn clone(&self) -> RefCell<T> {
RefCell::new(self.borrow().clone())
Expand Down
9 changes: 6 additions & 3 deletions src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
//! explicitly, by convention implementing the `Clone` trait and calling
//! the `clone` method.

#![unstable]
#![stable]

use kinds::Sized;

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

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

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

macro_rules! clone_impl {
($t:ty) => {
#[stable]
impl Clone for $t {
/// Return a deep copy of the value.
#[inline]
Expand Down Expand Up @@ -95,4 +99,3 @@ extern_fn_clone! { A, B, C, D, E }
extern_fn_clone! { A, B, C, D, E, F }
extern_fn_clone! { A, B, C, D, E, F, G }
extern_fn_clone! { A, B, C, D, E, F, G, H }

1 change: 1 addition & 0 deletions src/libcore/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ impl Writer for SipState {
}
}

#[stable]
impl Clone for SipState {
#[inline]
fn clone(&self) -> SipState {
Expand Down
9 changes: 9 additions & 0 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ pub struct Map<A, B, I: Iterator<A>, F: FnMut(A) -> B> {
}

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

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

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

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

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

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

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

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

// FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
#[stable]
impl<A, St, F> Clone for Unfold<A, St, F> where
F: Clone + FnMut(&mut St) -> Option<A>,
St: Clone,
Expand Down
1 change: 1 addition & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ impl<'a, A> DoubleEndedIterator<&'a A> for Iter<'a, A> {

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

#[stable]
impl<'a, A> Clone for Iter<'a, A> {
fn clone(&self) -> Iter<'a, A> {
Iter { inner: self.inner.clone() }
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,15 @@ impl<T> Equiv<*const T> for *mut T {
}
}

#[stable]
impl<T> Clone for *const T {
#[inline]
fn clone(&self) -> *const T {
*self
}
}

#[stable]
impl<T> Clone for *mut T {
#[inline]
fn clone(&self) -> *mut T {
Expand Down Expand Up @@ -451,4 +453,3 @@ impl<T> PartialOrd for *mut T {
#[inline]
fn ge(&self, other: &*mut T) -> bool { *self >= *other }
}

4 changes: 2 additions & 2 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ iterator!{struct Items -> *const T, &'a T}
#[experimental = "needs review"]
impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}

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

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

3 changes: 1 addition & 2 deletions src/libcore/tuple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ macro_rules! tuple_impls {
)+
}

#[unstable = "waiting for Clone to stabilize"]
#[stable]
impl<$($T:Clone),+> Clone for ($($T,)+) {
fn clone(&self) -> ($($T,)+) {
($(e!(self.$idx.clone()),)+)
Expand Down Expand Up @@ -328,4 +328,3 @@ tuple_impls! {
(val11, ref11, mut11, 11) -> L
}
}

4 changes: 2 additions & 2 deletions src/libstd/comm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ impl<T: Send> Sender<T> {
}
}

#[unstable]
#[stable]
impl<T: Send> Clone for Sender<T> {
fn clone(&self) -> Sender<T> {
let (packet, sleeper, guard) = match *unsafe { self.inner() } {
Expand Down Expand Up @@ -756,7 +756,7 @@ impl<T: Send> SyncSender<T> {
}
}

#[unstable]
#[stable]
impl<T: Send> Clone for SyncSender<T> {
fn clone(&self) -> SyncSender<T> {
unsafe { (*self.inner.get()).clone_chan(); }
Expand Down
1 change: 1 addition & 0 deletions src/libstd/io/comm_adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl ChanWriter {
}
}

#[stable]
impl Clone for ChanWriter {
fn clone(&self) -> ChanWriter {
ChanWriter { tx: self.tx.clone() }
Expand Down