From 9e3d0b002a5c2e81d43351c9b8550a3f4ccfb8f9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 21 Apr 2014 17:58:52 -0400 Subject: librustc: Remove the fallback to `int` from typechecking. This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change] --- src/liballoc/arc.rs | 2 +- src/liballoc/rc.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/liballoc') diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 94bf3368a0a..cccd5cb63ef 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -39,7 +39,7 @@ use heap::deallocate; /// let numbers = Vec::from_fn(100, |i| i as f32); /// let shared_numbers = Arc::new(numbers); /// -/// for _ in range(0, 10) { +/// for _ in range(0u, 10) { /// let child_numbers = shared_numbers.clone(); /// /// spawn(proc() { diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index db6af30bce7..c6e81fa7f7c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -276,7 +276,7 @@ mod tests { #[test] fn test_clone() { - let x = Rc::new(RefCell::new(5)); + let x = Rc::new(RefCell::new(5i)); let y = x.clone(); *x.borrow_mut() = 20; assert_eq!(*y.borrow(), 20); @@ -284,13 +284,13 @@ mod tests { #[test] fn test_simple() { - let x = Rc::new(5); + let x = Rc::new(5i); assert_eq!(*x, 5); } #[test] fn test_simple_clone() { - let x = Rc::new(5); + let x = Rc::new(5i); let y = x.clone(); assert_eq!(*x, 5); assert_eq!(*y, 5); @@ -298,20 +298,20 @@ mod tests { #[test] fn test_destructor() { - let x = Rc::new(box 5); + let x = Rc::new(box 5i); assert_eq!(**x, 5); } #[test] fn test_live() { - let x = Rc::new(5); + let x = Rc::new(5i); let y = x.downgrade(); assert!(y.upgrade().is_some()); } #[test] fn test_dead() { - let x = Rc::new(5); + let x = Rc::new(5i); let y = x.downgrade(); drop(x); assert!(y.upgrade().is_none()); @@ -321,7 +321,7 @@ mod tests { fn gc_inside() { // see issue #11532 use std::gc::GC; - let a = Rc::new(RefCell::new(box(GC) 1)); + let a = Rc::new(RefCell::new(box(GC) 1i)); assert!(a.try_borrow_mut().is_some()); } -- cgit 1.4.1-3-g733a5 From adbd5d7a421e50b1ff4c1d8f1f43a9fd5fb977a3 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 23 Jun 2014 16:34:29 -0700 Subject: core: Add stability attributes to Clone The following are tagged 'unstable' - core::clone - Clone - Clone::clone - impl Clone for Arc - impl Clone for arc::Weak - impl Clone for Rc - impl Clone for rc::Weak - impl Clone for Vec - impl Clone for Cell - impl Clone for RefCell - impl Clone for small tuples The following are tagged 'experimental' - Clone::clone_from - may not provide enough utility - impls for various extern "Rust" fns - may not handle lifetimes correctly See https://github.com/rust-lang/rust/wiki/Meeting-API-review-2014-06-23#clone --- src/liballoc/arc.rs | 2 ++ src/liballoc/owned.rs | 1 + src/liballoc/rc.rs | 2 ++ src/libcollections/vec.rs | 1 + src/libcore/cell.rs | 2 ++ src/libcore/clone.rs | 4 ++++ src/libcore/tuple.rs | 1 + src/libstd/gc.rs | 1 + 8 files changed, 14 insertions(+) (limited to 'src/liballoc') diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index cccd5cb63ef..6af4083edb2 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -110,6 +110,7 @@ impl Arc { } } +#[unstable] impl Clone for Arc { /// Duplicate an atomically reference counted wrapper. /// @@ -236,6 +237,7 @@ impl Weak { } } +#[unstable] impl Clone for Weak { #[inline] fn clone(&self) -> Weak { diff --git a/src/liballoc/owned.rs b/src/liballoc/owned.rs index fa7a8df5035..6f5d3293556 100644 --- a/src/liballoc/owned.rs +++ b/src/liballoc/owned.rs @@ -42,6 +42,7 @@ impl Default for Box { fn default() -> Box { box Default::default() } } +#[unstable] impl Clone for Box { /// Return a copy of the owned box. #[inline] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index c6e81fa7f7c..a3ca72f1547 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -143,6 +143,7 @@ impl Drop for Rc { } } +#[unstable] impl Clone for Rc { #[inline] fn clone(&self) -> Rc { @@ -224,6 +225,7 @@ impl Drop for Weak { } } +#[unstable] impl Clone for Weak { #[inline] fn clone(&self) -> Weak { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index e3ed3ffbabf..0ee0c5b87ae 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -316,6 +316,7 @@ impl Vec { } } +#[unstable] impl Clone for Vec { fn clone(&self) -> Vec { let len = self.len; diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index fd694c04f55..ab701b76026 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -192,6 +192,7 @@ impl Cell { } } +#[unstable] impl Clone for Cell { fn clone(&self) -> Cell { Cell::new(self.get()) @@ -298,6 +299,7 @@ impl RefCell { } } +#[unstable] impl Clone for RefCell { fn clone(&self) -> RefCell { RefCell::new(self.borrow().clone()) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 4fb887bad94..04f01db3147 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -21,6 +21,8 @@ the `clone` method. */ +#![unstable] + /// A common trait for cloning an object. pub trait Clone { /// Returns a copy of the value. The contents of owned pointers @@ -34,6 +36,7 @@ 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"] fn clone_from(&mut self, source: &Self) { *self = source.clone() } @@ -88,6 +91,7 @@ clone_impl!(char) macro_rules! extern_fn_clone( ($($A:ident),*) => ( + #[experimental = "this may not be sufficient for fns with region parameters"] impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType { /// Return a copy of a function pointer #[inline] diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 18511474ecf..3508da5d516 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -104,6 +104,7 @@ macro_rules! tuple_impls { )+ } + #[unstable] impl<$($T:Clone),+> Clone for ($($T,)+) { fn clone(&self) -> ($($T,)+) { ($(self.$refN().clone(),)+) diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index e889752f4fc..0f30e7231b1 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -37,6 +37,7 @@ pub struct Gc { marker: marker::NoSend, } +#[unstable] impl Clone for Gc { /// Clone the pointer only #[inline] -- cgit 1.4.1-3-g733a5