diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-08-11 17:27:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-08-12 14:55:17 -0700 |
| commit | 8d90d3f36871a00023cc1f313f91e351c287ca15 (patch) | |
| tree | 2d9b616a2468117aa3afe1f6b1f910ff3116776b /src/liballoc | |
| parent | d07d465cf60033e35eba16b9e431471d54c712f4 (diff) | |
| download | rust-8d90d3f36871a00023cc1f313f91e351c287ca15.tar.gz rust-8d90d3f36871a00023cc1f313f91e351c287ca15.zip | |
Remove all unstable deprecated functionality
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 127 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 26 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 134 |
4 files changed, 79 insertions, 210 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index ccf8784e2a7..09a4f9e0a62 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -272,18 +272,6 @@ impl<T: ?Sized> Arc<T> { } } -/// Get the number of weak references to this value. -#[inline] -#[unstable(feature = "arc_counts")] -#[deprecated(since = "1.2.0", reason = "renamed to Arc::weak_count")] -pub fn weak_count<T: ?Sized>(this: &Arc<T>) -> usize { Arc::weak_count(this) } - -/// Get the number of strong references to this value. -#[inline] -#[unstable(feature = "arc_counts")] -#[deprecated(since = "1.2.0", reason = "renamed to Arc::strong_count")] -pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { Arc::strong_count(this) } - #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> Clone for Arc<T> { /// Makes a clone of the `Arc<T>`. @@ -484,13 +472,6 @@ impl<T: ?Sized> Arc<T> { } } -#[inline] -#[unstable(feature = "arc_unique")] -#[deprecated(since = "1.2", reason = "use Arc::get_mut instead")] -pub fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> { - Arc::get_mut(this) -} - #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> Drop for Arc<T> { /// Drops the `Arc<T>`. @@ -860,7 +841,7 @@ mod tests { use std::sync::atomic::Ordering::{Acquire, SeqCst}; use std::thread; use std::vec::Vec; - use super::{Arc, Weak, get_mut, weak_count, strong_count}; + use super::{Arc, Weak}; use std::sync::Mutex; struct Canary(*mut atomic::AtomicUsize); @@ -898,43 +879,39 @@ mod tests { #[test] fn test_arc_get_mut() { - unsafe { - let mut x = Arc::new(3); - *get_mut(&mut x).unwrap() = 4; - assert_eq!(*x, 4); - let y = x.clone(); - assert!(get_mut(&mut x).is_none()); - drop(y); - assert!(get_mut(&mut x).is_some()); - let _w = x.downgrade(); - assert!(get_mut(&mut x).is_none()); - } + let mut x = Arc::new(3); + *Arc::get_mut(&mut x).unwrap() = 4; + assert_eq!(*x, 4); + let y = x.clone(); + assert!(Arc::get_mut(&mut x).is_none()); + drop(y); + assert!(Arc::get_mut(&mut x).is_some()); + let _w = x.downgrade(); + assert!(Arc::get_mut(&mut x).is_none()); } #[test] fn test_cowarc_clone_make_unique() { - unsafe { - let mut cow0 = Arc::new(75); - let mut cow1 = cow0.clone(); - let mut cow2 = cow1.clone(); - - assert!(75 == *Arc::make_unique(&mut cow0)); - assert!(75 == *Arc::make_unique(&mut cow1)); - assert!(75 == *Arc::make_unique(&mut cow2)); - - *Arc::make_unique(&mut cow0) += 1; - *Arc::make_unique(&mut cow1) += 2; - *Arc::make_unique(&mut cow2) += 3; - - assert!(76 == *cow0); - assert!(77 == *cow1); - assert!(78 == *cow2); - - // none should point to the same backing memory - assert!(*cow0 != *cow1); - assert!(*cow0 != *cow2); - assert!(*cow1 != *cow2); - } + let mut cow0 = Arc::new(75); + let mut cow1 = cow0.clone(); + let mut cow2 = cow1.clone(); + + assert!(75 == *Arc::make_unique(&mut cow0)); + assert!(75 == *Arc::make_unique(&mut cow1)); + assert!(75 == *Arc::make_unique(&mut cow2)); + + *Arc::make_unique(&mut cow0) += 1; + *Arc::make_unique(&mut cow1) += 2; + *Arc::make_unique(&mut cow2) += 3; + + assert!(76 == *cow0); + assert!(77 == *cow1); + assert!(78 == *cow2); + + // none should point to the same backing memory + assert!(*cow0 != *cow1); + assert!(*cow0 != *cow2); + assert!(*cow1 != *cow2); } #[test] @@ -947,9 +924,7 @@ mod tests { assert!(75 == *cow1); assert!(75 == *cow2); - unsafe { - *Arc::make_unique(&mut cow0) += 1; - } + *Arc::make_unique(&mut cow0) += 1; assert!(76 == *cow0); assert!(75 == *cow1); @@ -970,9 +945,7 @@ mod tests { assert!(75 == *cow0); assert!(75 == *cow1_weak.upgrade().unwrap()); - unsafe { - *Arc::make_unique(&mut cow0) += 1; - } + *Arc::make_unique(&mut cow0) += 1; assert!(76 == *cow0); assert!(cow1_weak.upgrade().is_none()); @@ -1028,40 +1001,40 @@ mod tests { #[test] fn test_strong_count() { let a = Arc::new(0u32); - assert!(strong_count(&a) == 1); + assert!(Arc::strong_count(&a) == 1); let w = a.downgrade(); - assert!(strong_count(&a) == 1); + assert!(Arc::strong_count(&a) == 1); let b = w.upgrade().expect(""); - assert!(strong_count(&b) == 2); - assert!(strong_count(&a) == 2); + assert!(Arc::strong_count(&b) == 2); + assert!(Arc::strong_count(&a) == 2); drop(w); drop(a); - assert!(strong_count(&b) == 1); + assert!(Arc::strong_count(&b) == 1); let c = b.clone(); - assert!(strong_count(&b) == 2); - assert!(strong_count(&c) == 2); + assert!(Arc::strong_count(&b) == 2); + assert!(Arc::strong_count(&c) == 2); } #[test] fn test_weak_count() { let a = Arc::new(0u32); - assert!(strong_count(&a) == 1); - assert!(weak_count(&a) == 0); + assert!(Arc::strong_count(&a) == 1); + assert!(Arc::weak_count(&a) == 0); let w = a.downgrade(); - assert!(strong_count(&a) == 1); - assert!(weak_count(&a) == 1); + assert!(Arc::strong_count(&a) == 1); + assert!(Arc::weak_count(&a) == 1); let x = w.clone(); - assert!(weak_count(&a) == 2); + assert!(Arc::weak_count(&a) == 2); drop(w); drop(x); - assert!(strong_count(&a) == 1); - assert!(weak_count(&a) == 0); + assert!(Arc::strong_count(&a) == 1); + assert!(Arc::weak_count(&a) == 0); let c = a.clone(); - assert!(strong_count(&a) == 2); - assert!(weak_count(&a) == 0); + assert!(Arc::strong_count(&a) == 2); + assert!(Arc::weak_count(&a) == 0); let d = c.downgrade(); - assert!(weak_count(&c) == 1); - assert!(strong_count(&c) == 2); + assert!(Arc::weak_count(&c) == 1); + assert!(Arc::strong_count(&c) == 2); drop(a); drop(c); diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index f31bb60ed97..8d357eb49a9 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -86,7 +86,6 @@ use core::raw::{TraitObject}; #[lang = "exchange_heap"] #[unstable(feature = "box_heap", reason = "may be renamed; uncertain about custom allocator design")] -#[allow(deprecated)] pub const HEAP: ExchangeHeapSingleton = ExchangeHeapSingleton { _force_singleton: () }; @@ -254,31 +253,6 @@ impl<T : ?Sized> Box<T> { } } -/// Consumes the `Box`, returning the wrapped raw pointer. -/// -/// After call to this function, caller is responsible for the memory -/// previously managed by `Box`, in particular caller should properly -/// destroy `T` and release memory. The proper way to do it is to -/// convert pointer back to `Box` with `Box::from_raw` function, because -/// `Box` does not specify, how memory is allocated. -/// -/// # Examples -/// ``` -/// #![feature(box_raw)] -/// -/// use std::boxed; -/// -/// let seventeen = Box::new(17u32); -/// let raw = boxed::into_raw(seventeen); -/// let boxed_again = unsafe { Box::from_raw(raw) }; -/// ``` -#[unstable(feature = "box_raw", reason = "may be renamed")] -#[deprecated(since = "1.2.0", reason = "renamed to Box::into_raw")] -#[inline] -pub fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T { - Box::into_raw(b) -} - #[stable(feature = "rust1", since = "1.0.0")] impl<T: Default> Default for Box<T> { #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 6551011e81d..05863c2ee5c 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -93,7 +93,7 @@ #![feature(core_slice_ext)] #![feature(core_str_ext)] -#![cfg_attr(test, feature(test, alloc, rustc_private, box_raw))] +#![cfg_attr(test, feature(test, rustc_private, box_raw))] #![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")), feature(libc))] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 620ceaa346b..b750e051f28 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -338,84 +338,6 @@ impl<T: ?Sized> Rc<T> { } } -/// Get the number of weak references to this value. -#[inline] -#[unstable(feature = "rc_counts")] -#[deprecated(since = "1.2.0", reason = "renamed to Rc::weak_count")] -pub fn weak_count<T: ?Sized>(this: &Rc<T>) -> usize { Rc::weak_count(this) } - -/// Get the number of strong references to this value. -#[inline] -#[unstable(feature = "rc_counts")] -#[deprecated(since = "1.2.0", reason = "renamed to Rc::strong_count")] -pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { Rc::strong_count(this) } - -/// Returns true if there are no other `Rc` or `Weak<T>` values that share the -/// same inner value. -/// -/// # Examples -/// -/// ``` -/// #![feature(rc_unique)] -/// -/// use std::rc; -/// use std::rc::Rc; -/// -/// let five = Rc::new(5); -/// -/// rc::is_unique(&five); -/// ``` -#[inline] -#[unstable(feature = "rc_unique")] -#[deprecated(since = "1.2.0", reason = "renamed to Rc::is_unique")] -pub fn is_unique<T>(rc: &Rc<T>) -> bool { Rc::is_unique(rc) } - -/// Unwraps the contained value if the `Rc<T>` is unique. -/// -/// If the `Rc<T>` is not unique, an `Err` is returned with the same `Rc<T>`. -/// -/// # Examples -/// -/// ``` -/// #![feature(rc_unique)] -/// -/// use std::rc::{self, Rc}; -/// -/// let x = Rc::new(3); -/// assert_eq!(rc::try_unwrap(x), Ok(3)); -/// -/// let x = Rc::new(4); -/// let _y = x.clone(); -/// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); -/// ``` -#[inline] -#[unstable(feature = "rc_unique")] -#[deprecated(since = "1.2.0", reason = "renamed to Rc::try_unwrap")] -pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> { Rc::try_unwrap(rc) } - -/// Returns a mutable reference to the contained value if the `Rc<T>` is unique. -/// -/// Returns `None` if the `Rc<T>` is not unique. -/// -/// # Examples -/// -/// ``` -/// #![feature(rc_unique)] -/// -/// use std::rc::{self, Rc}; -/// -/// let mut x = Rc::new(3); -/// *rc::get_mut(&mut x).unwrap() = 4; -/// assert_eq!(*x, 4); -/// -/// let _y = x.clone(); -/// assert!(rc::get_mut(&mut x).is_none()); -/// ``` -#[inline] -#[unstable(feature = "rc_unique")] -#[deprecated(since = "1.2.0", reason = "renamed to Rc::get_mut")] -pub fn get_mut<T>(rc: &mut Rc<T>) -> Option<&mut T> { Rc::get_mut(rc) } - impl<T: Clone> Rc<T> { /// Make a mutable reference from the given `Rc<T>`. /// @@ -922,7 +844,7 @@ impl<T: ?Sized> RcBoxPtr<T> for Weak<T> { #[cfg(test)] mod tests { - use super::{Rc, Weak, weak_count, strong_count}; + use super::{Rc, Weak}; use std::boxed::Box; use std::cell::RefCell; use std::option::Option; @@ -990,74 +912,74 @@ mod tests { #[test] fn is_unique() { let x = Rc::new(3); - assert!(super::is_unique(&x)); + assert!(Rc::is_unique(&x)); let y = x.clone(); - assert!(!super::is_unique(&x)); + assert!(!Rc::is_unique(&x)); drop(y); - assert!(super::is_unique(&x)); + assert!(Rc::is_unique(&x)); let w = x.downgrade(); - assert!(!super::is_unique(&x)); + assert!(!Rc::is_unique(&x)); drop(w); - assert!(super::is_unique(&x)); + assert!(Rc::is_unique(&x)); } #[test] fn test_strong_count() { let a = Rc::new(0u32); - assert!(strong_count(&a) == 1); + assert!(Rc::strong_count(&a) == 1); let w = a.downgrade(); - assert!(strong_count(&a) == 1); + assert!(Rc::strong_count(&a) == 1); let b = w.upgrade().expect("upgrade of live rc failed"); - assert!(strong_count(&b) == 2); - assert!(strong_count(&a) == 2); + assert!(Rc::strong_count(&b) == 2); + assert!(Rc::strong_count(&a) == 2); drop(w); drop(a); - assert!(strong_count(&b) == 1); + assert!(Rc::strong_count(&b) == 1); let c = b.clone(); - assert!(strong_count(&b) == 2); - assert!(strong_count(&c) == 2); + assert!(Rc::strong_count(&b) == 2); + assert!(Rc::strong_count(&c) == 2); } #[test] fn test_weak_count() { let a = Rc::new(0u32); - assert!(strong_count(&a) == 1); - assert!(weak_count(&a) == 0); + assert!(Rc::strong_count(&a) == 1); + assert!(Rc::weak_count(&a) == 0); let w = a.downgrade(); - assert!(strong_count(&a) == 1); - assert!(weak_count(&a) == 1); + assert!(Rc::strong_count(&a) == 1); + assert!(Rc::weak_count(&a) == 1); drop(w); - assert!(strong_count(&a) == 1); - assert!(weak_count(&a) == 0); + assert!(Rc::strong_count(&a) == 1); + assert!(Rc::weak_count(&a) == 0); let c = a.clone(); - assert!(strong_count(&a) == 2); - assert!(weak_count(&a) == 0); + assert!(Rc::strong_count(&a) == 2); + assert!(Rc::weak_count(&a) == 0); drop(c); } #[test] fn try_unwrap() { let x = Rc::new(3); - assert_eq!(super::try_unwrap(x), Ok(3)); + assert_eq!(Rc::try_unwrap(x), Ok(3)); let x = Rc::new(4); let _y = x.clone(); - assert_eq!(super::try_unwrap(x), Err(Rc::new(4))); + assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4))); let x = Rc::new(5); let _w = x.downgrade(); - assert_eq!(super::try_unwrap(x), Err(Rc::new(5))); + assert_eq!(Rc::try_unwrap(x), Err(Rc::new(5))); } #[test] fn get_mut() { let mut x = Rc::new(3); - *super::get_mut(&mut x).unwrap() = 4; + *Rc::get_mut(&mut x).unwrap() = 4; assert_eq!(*x, 4); let y = x.clone(); - assert!(super::get_mut(&mut x).is_none()); + assert!(Rc::get_mut(&mut x).is_none()); drop(y); - assert!(super::get_mut(&mut x).is_some()); + assert!(Rc::get_mut(&mut x).is_some()); let _w = x.downgrade(); - assert!(super::get_mut(&mut x).is_none()); + assert!(Rc::get_mut(&mut x).is_none()); } #[test] |
