Skip to content

Stabilize feature sort_unstable #43010

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

Merged
merged 4 commits into from Jul 3, 2017
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
40 changes: 0 additions & 40 deletions src/doc/unstable-book/src/library-features/sort-unstable.md

This file was deleted.

1 change: 0 additions & 1 deletion src/liballoc/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#![feature(rand)]
#![feature(repr_simd)]
#![feature(slice_rotate)]
#![feature(sort_unstable)]
#![feature(test)]

extern crate test;
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
#![cfg_attr(not(test), feature(core_float))]
#![cfg_attr(not(test), feature(exact_size_is_empty))]
#![cfg_attr(not(test), feature(slice_rotate))]
#![cfg_attr(not(test), feature(sort_unstable))]
#![cfg_attr(not(test), feature(str_checked_slicing))]
#![cfg_attr(test, feature(rand, test))]
#![feature(allocator)]
Expand Down
27 changes: 15 additions & 12 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,10 @@ impl<T> [T] {
///
/// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
///
/// When applicable, unstable sorting is preferred because it is generally faster than stable
/// sorting and it doesn't allocate auxiliary memory.
/// See [`sort_unstable`](#method.sort_unstable).
///
/// # Current implementation
///
/// The current algorithm is an adaptive, iterative merge sort inspired by
Expand Down Expand Up @@ -1174,6 +1178,10 @@ impl<T> [T] {
///
/// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
///
/// When applicable, unstable sorting is preferred because it is generally faster than stable
/// sorting and it doesn't allocate auxiliary memory.
/// See [`sort_unstable_by`](#method.sort_unstable_by).
///
/// # Current implementation
///
/// The current algorithm is an adaptive, iterative merge sort inspired by
Expand Down Expand Up @@ -1207,6 +1215,10 @@ impl<T> [T] {
///
/// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
///
/// When applicable, unstable sorting is preferred because it is generally faster than stable
/// sorting and it doesn't allocate auxiliary memory.
/// See [`sort_unstable_by_key`](#method.sort_unstable_by_key).
///
/// # Current implementation
///
/// The current algorithm is an adaptive, iterative merge sort inspired by
Expand Down Expand Up @@ -1251,17 +1263,14 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(sort_unstable)]
///
/// let mut v = [-5, 4, 1, -3, 2];
///
/// v.sort_unstable();
/// assert!(v == [-5, -3, 1, 2, 4]);
/// ```
///
/// [pdqsort]: https://github.com/orlp/pdqsort
// FIXME #40585: Mention `sort_unstable` in the documentation for `sort`.
#[unstable(feature = "sort_unstable", issue = "40585")]
#[stable(feature = "sort_unstable", since = "1.20.0")]
#[inline]
pub fn sort_unstable(&mut self)
where T: Ord
Expand All @@ -1288,8 +1297,6 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(sort_unstable)]
///
/// let mut v = [5, 4, 1, 3, 2];
/// v.sort_unstable_by(|a, b| a.cmp(b));
/// assert!(v == [1, 2, 3, 4, 5]);
Expand All @@ -1300,8 +1307,7 @@ impl<T> [T] {
/// ```
///
/// [pdqsort]: https://github.com/orlp/pdqsort
// FIXME #40585: Mention `sort_unstable_by` in the documentation for `sort_by`.
#[unstable(feature = "sort_unstable", issue = "40585")]
#[stable(feature = "sort_unstable", since = "1.20.0")]
#[inline]
pub fn sort_unstable_by<F>(&mut self, compare: F)
where F: FnMut(&T, &T) -> Ordering
Expand All @@ -1328,17 +1334,14 @@ impl<T> [T] {
/// # Examples
///
/// ```
/// #![feature(sort_unstable)]
///
/// let mut v = [-5i32, 4, 1, -3, 2];
///
/// v.sort_unstable_by_key(|k| k.abs());
/// assert!(v == [1, 2, -3, 4, -5]);
/// ```
///
/// [pdqsort]: https://github.com/orlp/pdqsort
// FIXME #40585: Mention `sort_unstable_by_key` in the documentation for `sort_by_key`.
#[unstable(feature = "sort_unstable", issue = "40585")]
#[stable(feature = "sort_unstable", since = "1.20.0")]
#[inline]
pub fn sort_unstable_by_key<B, F>(&mut self, f: F)
where F: FnMut(&T) -> B,
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ 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 = "sort_unstable", issue = "40585")]
#[stable(feature = "sort_unstable", since = "1.20.0")]
fn sort_unstable(&mut self)
where Self::Item: Ord;

#[unstable(feature = "sort_unstable", issue = "40585")]
#[stable(feature = "sort_unstable", since = "1.20.0")]
fn sort_unstable_by<F>(&mut self, compare: F)
where F: FnMut(&Self::Item, &Self::Item) -> Ordering;

#[unstable(feature = "sort_unstable", issue = "40585")]
#[stable(feature = "sort_unstable", since = "1.20.0")]
fn sort_unstable_by_key<B, F>(&mut self, f: F)
where F: FnMut(&Self::Item) -> B,
B: Ord;
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize

if start_l < end_l {
// The left block remains.
// Move it's remaining out-of-order elements to the far right.
// Move its remaining out-of-order elements to the far right.
debug_assert_eq!(width(l, r), block_l);
while start_l < end_l {
unsafe {
Expand All @@ -363,7 +363,7 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
width(v.as_mut_ptr(), r)
} else if start_r < end_r {
// The right block remains.
// Move it's remaining out-of-order elements to the far left.
// Move its remaining out-of-order elements to the far left.
debug_assert_eq!(width(l, r), block_r);
while start_r < end_r {
unsafe {
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#![feature(slice_patterns)]
#![feature(slice_rotate)]
#![feature(sort_internals)]
#![feature(sort_unstable)]
#![feature(specialization)]
#![feature(step_by)]
#![feature(step_trait)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#![feature(specialization)]
#![feature(unboxed_closures)]
#![feature(discriminant_value)]
#![feature(sort_unstable)]
#![feature(trace_macros)]
#![feature(test)]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#![feature(rand)]
#![feature(conservative_impl_trait)]
#![feature(sort_unstable)]

extern crate graphviz;
#[macro_use] extern crate rustc;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#![feature(specialization)]
#![feature(discriminant_value)]
#![feature(rustc_private)]
#![feature(sort_unstable)]

#[macro_use]
extern crate log;
Expand Down