1
Fork 0

Auto merge of #40538 - aturon:stab-1.17, r=alexcrichton

Library stabilizations for 1.17

Details of the stabilizations are available in the commits. Includes only library stabilizations; there are a couple of compiler stabilizations that should also be done for 1.17.

Will need a beta backport, which I will create after approval.

r? @alexcrichton
This commit is contained in:
bors 2017-03-19 01:40:57 +00:00
commit bfc49b1092
20 changed files with 77 additions and 113 deletions

View file

@ -287,17 +287,15 @@ impl<T> Arc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(rc_raw)]
///
/// use std::sync::Arc; /// use std::sync::Arc;
/// ///
/// let x = Arc::new(10); /// let x = Arc::new(10);
/// let x_ptr = Arc::into_raw(x); /// let x_ptr = Arc::into_raw(x);
/// assert_eq!(unsafe { *x_ptr }, 10); /// assert_eq!(unsafe { *x_ptr }, 10);
/// ``` /// ```
#[unstable(feature = "rc_raw", issue = "37197")] #[stable(feature = "rc_raw", since = "1.17.0")]
pub fn into_raw(this: Self) -> *mut T { pub fn into_raw(this: Self) -> *const T {
let ptr = unsafe { &mut (**this.ptr).data as *mut _ }; let ptr = unsafe { &(**this.ptr).data as *const _ };
mem::forget(this); mem::forget(this);
ptr ptr
} }
@ -315,8 +313,6 @@ impl<T> Arc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(rc_raw)]
///
/// use std::sync::Arc; /// use std::sync::Arc;
/// ///
/// let x = Arc::new(10); /// let x = Arc::new(10);
@ -332,11 +328,14 @@ impl<T> Arc<T> {
/// ///
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling! /// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
/// ``` /// ```
#[unstable(feature = "rc_raw", issue = "37197")] #[stable(feature = "rc_raw", since = "1.17.0")]
pub unsafe fn from_raw(ptr: *mut T) -> Self { pub unsafe fn from_raw(ptr: *const T) -> Self {
// To find the corresponding pointer to the `ArcInner` we need to subtract the offset of the // To find the corresponding pointer to the `ArcInner` we need to subtract the offset of the
// `data` field from the pointer. // `data` field from the pointer.
Arc { ptr: Shared::new((ptr as *mut u8).offset(-offset_of!(ArcInner<T>, data)) as *mut _) } let ptr = (ptr as *const u8).offset(-offset_of!(ArcInner<T>, data));
Arc {
ptr: Shared::new(ptr as *const _),
}
} }
} }
@ -448,7 +447,7 @@ impl<T: ?Sized> Arc<T> {
// Non-inlined part of `drop`. // Non-inlined part of `drop`.
#[inline(never)] #[inline(never)]
unsafe fn drop_slow(&mut self) { unsafe fn drop_slow(&mut self) {
let ptr = *self.ptr; let ptr = self.ptr.as_mut_ptr();
// Destroy the data at this time, even though we may not free the box // Destroy the data at this time, even though we may not free the box
// allocation itself (there may still be weak pointers lying around). // allocation itself (there may still be weak pointers lying around).
@ -461,17 +460,13 @@ impl<T: ?Sized> Arc<T> {
} }
#[inline] #[inline]
#[unstable(feature = "ptr_eq", #[stable(feature = "ptr_eq", since = "1.17.0")]
reason = "newly added",
issue = "36497")]
/// Returns true if the two `Arc`s point to the same value (not /// Returns true if the two `Arc`s point to the same value (not
/// just values that compare as equal). /// just values that compare as equal).
/// ///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(ptr_eq)]
///
/// use std::sync::Arc; /// use std::sync::Arc;
/// ///
/// let five = Arc::new(5); /// let five = Arc::new(5);
@ -628,7 +623,7 @@ impl<T: Clone> Arc<T> {
// As with `get_mut()`, the unsafety is ok because our reference was // As with `get_mut()`, the unsafety is ok because our reference was
// either unique to begin with, or became one upon cloning the contents. // either unique to begin with, or became one upon cloning the contents.
unsafe { unsafe {
let inner = &mut **this.ptr; let inner = &mut *this.ptr.as_mut_ptr();
&mut inner.data &mut inner.data
} }
} }
@ -671,7 +666,7 @@ impl<T: ?Sized> Arc<T> {
// the Arc itself to be `mut`, so we're returning the only possible // the Arc itself to be `mut`, so we're returning the only possible
// reference to the inner data. // reference to the inner data.
unsafe { unsafe {
let inner = &mut **this.ptr; let inner = &mut *this.ptr.as_mut_ptr();
Some(&mut inner.data) Some(&mut inner.data)
} }
} else { } else {

View file

@ -364,17 +364,15 @@ impl<T> Rc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(rc_raw)]
///
/// use std::rc::Rc; /// use std::rc::Rc;
/// ///
/// let x = Rc::new(10); /// let x = Rc::new(10);
/// let x_ptr = Rc::into_raw(x); /// let x_ptr = Rc::into_raw(x);
/// assert_eq!(unsafe { *x_ptr }, 10); /// assert_eq!(unsafe { *x_ptr }, 10);
/// ``` /// ```
#[unstable(feature = "rc_raw", issue = "37197")] #[stable(feature = "rc_raw", since = "1.17.0")]
pub fn into_raw(this: Self) -> *mut T { pub fn into_raw(this: Self) -> *const T {
let ptr = unsafe { &mut (**this.ptr).value as *mut _ }; let ptr = unsafe { &mut (*this.ptr.as_mut_ptr()).value as *const _ };
mem::forget(this); mem::forget(this);
ptr ptr
} }
@ -392,8 +390,6 @@ impl<T> Rc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(rc_raw)]
///
/// use std::rc::Rc; /// use std::rc::Rc;
/// ///
/// let x = Rc::new(10); /// let x = Rc::new(10);
@ -409,11 +405,11 @@ impl<T> Rc<T> {
/// ///
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling! /// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
/// ``` /// ```
#[unstable(feature = "rc_raw", issue = "37197")] #[stable(feature = "rc_raw", since = "1.17.0")]
pub unsafe fn from_raw(ptr: *mut T) -> Self { pub unsafe fn from_raw(ptr: *const T) -> Self {
// To find the corresponding pointer to the `RcBox` we need to subtract the offset of the // To find the corresponding pointer to the `RcBox` we need to subtract the offset of the
// `value` field from the pointer. // `value` field from the pointer.
Rc { ptr: Shared::new((ptr as *mut u8).offset(-offset_of!(RcBox<T>, value)) as *mut _) } Rc { ptr: Shared::new((ptr as *const u8).offset(-offset_of!(RcBox<T>, value)) as *const _) }
} }
} }
@ -543,7 +539,7 @@ impl<T: ?Sized> Rc<T> {
#[stable(feature = "rc_unique", since = "1.4.0")] #[stable(feature = "rc_unique", since = "1.4.0")]
pub fn get_mut(this: &mut Self) -> Option<&mut T> { pub fn get_mut(this: &mut Self) -> Option<&mut T> {
if Rc::is_unique(this) { if Rc::is_unique(this) {
let inner = unsafe { &mut **this.ptr }; let inner = unsafe { &mut *this.ptr.as_mut_ptr() };
Some(&mut inner.value) Some(&mut inner.value)
} else { } else {
None None
@ -551,17 +547,13 @@ impl<T: ?Sized> Rc<T> {
} }
#[inline] #[inline]
#[unstable(feature = "ptr_eq", #[stable(feature = "ptr_eq", since = "1.17.0")]
reason = "newly added",
issue = "36497")]
/// Returns true if the two `Rc`s point to the same value (not /// Returns true if the two `Rc`s point to the same value (not
/// just values that compare as equal). /// just values that compare as equal).
/// ///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(ptr_eq)]
///
/// use std::rc::Rc; /// use std::rc::Rc;
/// ///
/// let five = Rc::new(5); /// let five = Rc::new(5);
@ -631,7 +623,7 @@ impl<T: Clone> Rc<T> {
// reference count is guaranteed to be 1 at this point, and we required // reference count is guaranteed to be 1 at this point, and we required
// the `Rc<T>` itself to be `mut`, so we're returning the only possible // the `Rc<T>` itself to be `mut`, so we're returning the only possible
// reference to the inner value. // reference to the inner value.
let inner = unsafe { &mut **this.ptr }; let inner = unsafe { &mut *this.ptr.as_mut_ptr() };
&mut inner.value &mut inner.value
} }
} }
@ -677,7 +669,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
/// ``` /// ```
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
let ptr = *self.ptr; let ptr = self.ptr.as_mut_ptr();
self.dec_strong(); self.dec_strong();
if self.strong() == 0 { if self.strong() == 0 {

View file

@ -338,6 +338,7 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
} }
/// An iterator over a sub-range of BTreeMap's entries. /// An iterator over a sub-range of BTreeMap's entries.
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct Range<'a, K: 'a, V: 'a> { pub struct Range<'a, K: 'a, V: 'a> {
front: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>, front: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
back: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>, back: Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>,
@ -351,6 +352,7 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Range<'a, K, V>
} }
/// A mutable iterator over a sub-range of BTreeMap's entries. /// A mutable iterator over a sub-range of BTreeMap's entries.
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct RangeMut<'a, K: 'a, V: 'a> { pub struct RangeMut<'a, K: 'a, V: 'a> {
front: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>, front: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
back: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>, back: Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>,
@ -724,8 +726,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// #![feature(btree_range, collections_bound)]
///
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// use std::collections::Bound::Included; /// use std::collections::Bound::Included;
/// ///
@ -738,9 +738,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// } /// }
/// assert_eq!(Some((&5, &"b")), map.range(4..).next()); /// assert_eq!(Some((&5, &"b")), map.range(4..).next());
/// ``` /// ```
#[unstable(feature = "btree_range", #[stable(feature = "btree_range", since = "1.17.0")]
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27787")]
pub fn range<T: ?Sized, R>(&self, range: R) -> Range<K, V> pub fn range<T: ?Sized, R>(&self, range: R) -> Range<K, V>
where T: Ord, K: Borrow<T>, R: RangeArgument<T> where T: Ord, K: Borrow<T>, R: RangeArgument<T>
{ {
@ -768,8 +766,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// #![feature(btree_range)]
///
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// ///
/// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"].iter() /// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"].iter()
@ -782,9 +778,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// println!("{} => {}", name, balance); /// println!("{} => {}", name, balance);
/// } /// }
/// ``` /// ```
#[unstable(feature = "btree_range", #[stable(feature = "btree_range", since = "1.17.0")]
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27787")]
pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<K, V> pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<K, V>
where T: Ord, K: Borrow<T>, R: RangeArgument<T> where T: Ord, K: Borrow<T>, R: RangeArgument<T>
{ {

View file

@ -113,6 +113,7 @@ pub struct IntoIter<T> {
/// [`BTreeSet`]: struct.BTreeSet.html /// [`BTreeSet`]: struct.BTreeSet.html
/// [`range`]: struct.BTreeSet.html#method.range /// [`range`]: struct.BTreeSet.html#method.range
#[derive(Debug)] #[derive(Debug)]
#[stable(feature = "btree_range", since = "1.17.0")]
pub struct Range<'a, T: 'a> { pub struct Range<'a, T: 'a> {
iter: ::btree_map::Range<'a, T, ()>, iter: ::btree_map::Range<'a, T, ()>,
} }
@ -264,8 +265,6 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(btree_range, collections_bound)]
///
/// use std::collections::BTreeSet; /// use std::collections::BTreeSet;
/// use std::collections::Bound::Included; /// use std::collections::Bound::Included;
/// ///
@ -278,9 +277,7 @@ impl<T: Ord> BTreeSet<T> {
/// } /// }
/// assert_eq!(Some(&5), set.range(4..).next()); /// assert_eq!(Some(&5), set.range(4..).next());
/// ``` /// ```
#[unstable(feature = "btree_range", #[stable(feature = "btree_range", since = "1.17.0")]
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27787")]
pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T> pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T>
where K: Ord, T: Borrow<K>, R: RangeArgument<K> where K: Ord, T: Borrow<K>, R: RangeArgument<K>
{ {

View file

@ -129,14 +129,17 @@ mod std {
} }
/// An endpoint of a range of keys. /// An endpoint of a range of keys.
#[unstable(feature = "collections_bound", issue = "27787")] #[stable(feature = "collections_bound", since = "1.17.0")]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum Bound<T> { pub enum Bound<T> {
/// An inclusive bound. /// An inclusive bound.
#[stable(feature = "collections_bound", since = "1.17.0")]
Included(T), Included(T),
/// An exclusive bound. /// An exclusive bound.
#[stable(feature = "collections_bound", since = "1.17.0")]
Excluded(T), Excluded(T),
/// An infinite endpoint. Indicates that there is no bound in this direction. /// An infinite endpoint. Indicates that there is no bound in this direction.
#[stable(feature = "collections_bound", since = "1.17.0")]
Unbounded, Unbounded,
} }

View file

@ -142,7 +142,7 @@ impl<T> LinkedList<T> {
match self.head { match self.head {
None => self.tail = node, None => self.tail = node,
Some(head) => (**head).prev = node, Some(head) => (*head.as_mut_ptr()).prev = node,
} }
self.head = node; self.head = node;
@ -154,12 +154,12 @@ impl<T> LinkedList<T> {
#[inline] #[inline]
fn pop_front_node(&mut self) -> Option<Box<Node<T>>> { fn pop_front_node(&mut self) -> Option<Box<Node<T>>> {
self.head.map(|node| unsafe { self.head.map(|node| unsafe {
let node = Box::from_raw(*node); let node = Box::from_raw(node.as_mut_ptr());
self.head = node.next; self.head = node.next;
match self.head { match self.head {
None => self.tail = None, None => self.tail = None,
Some(head) => (**head).prev = None, Some(head) => (*head.as_mut_ptr()).prev = None,
} }
self.len -= 1; self.len -= 1;
@ -177,7 +177,7 @@ impl<T> LinkedList<T> {
match self.tail { match self.tail {
None => self.head = node, None => self.head = node,
Some(tail) => (**tail).next = node, Some(tail) => (*tail.as_mut_ptr()).next = node,
} }
self.tail = node; self.tail = node;
@ -189,12 +189,12 @@ impl<T> LinkedList<T> {
#[inline] #[inline]
fn pop_back_node(&mut self) -> Option<Box<Node<T>>> { fn pop_back_node(&mut self) -> Option<Box<Node<T>>> {
self.tail.map(|node| unsafe { self.tail.map(|node| unsafe {
let node = Box::from_raw(*node); let node = Box::from_raw(node.as_mut_ptr());
self.tail = node.prev; self.tail = node.prev;
match self.tail { match self.tail {
None => self.head = None, None => self.head = None,
Some(tail) => (**tail).next = None, Some(tail) => (*tail.as_mut_ptr()).next = None,
} }
self.len -= 1; self.len -= 1;
@ -269,8 +269,8 @@ impl<T> LinkedList<T> {
Some(tail) => { Some(tail) => {
if let Some(other_head) = other.head.take() { if let Some(other_head) = other.head.take() {
unsafe { unsafe {
(**tail).next = Some(other_head); (*tail.as_mut_ptr()).next = Some(other_head);
(**other_head).prev = Some(tail); (*other_head.as_mut_ptr()).prev = Some(tail);
} }
self.tail = other.tail.take(); self.tail = other.tail.take();
@ -484,7 +484,7 @@ impl<T> LinkedList<T> {
#[inline] #[inline]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn front_mut(&mut self) -> Option<&mut T> { pub fn front_mut(&mut self) -> Option<&mut T> {
self.head.map(|node| unsafe { &mut (**node).element }) self.head.map(|node| unsafe { &mut (*node.as_mut_ptr()).element })
} }
/// Provides a reference to the back element, or `None` if the list is /// Provides a reference to the back element, or `None` if the list is
@ -530,7 +530,7 @@ impl<T> LinkedList<T> {
#[inline] #[inline]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn back_mut(&mut self) -> Option<&mut T> { pub fn back_mut(&mut self) -> Option<&mut T> {
self.tail.map(|node| unsafe { &mut (**node).element }) self.tail.map(|node| unsafe { &mut (*node.as_mut_ptr()).element })
} }
/// Adds an element first in the list. /// Adds an element first in the list.
@ -675,9 +675,9 @@ impl<T> LinkedList<T> {
let second_part_head; let second_part_head;
unsafe { unsafe {
second_part_head = (**split_node.unwrap()).next.take(); second_part_head = (*split_node.unwrap().as_mut_ptr()).next.take();
if let Some(head) = second_part_head { if let Some(head) = second_part_head {
(**head).prev = None; (*head.as_mut_ptr()).prev = None;
} }
} }
@ -816,7 +816,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
None None
} else { } else {
self.head.map(|node| unsafe { self.head.map(|node| unsafe {
let node = &mut **node; let node = &mut *node.as_mut_ptr();
self.len -= 1; self.len -= 1;
self.head = node.next; self.head = node.next;
&mut node.element &mut node.element
@ -838,7 +838,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
None None
} else { } else {
self.tail.map(|node| unsafe { self.tail.map(|node| unsafe {
let node = &mut **node; let node = &mut *node.as_mut_ptr();
self.len -= 1; self.len -= 1;
self.tail = node.prev; self.tail = node.prev;
&mut node.element &mut node.element
@ -896,8 +896,8 @@ impl<'a, T> IterMut<'a, T> {
element: element, element: element,
}))); })));
(**prev).next = node; (*prev.as_mut_ptr()).next = node;
(**head).prev = node; (*head.as_mut_ptr()).prev = node;
self.list.len += 1; self.list.len += 1;
}, },
@ -929,7 +929,7 @@ impl<'a, T> IterMut<'a, T> {
if self.len == 0 { if self.len == 0 {
None None
} else { } else {
self.head.map(|node| unsafe { &mut (**node).element }) self.head.map(|node| unsafe { &mut (*node.as_mut_ptr()).element })
} }
} }
} }

View file

@ -29,7 +29,6 @@ pub trait RangeArgument<T: ?Sized> {
/// ``` /// ```
/// #![feature(collections)] /// #![feature(collections)]
/// #![feature(collections_range)] /// #![feature(collections_range)]
/// #![feature(collections_bound)]
/// ///
/// extern crate collections; /// extern crate collections;
/// ///
@ -52,7 +51,6 @@ pub trait RangeArgument<T: ?Sized> {
/// ``` /// ```
/// #![feature(collections)] /// #![feature(collections)]
/// #![feature(collections_range)] /// #![feature(collections_range)]
/// #![feature(collections_bound)]
/// ///
/// extern crate collections; /// extern crate collections;
/// ///

View file

@ -2120,7 +2120,7 @@ unsafe impl<#[may_dangle] T> Drop for IntoIter<T> {
for _x in self.by_ref() {} for _x in self.by_ref() {}
// RawVec handles deallocation // RawVec handles deallocation
let _ = unsafe { RawVec::from_raw_parts(*self.buf, self.cap) }; let _ = unsafe { RawVec::from_raw_parts(self.buf.as_mut_ptr(), self.cap) };
} }
} }
@ -2185,7 +2185,7 @@ impl<'a, T> Drop for Drain<'a, T> {
if self.tail_len > 0 { if self.tail_len > 0 {
unsafe { unsafe {
let source_vec = &mut **self.vec; let source_vec = &mut *self.vec.as_mut_ptr();
// memmove back untouched tail, update to new length // memmove back untouched tail, update to new length
let start = source_vec.len(); let start = source_vec.len();
let tail = self.tail_start; let tail = self.tail_start;

View file

@ -2125,7 +2125,7 @@ impl<'a, T: 'a> Drop for Drain<'a, T> {
fn drop(&mut self) { fn drop(&mut self) {
for _ in self.by_ref() {} for _ in self.by_ref() {}
let source_deque = unsafe { &mut **self.deque }; let source_deque = unsafe { &mut *self.deque.as_mut_ptr() };
// T = source_deque_tail; H = source_deque_head; t = drain_tail; h = drain_head // T = source_deque_tail; H = source_deque_head; t = drain_tail; h = drain_head
// //

View file

@ -13,11 +13,9 @@
#![feature(binary_heap_extras)] #![feature(binary_heap_extras)]
#![feature(binary_heap_peek_mut_pop)] #![feature(binary_heap_peek_mut_pop)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(btree_range)]
#![feature(inclusive_range_syntax)] #![feature(inclusive_range_syntax)]
#![feature(collection_placement)] #![feature(collection_placement)]
#![feature(collections)] #![feature(collections)]
#![feature(collections_bound)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(pattern)] #![feature(pattern)]

View file

@ -394,7 +394,6 @@ impl<T> Cell<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(move_cell)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// let c1 = Cell::new(5i32); /// let c1 = Cell::new(5i32);
@ -404,7 +403,7 @@ impl<T> Cell<T> {
/// assert_eq!(5, c2.get()); /// assert_eq!(5, c2.get());
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "move_cell", issue = "39264")] #[stable(feature = "move_cell", since = "1.17.0")]
pub fn swap(&self, other: &Self) { pub fn swap(&self, other: &Self) {
if ptr::eq(self, other) { if ptr::eq(self, other) {
return; return;
@ -419,7 +418,6 @@ impl<T> Cell<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(move_cell)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// let c = Cell::new(5); /// let c = Cell::new(5);
@ -427,7 +425,7 @@ impl<T> Cell<T> {
/// ///
/// assert_eq!(5, old); /// assert_eq!(5, old);
/// ``` /// ```
#[unstable(feature = "move_cell", issue = "39264")] #[stable(feature = "move_cell", since = "1.17.0")]
pub fn replace(&self, val: T) -> T { pub fn replace(&self, val: T) -> T {
mem::replace(unsafe { &mut *self.value.get() }, val) mem::replace(unsafe { &mut *self.value.get() }, val)
} }
@ -437,7 +435,6 @@ impl<T> Cell<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(move_cell)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// let c = Cell::new(5); /// let c = Cell::new(5);
@ -445,7 +442,7 @@ impl<T> Cell<T> {
/// ///
/// assert_eq!(five, 5); /// assert_eq!(five, 5);
/// ``` /// ```
#[unstable(feature = "move_cell", issue = "39264")] #[stable(feature = "move_cell", since = "1.17.0")]
pub fn into_inner(self) -> T { pub fn into_inner(self) -> T {
unsafe { self.value.into_inner() } unsafe { self.value.into_inner() }
} }
@ -457,7 +454,6 @@ impl<T: Default> Cell<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(move_cell)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// let c = Cell::new(5); /// let c = Cell::new(5);
@ -466,7 +462,7 @@ impl<T: Default> Cell<T> {
/// assert_eq!(five, 5); /// assert_eq!(five, 5);
/// assert_eq!(c.into_inner(), 0); /// assert_eq!(c.into_inner(), 0);
/// ``` /// ```
#[unstable(feature = "move_cell", issue = "39264")] #[stable(feature = "move_cell", since = "1.17.0")]
pub fn take(&self) -> T { pub fn take(&self) -> T {
self.replace(Default::default()) self.replace(Default::default())
} }

View file

@ -255,8 +255,6 @@ impl Ordering {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(ordering_chaining)]
///
/// use std::cmp::Ordering; /// use std::cmp::Ordering;
/// ///
/// let result = Ordering::Equal.then(Ordering::Less); /// let result = Ordering::Equal.then(Ordering::Less);
@ -278,7 +276,7 @@ impl Ordering {
/// assert_eq!(result, Ordering::Less); /// assert_eq!(result, Ordering::Less);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "ordering_chaining", issue = "37053")] #[stable(feature = "ordering_chaining", since = "1.17.0")]
pub fn then(self, other: Ordering) -> Ordering { pub fn then(self, other: Ordering) -> Ordering {
match self { match self {
Equal => other, Equal => other,
@ -294,8 +292,6 @@ impl Ordering {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(ordering_chaining)]
///
/// use std::cmp::Ordering; /// use std::cmp::Ordering;
/// ///
/// let result = Ordering::Equal.then_with(|| Ordering::Less); /// let result = Ordering::Equal.then_with(|| Ordering::Less);
@ -317,7 +313,7 @@ impl Ordering {
/// assert_eq!(result, Ordering::Less); /// assert_eq!(result, Ordering::Less);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "ordering_chaining", issue = "37053")] #[stable(feature = "ordering_chaining", since = "1.17.0")]
pub fn then_with<F: FnOnce() -> Ordering>(self, f: F) -> Ordering { pub fn then_with<F: FnOnce() -> Ordering>(self, f: F) -> Ordering {
match self { match self {
Equal => f(), Equal => f(),

View file

@ -161,8 +161,6 @@ pub unsafe fn read<T>(src: *const T) -> T {
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// #![feature(ptr_unaligned)]
///
/// let x = 12; /// let x = 12;
/// let y = &x as *const i32; /// let y = &x as *const i32;
/// ///
@ -171,7 +169,7 @@ pub unsafe fn read<T>(src: *const T) -> T {
/// } /// }
/// ``` /// ```
#[inline(always)] #[inline(always)]
#[unstable(feature = "ptr_unaligned", issue = "37955")] #[stable(feature = "ptr_unaligned", since = "1.17.0")]
pub unsafe fn read_unaligned<T>(src: *const T) -> T { pub unsafe fn read_unaligned<T>(src: *const T) -> T {
let mut tmp: T = mem::uninitialized(); let mut tmp: T = mem::uninitialized();
copy_nonoverlapping(src as *const u8, copy_nonoverlapping(src as *const u8,
@ -243,8 +241,6 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// Basic usage: /// Basic usage:
/// ///
/// ``` /// ```
/// #![feature(ptr_unaligned)]
///
/// let mut x = 0; /// let mut x = 0;
/// let y = &mut x as *mut i32; /// let y = &mut x as *mut i32;
/// let z = 12; /// let z = 12;
@ -255,7 +251,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// } /// }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "ptr_unaligned", issue = "37955")] #[stable(feature = "ptr_unaligned", since = "1.17.0")]
pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) { pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
copy_nonoverlapping(&src as *const T as *const u8, copy_nonoverlapping(&src as *const T as *const u8,
dst as *mut u8, dst as *mut u8,
@ -662,7 +658,6 @@ impl<T: ?Sized> Eq for *mut T {}
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(ptr_eq)]
/// use std::ptr; /// use std::ptr;
/// ///
/// let five = 5; /// let five = 5;
@ -677,7 +672,7 @@ impl<T: ?Sized> Eq for *mut T {}
/// assert!(ptr::eq(five_ref, same_five_ref)); /// assert!(ptr::eq(five_ref, same_five_ref));
/// assert!(!ptr::eq(five_ref, other_five_ref)); /// assert!(!ptr::eq(five_ref, other_five_ref));
/// ``` /// ```
#[unstable(feature = "ptr_eq", reason = "newly added", issue = "36497")] #[stable(feature = "ptr_eq", since = "1.17.0")]
#[inline] #[inline]
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool { pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
a == b a == b
@ -972,11 +967,19 @@ impl<T: ?Sized> Shared<T> {
/// # Safety /// # Safety
/// ///
/// `ptr` must be non-null. /// `ptr` must be non-null.
pub unsafe fn new(ptr: *mut T) -> Self { pub unsafe fn new(ptr: *const T) -> Self {
Shared { pointer: NonZero::new(ptr), _marker: PhantomData } Shared { pointer: NonZero::new(ptr), _marker: PhantomData }
} }
} }
#[unstable(feature = "shared", issue = "27730")]
impl<T: ?Sized> Shared<T> {
/// Acquires the underlying pointer as a `*mut` pointer.
pub unsafe fn as_mut_ptr(&self) -> *mut T {
**self as _
}
}
#[unstable(feature = "shared", issue = "27730")] #[unstable(feature = "shared", issue = "27730")]
impl<T: ?Sized> Clone for Shared<T> { impl<T: ?Sized> Clone for Shared<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
@ -992,10 +995,10 @@ impl<T: ?Sized, U: ?Sized> CoerceUnsized<Shared<U>> for Shared<T> where T: Unsiz
#[unstable(feature = "shared", issue = "27730")] #[unstable(feature = "shared", issue = "27730")]
impl<T: ?Sized> Deref for Shared<T> { impl<T: ?Sized> Deref for Shared<T> {
type Target = *mut T; type Target = *const T;
#[inline] #[inline]
fn deref(&self) -> &*mut T { fn deref(&self) -> &*const T {
unsafe { mem::transmute(&*self.pointer) } unsafe { mem::transmute(&*self.pointer) }
} }
} }

View file

@ -803,12 +803,11 @@ impl<T: fmt::Debug, E> Result<T, E> {
/// Basic usage: /// Basic usage:
/// ///
/// ```{.should_panic} /// ```{.should_panic}
/// # #![feature(result_expect_err)]
/// let x: Result<u32, &str> = Ok(10); /// let x: Result<u32, &str> = Ok(10);
/// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10` /// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "result_expect_err", issue = "39041")] #[stable(feature = "result_expect_err", since = "1.17.0")]
pub fn expect_err(self, msg: &str) -> E { pub fn expect_err(self, msg: &str) -> E {
match self { match self {
Ok(t) => unwrap_failed(msg, t), Ok(t) => unwrap_failed(msg, t),

View file

@ -23,7 +23,6 @@
#![feature(nonzero)] #![feature(nonzero)]
#![feature(rand)] #![feature(rand)]
#![feature(raw)] #![feature(raw)]
#![feature(result_expect_err)]
#![feature(sip_hash_13)] #![feature(sip_hash_13)]
#![feature(slice_patterns)] #![feature(slice_patterns)]
#![feature(step_by)] #![feature(step_by)]
@ -31,9 +30,6 @@
#![feature(try_from)] #![feature(try_from)]
#![feature(unicode)] #![feature(unicode)]
#![feature(unique)] #![feature(unique)]
#![feature(ordering_chaining)]
#![feature(ptr_unaligned)]
#![feature(move_cell)]
#![feature(fmt_internals)] #![feature(fmt_internals)]
extern crate core; extern crate core;

View file

@ -248,7 +248,7 @@ impl<'a, A: Array> Drop for Drain<'a, A> {
if self.tail_len > 0 { if self.tail_len > 0 {
unsafe { unsafe {
let source_array_vec = &mut **self.array_vec; let source_array_vec = &mut *self.array_vec.as_mut_ptr();
// memmove back untouched tail, update to new length // memmove back untouched tail, update to new length
let start = source_array_vec.len(); let start = source_array_vec.len();
let tail = self.tail_start; let tail = self.tail_start;
@ -317,4 +317,3 @@ impl<T> Default for ManuallyDrop<T> {
ManuallyDrop::new() ManuallyDrop::new()
} }
} }

View file

@ -27,7 +27,6 @@
#![feature(shared)] #![feature(shared)]
#![feature(collections_range)] #![feature(collections_range)]
#![feature(collections_bound)]
#![cfg_attr(stage0,feature(field_init_shorthand))] #![cfg_attr(stage0,feature(field_init_shorthand))]
#![feature(nonzero)] #![feature(nonzero)]
#![feature(rustc_private)] #![feature(rustc_private)]

View file

@ -1154,7 +1154,7 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
fn next(&mut self) -> Option<(SafeHash, K, V)> { fn next(&mut self) -> Option<(SafeHash, K, V)> {
self.iter.next().map(|bucket| { self.iter.next().map(|bucket| {
unsafe { unsafe {
(**self.table).size -= 1; (*self.table.as_mut_ptr()).size -= 1;
let (k, v) = ptr::read(bucket.pair); let (k, v) = ptr::read(bucket.pair);
(SafeHash { hash: ptr::replace(bucket.hash, EMPTY_BUCKET) }, k, v) (SafeHash { hash: ptr::replace(bucket.hash, EMPTY_BUCKET) }, k, v)
} }

View file

@ -245,7 +245,6 @@
#![feature(char_escape_debug)] #![feature(char_escape_debug)]
#![feature(char_internals)] #![feature(char_internals)]
#![feature(collections)] #![feature(collections)]
#![feature(collections_bound)]
#![feature(collections_range)] #![feature(collections_range)]
#![feature(compiler_builtins_lib)] #![feature(compiler_builtins_lib)]
#![feature(const_fn)] #![feature(const_fn)]

View file

@ -1032,7 +1032,7 @@ pub fn exit(code: i32) -> ! {
/// will be run. If a clean shutdown is needed it is recommended to only call /// will be run. If a clean shutdown is needed it is recommended to only call
/// this function at a known point where there are no more destructors left /// this function at a known point where there are no more destructors left
/// to run. /// to run.
#[unstable(feature = "process_abort", issue = "37838")] #[stable(feature = "process_abort", since = "1.17.0")]
pub fn abort() -> ! { pub fn abort() -> ! {
unsafe { ::sys::abort_internal() }; unsafe { ::sys::abort_internal() };
} }