Skip to content
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

Library stabilizations/deprecations for 1.15 release #38369

Merged
merged 12 commits into from
Dec 18, 2016
10 changes: 2 additions & 8 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(arc_counts)]
///
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
Expand All @@ -404,8 +402,7 @@ impl<T: ?Sized> Arc<T> {
/// assert_eq!(1, Arc::weak_count(&five));
/// ```
#[inline]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
issue = "28356")]
#[stable(feature = "arc_counts", since = "1.15.0")]
pub fn weak_count(this: &Self) -> usize {
this.inner().weak.load(SeqCst) - 1
}
Expand All @@ -421,8 +418,6 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(arc_counts)]
///
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
Expand All @@ -433,8 +428,7 @@ impl<T: ?Sized> Arc<T> {
/// assert_eq!(2, Arc::strong_count(&five));
/// ```
#[inline]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
issue = "28356")]
#[stable(feature = "arc_counts", since = "1.15.0")]
pub fn strong_count(this: &Self) -> usize {
this.inner().strong.load(SeqCst)
}
Expand Down
46 changes: 7 additions & 39 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<T> Rc<T> {
#[inline]
#[stable(feature = "rc_unique", since = "1.4.0")]
pub fn try_unwrap(this: Self) -> Result<T, Self> {
if Rc::would_unwrap(&this) {
if Rc::strong_count(&this) == 1 {
unsafe {
let val = ptr::read(&*this); // copy the contained object

Expand All @@ -343,26 +343,10 @@ impl<T> Rc<T> {
///
/// [try_unwrap]: struct.Rc.html#method.try_unwrap
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
///
/// # Examples
///
/// ```
/// #![feature(rc_would_unwrap)]
///
/// use std::rc::Rc;
///
/// let x = Rc::new(3);
/// assert!(Rc::would_unwrap(&x));
/// assert_eq!(Rc::try_unwrap(x), Ok(3));
///
/// let x = Rc::new(4);
/// let _y = x.clone();
/// assert!(!Rc::would_unwrap(&x));
/// assert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
/// ```
#[unstable(feature = "rc_would_unwrap",
reason = "just added for niche usecase",
issue = "28356")]
#[rustc_deprecated(since = "1.15.0", reason = "too niche; use `strong_count` instead")]
pub fn would_unwrap(this: &Self) -> bool {
Rc::strong_count(&this) == 1
}
Expand Down Expand Up @@ -482,8 +466,6 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// #![feature(rc_counts)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
Expand All @@ -492,8 +474,7 @@ impl<T: ?Sized> Rc<T> {
/// assert_eq!(1, Rc::weak_count(&five));
/// ```
#[inline]
#[unstable(feature = "rc_counts", reason = "not clearly useful",
issue = "28356")]
#[stable(feature = "rc_counts", since = "1.15.0")]
pub fn weak_count(this: &Self) -> usize {
this.weak() - 1
}
Expand All @@ -503,8 +484,6 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// #![feature(rc_counts)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
Expand All @@ -513,8 +492,7 @@ impl<T: ?Sized> Rc<T> {
/// assert_eq!(2, Rc::strong_count(&five));
/// ```
#[inline]
#[unstable(feature = "rc_counts", reason = "not clearly useful",
issue = "28356")]
#[stable(feature = "rc_counts", since = "1.15.0")]
pub fn strong_count(this: &Self) -> usize {
this.strong()
}
Expand All @@ -523,21 +501,11 @@ impl<T: ?Sized> Rc<T> {
/// this inner value.
///
/// [weak]: struct.Weak.html
///
/// # Examples
///
/// ```
/// #![feature(rc_counts)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
///
/// assert!(Rc::is_unique(&five));
/// ```
#[inline]
#[unstable(feature = "rc_counts", reason = "uniqueness has unclear meaning",
#[unstable(feature = "is_unique", reason = "uniqueness has unclear meaning",
issue = "28356")]
#[rustc_deprecated(since = "1.15.0",
reason = "too niche; use `strong_count` and `weak_count` instead")]
pub fn is_unique(this: &Self) -> bool {
Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1
}
Expand Down
6 changes: 2 additions & 4 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1902,14 +1902,13 @@ impl<T> IntoIter<T> {
/// # Examples
///
/// ```
/// # #![feature(vec_into_iter_as_slice)]
/// let vec = vec!['a', 'b', 'c'];
/// let mut into_iter = vec.into_iter();
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
/// let _ = into_iter.next().unwrap();
/// assert_eq!(into_iter.as_slice(), &['b', 'c']);
/// ```
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
#[stable(feature = "vec_into_iter_as_slice", since = "1.15.0")]
pub fn as_slice(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.ptr, self.len())
Expand All @@ -1921,7 +1920,6 @@ impl<T> IntoIter<T> {
/// # Examples
///
/// ```
/// # #![feature(vec_into_iter_as_slice)]
/// let vec = vec!['a', 'b', 'c'];
/// let mut into_iter = vec.into_iter();
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
Expand All @@ -1930,7 +1928,7 @@ impl<T> IntoIter<T> {
/// assert_eq!(into_iter.next().unwrap(), 'b');
/// assert_eq!(into_iter.next().unwrap(), 'z');
/// ```
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
#[stable(feature = "vec_into_iter_as_slice", since = "1.15.0")]
pub fn as_mut_slice(&self) -> &mut [T] {
unsafe {
slice::from_raw_parts_mut(self.ptr as *mut T, self.len())
Expand Down
1 change: 0 additions & 1 deletion src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#![feature(test)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(vec_into_iter_as_slice)]

extern crate collections;
extern crate test;
Expand Down
8 changes: 5 additions & 3 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ pub struct RefCell<T: ?Sized> {
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[unstable(feature = "borrow_state", issue = "27733")]
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
#[allow(deprecated)]
pub enum BorrowState {
/// The cell is currently being read, there is at least one active `borrow`.
Reading,
Expand Down Expand Up @@ -511,6 +513,8 @@ impl<T: ?Sized> RefCell<T> {
/// }
/// ```
#[unstable(feature = "borrow_state", issue = "27733")]
#[rustc_deprecated(since = "1.15.0", reason = "use `try_borrow` instead")]
#[allow(deprecated)]
#[inline]
pub fn borrow_state(&self) -> BorrowState {
match self.borrow.get() {
Expand Down Expand Up @@ -888,9 +892,7 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// `Ref::clone(...)`. A `Clone` implementation or a method would interfere
/// with the widespread use of `r.borrow().clone()` to clone the contents of
/// a `RefCell`.
#[unstable(feature = "cell_extras",
reason = "likely to be moved to a method, pending language changes",
issue = "27746")]
#[stable(feature = "cell_extras", since = "1.15.0")]
#[inline]
pub fn clone(orig: &Ref<'b, T>) -> Ref<'b, T> {
Ref {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ pub trait CharExt {
fn len_utf8(self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn len_utf16(self) -> usize;
#[unstable(feature = "unicode", issue = "27784")]
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
fn encode_utf8(self, dst: &mut [u8]) -> &mut str;
#[unstable(feature = "unicode", issue = "27784")]
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16];
}

Expand Down
10 changes: 5 additions & 5 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#![stable(feature = "rust1", since = "1.0.0")]

use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut, BorrowState};
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
use marker::PhantomData;
use mem;
use num::flt2dec;
Expand Down Expand Up @@ -1634,13 +1634,13 @@ impl<T: Copy + Debug> Debug for Cell<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + Debug> Debug for RefCell<T> {
fn fmt(&self, f: &mut Formatter) -> Result {
match self.borrow_state() {
BorrowState::Unused | BorrowState::Reading => {
match self.try_borrow() {
Ok(borrow) => {
f.debug_struct("RefCell")
.field("value", &self.borrow())
.field("value", &borrow)
.finish()
}
BorrowState::Writing => {
Err(_) => {
f.debug_struct("RefCell")
.field("value", &"<borrowed>")
.finish()
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,12 +1696,11 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// #![feature(iter_max_by)]
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x, y| x.cmp(y)).unwrap(), 5);
/// ```
#[inline]
#[unstable(feature = "iter_max_by", issue="36105")]
#[stable(feature = "iter_max_by", since = "1.15.0")]
fn max_by<F>(self, mut compare: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
{
Expand Down Expand Up @@ -1746,12 +1745,11 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// #![feature(iter_min_by)]
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x, y| x.cmp(y)).unwrap(), -10);
/// ```
#[inline]
#[unstable(feature = "iter_min_by", issue="36105")]
#[stable(feature = "iter_min_by", since = "1.15.0")]
fn min_by<F>(self, mut compare: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
{
Expand Down
18 changes: 6 additions & 12 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ impl AtomicBool {
/// # Examples
///
/// ```
/// #![feature(atomic_access)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bool = AtomicBool::new(true);
Expand All @@ -212,7 +211,7 @@ impl AtomicBool {
/// assert_eq!(some_bool.load(Ordering::SeqCst), false);
/// ```
#[inline]
#[unstable(feature = "atomic_access", issue = "35603")]
#[stable(feature = "atomic_access", since = "1.15.0")]
pub fn get_mut(&mut self) -> &mut bool {
unsafe { &mut *(self.v.get() as *mut bool) }
}
Expand All @@ -225,14 +224,13 @@ impl AtomicBool {
/// # Examples
///
/// ```
/// #![feature(atomic_access)]
/// use std::sync::atomic::AtomicBool;
///
/// let some_bool = AtomicBool::new(true);
/// assert_eq!(some_bool.into_inner(), true);
/// ```
#[inline]
#[unstable(feature = "atomic_access", issue = "35603")]
#[stable(feature = "atomic_access", since = "1.15.0")]
pub fn into_inner(self) -> bool {
unsafe { self.v.into_inner() != 0 }
}
Expand Down Expand Up @@ -588,15 +586,14 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```
/// #![feature(atomic_access)]
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
/// let mut atomic_ptr = AtomicPtr::new(&mut 10);
/// *atomic_ptr.get_mut() = &mut 5;
/// assert_eq!(unsafe { *atomic_ptr.load(Ordering::SeqCst) }, 5);
/// ```
#[inline]
#[unstable(feature = "atomic_access", issue = "35603")]
#[stable(feature = "atomic_access", since = "1.15.0")]
pub fn get_mut(&mut self) -> &mut *mut T {
unsafe { &mut *self.p.get() }
}
Expand All @@ -609,14 +606,13 @@ impl<T> AtomicPtr<T> {
/// # Examples
///
/// ```
/// #![feature(atomic_access)]
/// use std::sync::atomic::AtomicPtr;
///
/// let atomic_ptr = AtomicPtr::new(&mut 5);
/// assert_eq!(unsafe { *atomic_ptr.into_inner() }, 5);
/// ```
#[inline]
#[unstable(feature = "atomic_access", issue = "35603")]
#[stable(feature = "atomic_access", since = "1.15.0")]
pub fn into_inner(self) -> *mut T {
unsafe { self.p.into_inner() }
}
Expand Down Expand Up @@ -883,7 +879,6 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```
/// #![feature(atomic_access)]
/// use std::sync::atomic::{AtomicIsize, Ordering};
///
/// let mut some_isize = AtomicIsize::new(10);
Expand All @@ -905,7 +900,6 @@ macro_rules! atomic_int {
/// # Examples
///
/// ```
/// #![feature(atomic_access)]
/// use std::sync::atomic::AtomicIsize;
///
/// let some_isize = AtomicIsize::new(5);
Expand Down Expand Up @@ -1261,15 +1255,15 @@ atomic_int!{
stable(feature = "rust1", since = "1.0.0"),
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
stable(feature = "atomic_debug", since = "1.3.0"),
unstable(feature = "atomic_access", issue = "35603"),
stable(feature = "atomic_access", since = "1.15.0"),
isize AtomicIsize ATOMIC_ISIZE_INIT
}
#[cfg(target_has_atomic = "ptr")]
atomic_int!{
stable(feature = "rust1", since = "1.0.0"),
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
stable(feature = "atomic_debug", since = "1.3.0"),
unstable(feature = "atomic_access", issue = "35603"),
stable(feature = "atomic_access", since = "1.15.0"),
usize AtomicUsize ATOMIC_USIZE_INIT
}

Expand Down
Loading