Skip to content

Commit

Permalink
Auto merge of #50017 - tinaun:stabilize-all-the-things, r=sfackler
Browse files Browse the repository at this point in the history
stabilize a bunch of minor api additions

besides `ptr::NonNull::cast` (which is 4 days away from end of FCP) all of these have been finished with FCP for a few weeks now with minimal issues raised

* Closes #41020
* Closes #42818
* Closes #44030
* Closes #44400
* Closes #46507
* Closes #47653
* Closes #46344

the following functions will be stabilized in 1.27:
* `[T]::rsplit`
* `[T]::rsplit_mut`
* `[T]::swap_with_slice`
* `ptr::swap_nonoverlapping`
* `NonNull::cast`
* `Duration::from_micros`
* `Duration::from_nanos`
* `Duration::subsec_millis`
* `Duration::subsec_micros`
* `HashMap::remove_entry`
  • Loading branch information
bors committed Apr 18, 2018
2 parents c8fa49f + fd042ee commit ac3c228
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 59 deletions.
10 changes: 0 additions & 10 deletions src/doc/unstable-book/src/library-features/slice-rsplit.md

This file was deleted.

4 changes: 1 addition & 3 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
#![feature(lang_items)]
#![feature(libc)]
#![feature(needs_allocator)]
#![feature(nonnull_cast)]
#![feature(nonzero)]
#![feature(optin_builtin_traits)]
#![feature(pattern)]
Expand All @@ -108,7 +107,6 @@
#![feature(ptr_offset_from)]
#![feature(rustc_attrs)]
#![feature(slice_get_slice)]
#![feature(slice_rsplit)]
#![feature(specialization)]
#![feature(staged_api)]
#![feature(str_internals)]
Expand All @@ -124,7 +122,7 @@
#![feature(inclusive_range_fields)]
#![cfg_attr(stage0, feature(generic_param_attrs))]

#![cfg_attr(not(test), feature(fn_traits, swap_with_slice, i128))]
#![cfg_attr(not(test), feature(fn_traits, i128))]
#![cfg_attr(test, feature(test))]

// Allow testing this library
Expand Down
19 changes: 4 additions & 15 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub use core::slice::{Iter, IterMut};
pub use core::slice::{SplitMut, ChunksMut, Split};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
pub use core::slice::{RSplit, RSplitMut};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
Expand Down Expand Up @@ -888,7 +888,6 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(slice_rsplit)]
///
/// let slice = [11, 22, 33, 0, 44, 55];
/// let mut iter = slice.rsplit(|num| *num == 0);
Expand All @@ -902,8 +901,6 @@ impl<T> [T] {
/// slice will be the first (or last) item returned by the iterator.
///
/// ```
/// #![feature(slice_rsplit)]
///
/// let v = &[0, 1, 1, 2, 3, 5, 8];
/// let mut it = v.rsplit(|n| *n % 2 == 0);
/// assert_eq!(it.next().unwrap(), &[]);
Expand All @@ -912,7 +909,7 @@ impl<T> [T] {
/// assert_eq!(it.next().unwrap(), &[]);
/// assert_eq!(it.next(), None);
/// ```
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
#[inline]
pub fn rsplit<F>(&self, pred: F) -> RSplit<T, F>
where F: FnMut(&T) -> bool
Expand All @@ -927,8 +924,6 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(slice_rsplit)]
///
/// let mut v = [100, 400, 300, 200, 600, 500];
///
/// let mut count = 0;
Expand All @@ -939,7 +934,7 @@ impl<T> [T] {
/// assert_eq!(v, [3, 400, 300, 2, 600, 1]);
/// ```
///
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
#[inline]
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<T, F>
where F: FnMut(&T) -> bool
Expand Down Expand Up @@ -1707,8 +1702,6 @@ impl<T> [T] {
/// Swapping two elements across slices:
///
/// ```
/// #![feature(swap_with_slice)]
///
/// let mut slice1 = [0, 0];
/// let mut slice2 = [1, 2, 3, 4];
///
Expand All @@ -1724,8 +1717,6 @@ impl<T> [T] {
/// a compile failure:
///
/// ```compile_fail
/// #![feature(swap_with_slice)]
///
/// let mut slice = [1, 2, 3, 4, 5];
/// slice[..2].swap_with_slice(&mut slice[3..]); // compile fail!
/// ```
Expand All @@ -1734,8 +1725,6 @@ impl<T> [T] {
/// mutable sub-slices from a slice:
///
/// ```
/// #![feature(swap_with_slice)]
///
/// let mut slice = [1, 2, 3, 4, 5];
///
/// {
Expand All @@ -1747,7 +1736,7 @@ impl<T> [T] {
/// ```
///
/// [`split_at_mut`]: #method.split_at_mut
#[unstable(feature = "swap_with_slice", issue = "44030")]
#[stable(feature = "swap_with_slice", since = "1.27.0")]
pub fn swap_with_slice(&mut self, other: &mut [T]) {
core_slice::SliceExt::swap_with_slice(self, other)
}
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
/// Basic usage:
///
/// ```
/// #![feature(swap_nonoverlapping)]
///
/// use std::ptr;
///
/// let mut x = [1, 2, 3, 4];
Expand All @@ -181,7 +179,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
/// assert_eq!(y, [1, 2, 9]);
/// ```
#[inline]
#[unstable(feature = "swap_nonoverlapping", issue = "42818")]
#[stable(feature = "swap_nonoverlapping", since = "1.27.0")]
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut u8;
let y = y as *mut u8;
Expand Down Expand Up @@ -2744,7 +2742,7 @@ impl<T: ?Sized> NonNull<T> {
}

/// Cast to a pointer of another type
#[unstable(feature = "nonnull_cast", issue = "47653")]
#[stable(feature = "nonnull_cast", since = "1.27.0")]
pub fn cast<U>(self) -> NonNull<U> {
unsafe {
NonNull::new_unchecked(self.as_ptr() as *mut U)
Expand Down
30 changes: 15 additions & 15 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub trait SliceExt {
fn split<P>(&self, pred: P) -> Split<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
fn rsplit<P>(&self, pred: P) -> RSplit<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;

Expand Down Expand Up @@ -169,7 +169,7 @@ pub trait SliceExt {
fn split_mut<P>(&mut self, pred: P) -> SplitMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
fn rsplit_mut<P>(&mut self, pred: P) -> RSplitMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;

Expand Down Expand Up @@ -223,7 +223,7 @@ pub trait SliceExt {
#[stable(feature = "copy_from_slice", since = "1.9.0")]
fn copy_from_slice(&mut self, src: &[Self::Item]) where Self::Item: Copy;

#[unstable(feature = "swap_with_slice", issue = "44030")]
#[stable(feature = "swap_with_slice", since = "1.27.0")]
fn swap_with_slice(&mut self, src: &mut [Self::Item]);

#[stable(feature = "sort_unstable", since = "1.20.0")]
Expand Down Expand Up @@ -1840,13 +1840,13 @@ impl<'a, T, P> FusedIterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
///
/// [`rsplit`]: ../../std/primitive.slice.html#method.rsplit
/// [slices]: ../../std/primitive.slice.html
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
#[derive(Clone)] // Is this correct, or does it incorrectly require `T: Clone`?
pub struct RSplit<'a, T:'a, P> where P: FnMut(&T) -> bool {
inner: Split<'a, T, P>
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RSplit")
Expand All @@ -1856,7 +1856,7 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
type Item = &'a [T];

Expand All @@ -1871,23 +1871,23 @@ impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> DoubleEndedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
#[inline]
fn next_back(&mut self) -> Option<&'a [T]> {
self.inner.next()
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
#[inline]
fn finish(&mut self) -> Option<&'a [T]> {
self.inner.finish()
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {}

/// An iterator over the subslices of the vector which are separated
Expand All @@ -1897,12 +1897,12 @@ impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {}
///
/// [`rsplit_mut`]: ../../std/primitive.slice.html#method.rsplit_mut
/// [slices]: ../../std/primitive.slice.html
#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
pub struct RSplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool {
inner: SplitMut<'a, T, P>
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RSplitMut")
Expand All @@ -1912,15 +1912,15 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMu
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> SplitIter for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
#[inline]
fn finish(&mut self) -> Option<&'a mut [T]> {
self.inner.finish()
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
type Item = &'a mut [T];

Expand All @@ -1935,7 +1935,7 @@ impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where
P: FnMut(&T) -> bool,
{
Expand All @@ -1945,7 +1945,7 @@ impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where
}
}

#[unstable(feature = "slice_rsplit", issue = "41020")]
#[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> FusedIterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {}

/// An private iterator over subslices separated by elements that
Expand Down
12 changes: 4 additions & 8 deletions src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,14 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_from_micros)]
/// use std::time::Duration;
///
/// let duration = Duration::from_micros(1_000_002);
///
/// assert_eq!(1, duration.as_secs());
/// assert_eq!(2000, duration.subsec_nanos());
/// ```
#[unstable(feature = "duration_from_micros", issue = "44400")]
#[stable(feature = "duration_from_micros", since = "1.27.0")]
#[inline]
pub const fn from_micros(micros: u64) -> Duration {
Duration {
Expand All @@ -159,15 +158,14 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_extras)]
/// use std::time::Duration;
///
/// let duration = Duration::from_nanos(1_000_000_123);
///
/// assert_eq!(1, duration.as_secs());
/// assert_eq!(123, duration.subsec_nanos());
/// ```
#[unstable(feature = "duration_extras", issue = "46507")]
#[stable(feature = "duration_extras", since = "1.27.0")]
#[inline]
pub const fn from_nanos(nanos: u64) -> Duration {
Duration {
Expand Down Expand Up @@ -217,14 +215,13 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_extras)]
/// use std::time::Duration;
///
/// let duration = Duration::from_millis(5432);
/// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_millis(), 432);
/// ```
#[unstable(feature = "duration_extras", issue = "46507")]
#[stable(feature = "duration_extras", since = "1.27.0")]
#[inline]
pub fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI }

Expand All @@ -237,14 +234,13 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_extras, duration_from_micros)]
/// use std::time::Duration;
///
/// let duration = Duration::from_micros(1_234_567);
/// assert_eq!(duration.as_secs(), 1);
/// assert_eq!(duration.subsec_micros(), 234_567);
/// ```
#[unstable(feature = "duration_extras", issue = "46507")]
#[stable(feature = "duration_extras", since = "1.27.0")]
#[inline]
pub fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO }

Expand Down
3 changes: 1 addition & 2 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,6 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// #![feature(hash_map_remove_entry)]
/// use std::collections::HashMap;
///
/// # fn main() {
Expand All @@ -1389,7 +1388,7 @@ impl<K, V, S> HashMap<K, V, S>
/// assert_eq!(map.remove(&1), None);
/// # }
/// ```
#[unstable(feature = "hash_map_remove_entry", issue = "46344")]
#[stable(feature = "hash_map_remove_entry", since = "1.27.0")]
pub fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(K, V)>
where K: Borrow<Q>,
Q: Hash + Eq
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@
#![feature(macro_reexport)]
#![feature(macro_vis_matcher)]
#![feature(needs_panic_runtime)]
#![feature(nonnull_cast)]
#![feature(exhaustive_patterns)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/realloc-16687.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Ideally this would be revised to use no_std, but for now it serves
// well enough to reproduce (and illustrate) the bug from #16687.

#![feature(heap_api, allocator_api, nonnull_cast)]
#![feature(heap_api, allocator_api)]

use std::alloc::{Global, Alloc, Layout};
use std::ptr::{self, NonNull};
Expand Down

0 comments on commit ac3c228

Please sign in to comment.