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

Backport API stabilizations and an FFI fix #33883

Merged
merged 8 commits into from
May 26, 2016
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 mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CFG_RELEASE_NUM=1.10.0
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
# NB Make sure it starts with a dot to conform to semver pre-release
# versions (section 9)
CFG_PRERELEASE_VERSION=.1
CFG_PRERELEASE_VERSION=.2

# Append a version-dependent hash to each library, so we can install different
# versions in the same place
Expand Down
61 changes: 32 additions & 29 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,31 @@ impl<T: ?Sized> Drop for Arc<T> {
}
}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// use std::sync::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
unsafe {
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
}))}
}
}
}

impl<T: ?Sized> Weak<T> {
/// Upgrades a weak reference to a strong reference.
///
Expand Down Expand Up @@ -682,6 +707,13 @@ impl<T: ?Sized> Clone for Weak<T> {
}
}

#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl<T> Default for Weak<T> {
fn default() -> Weak<T> {
Weak::new()
}
}

#[stable(feature = "arc_weak", since = "1.4.0")]
impl<T: ?Sized> Drop for Weak<T> {
/// Drops the `Weak<T>`.
Expand Down Expand Up @@ -907,35 +939,6 @@ impl<T> From<T> for Arc<T> {
}
}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// #![feature(downgraded_weak)]
///
/// use std::sync::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[unstable(feature = "downgraded_weak",
reason = "recently added",
issue = "30425")]
pub fn new() -> Weak<T> {
unsafe {
Weak { ptr: Shared::new(Box::into_raw(box ArcInner {
strong: atomic::AtomicUsize::new(0),
weak: atomic::AtomicUsize::new(1),
data: uninitialized(),
}))}
}
}
}

#[cfg(test)]
mod tests {
use std::clone::Clone;
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(unsize)]
#![feature(extended_compare_and_swap)]

#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
#![cfg_attr(test, feature(test, box_heap))]
Expand Down
59 changes: 31 additions & 28 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,33 @@ impl<T: ?Sized> !marker::Sync for Weak<T> {}
#[unstable(feature = "coerce_unsized", issue = "27732")]
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Weak<U>> for Weak<T> {}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// use std::rc::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Shared::new(Box::into_raw(box RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: uninitialized(),
})),
}
}
}
}

impl<T: ?Sized> Weak<T> {
/// Upgrades a weak reference to a strong reference.
///
Expand Down Expand Up @@ -823,34 +850,10 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
}
}

impl<T> Weak<T> {
/// Constructs a new `Weak<T>` without an accompanying instance of T.
///
/// This allocates memory for T, but does not initialize it. Calling
/// Weak<T>::upgrade() on the return value always gives None.
///
/// # Examples
///
/// ```
/// #![feature(downgraded_weak)]
///
/// use std::rc::Weak;
///
/// let empty: Weak<i64> = Weak::new();
/// ```
#[unstable(feature = "downgraded_weak",
reason = "recently added",
issue="30425")]
pub fn new() -> Weak<T> {
unsafe {
Weak {
ptr: Shared::new(Box::into_raw(box RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: uninitialized(),
})),
}
}
#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl<T> Default for Weak<T> {
fn default() -> Weak<T> {
Weak::new()
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub struct Values<'a, K: 'a, V: 'a> {
}

/// A mutable iterator over a BTreeMap's values.
#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: IterMut<'a, K, V>,
}
Expand Down Expand Up @@ -1144,7 +1144,7 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
}
}

#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
type Item = &'a mut V;

Expand All @@ -1157,14 +1157,14 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
}
}

#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> DoubleEndedIterator for ValuesMut<'a, K, V> {
fn next_back(&mut self) -> Option<&'a mut V> {
self.inner.next_back().map(|(_, v)| v)
}
}

#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
#[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
fn len(&self) -> usize {
self.inner.len()
Expand Down Expand Up @@ -1575,7 +1575,6 @@ impl<K, V> BTreeMap<K, V> {
/// Basic usage:
///
/// ```
/// # #![feature(map_values_mut)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
Expand All @@ -1590,8 +1589,8 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!(values, [String::from("hello!"),
/// String::from("goodbye!")]);
/// ```
#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
pub fn values_mut<'a>(&'a mut self) -> ValuesMut<'a, K, V> {
#[stable(feature = "map_values_mut", since = "1.10.0")]
pub fn values_mut(&mut self) -> ValuesMut<K, V> {
ValuesMut { inner: self.iter_mut() }
}

Expand Down Expand Up @@ -1656,7 +1655,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
}

/// Returns a reference to this entry's key.
#[unstable(feature = "map_entry_keys", issue = "32281")]
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
match *self {
Occupied(ref entry) => entry.key(),
Expand All @@ -1668,7 +1667,7 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
/// Gets a reference to the key that would be used when inserting a value
/// through the VacantEntry.
#[unstable(feature = "map_entry_keys", issue = "32281")]
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
&self.key
}
Expand Down Expand Up @@ -1718,7 +1717,7 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {

impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
/// Gets a reference to the key in the entry.
#[unstable(feature = "map_entry_keys", issue = "32281")]
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
self.handle.reborrow().into_kv().0
}
Expand Down
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]

#![cfg_attr(test, allow(deprecated))] // rand
#![cfg_attr(not(test), feature(slice_binary_search_by_key))] // impl [T]
#![cfg_attr(not(stage0), deny(warnings))]

#![feature(alloc)]
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ impl<T> [T] {
/// fourth could match any position in `[1,4]`.
///
/// ```rust
/// #![feature(slice_binary_search_by_key)]
/// let s = [(0, 0), (2, 1), (4, 1), (5, 1), (3, 1),
/// (1, 2), (2, 3), (4, 5), (5, 8), (3, 13),
/// (1, 21), (2, 34), (4, 55)];
Expand All @@ -770,7 +769,7 @@ impl<T> [T] {
/// let r = s.binary_search_by_key(&1, |&(a,b)| b);
/// assert!(match r { Ok(1...4) => true, _ => false, });
/// ```
#[unstable(feature = "slice_binary_search_by_key", reason = "recently added", issue = "33018")]
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
#[inline]
pub fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnMut(&T) -> B,
Expand Down
2 changes: 0 additions & 2 deletions src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#![feature(enumset)]
#![feature(iter_arith)]
#![feature(linked_list_contains)]
#![feature(map_entry_keys)]
#![feature(map_values_mut)]
#![feature(pattern)]
#![feature(rand)]
#![feature(step_by)]
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#![allow(non_snake_case)]
#![stable(feature = "core_char", since = "1.2.0")]

use iter::Iterator;
use prelude::v1::*;

use mem::transmute;
use option::Option::{None, Some};
use option::Option;
use slice::SliceExt;

// UTF-8 ranges and tags for encoding characters
const TAG_CONT: u8 = 0b1000_0000;
Expand Down
1 change: 1 addition & 0 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ impl<I: Iterator> Peekable<I> {
/// ```
#[unstable(feature = "peekable_is_empty", issue = "32111")]
#[inline]
#[rustc_deprecated(since = "1.10.0", reason = "replaced by .peek().is_none()")]
pub fn is_empty(&mut self) -> bool {
self.peek().is_none()
}
Expand Down
9 changes: 4 additions & 5 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ pub trait SliceExt {
#[stable(feature = "core", since = "1.6.0")]
fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> Ordering;
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> B,
B: Ord;
#[stable(feature = "core", since = "1.6.0")]
fn len(&self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
Expand Down Expand Up @@ -157,11 +161,6 @@ pub trait SliceExt {
fn clone_from_slice(&mut self, src: &[Self::Item]) where Self::Item: Clone;
#[stable(feature = "copy_from_slice", since = "1.9.0")]
fn copy_from_slice(&mut self, src: &[Self::Item]) where Self::Item: Copy;

#[unstable(feature = "slice_binary_search_by_key", reason = "recently added", issue = "33018")]
fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> B,
B: Ord;
}

// Use macros to be generic over const/mut
Expand Down
Loading