Skip to content

Commit c4b1638

Browse files
committed
Auto merge of #30187 - alexcrichton:stabilize-1.6, r=aturon
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2 parents bf79ffa + 464cdff commit c4b1638

File tree

165 files changed

+712
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+712
-718
lines changed

src/compiletest/compiletest.rs

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#![feature(rustc_private)]
1717
#![feature(str_char)]
1818
#![feature(test)]
19-
#![feature(vec_push_all)]
20-
#![feature(path_components_peek)]
2119

2220
#![deny(warnings)]
2321

src/compiletest/runtest.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1009,15 +1009,12 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>,
10091009
}
10101010
}
10111011

1012-
fn is_compiler_error_or_warning(mut line: &str) -> bool {
1013-
// Remove initial prefix which may contain a colon
1014-
let mut components = Path::new(line).components();
1015-
if let Some(Component::Prefix(_)) = components.peek() {
1016-
components.next();
1017-
}
1018-
1019-
// Safe as path was originally constructed from a &str ^
1020-
line = components.as_path().to_str().unwrap();
1012+
fn is_compiler_error_or_warning(line: &str) -> bool {
1013+
let mut c = Path::new(line).components();
1014+
let line = match c.next() {
1015+
Some(Component::Prefix(_)) => c.as_path().to_str().unwrap(),
1016+
_ => line,
1017+
};
10211018

10221019
let mut i = 0;
10231020
return
@@ -1314,7 +1311,7 @@ fn make_compile_args<F>(config: &Config,
13141311
"-L".to_owned(),
13151312
config.build_base.to_str().unwrap().to_owned(),
13161313
format!("--target={}", target));
1317-
args.push_all(&extras);
1314+
args.extend_from_slice(&extras);
13181315
if !props.no_prefer_dynamic {
13191316
args.push("-C".to_owned());
13201317
args.push("prefer-dynamic".to_owned());

src/doc/book/custom-allocators.md

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ annotated version of `alloc_system`
8383
// Allocators are not allowed to depend on the standard library which in turn
8484
// requires an allocator in order to avoid circular dependencies. This crate,
8585
// however, can use all of libcore.
86-
#![feature(no_std)]
8786
#![no_std]
8887
8988
// Let's give a unique name to our custom allocator

src/doc/book/lang-items.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and one for deallocation. A freestanding program that uses the `Box`
1616
sugar for dynamic allocations via `malloc` and `free`:
1717

1818
```rust
19-
#![feature(lang_items, box_syntax, start, no_std, libc)]
19+
#![feature(lang_items, box_syntax, start, libc)]
2020
#![no_std]
2121

2222
extern crate libc;

src/doc/book/no-stdlib.md

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ in the same format as C:
1616
# #![feature(libc)]
1717
#![feature(lang_items)]
1818
#![feature(start)]
19-
#![feature(no_std)]
2019
#![no_std]
2120

2221
// Pull in the system libc library for what crt0.o likely requires
@@ -46,7 +45,6 @@ compiler's name mangling too:
4645

4746
```rust
4847
# #![feature(libc)]
49-
#![feature(no_std)]
5048
#![feature(lang_items)]
5149
#![feature(start)]
5250
#![no_std]
@@ -104,9 +102,6 @@ vectors provided from C, using idiomatic Rust practices.
104102
# #![feature(libc)]
105103
#![feature(lang_items)]
106104
#![feature(start)]
107-
#![feature(no_std)]
108-
#![feature(core)]
109-
#![feature(core_slice_ext)]
110105
#![feature(raw)]
111106
#![no_std]
112107

src/etc/unicode.py

-3
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ def emit_bsearch_range_table(f):
315315
f.write("""
316316
fn bsearch_range_table(c: char, r: &'static [(char, char)]) -> bool {
317317
use core::cmp::Ordering::{Equal, Less, Greater};
318-
use core::slice::SliceExt;
319318
r.binary_search_by(|&(lo, hi)| {
320319
if lo <= c && c <= hi {
321320
Equal
@@ -358,7 +357,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
358357
f.write("pub mod conversions {")
359358
f.write("""
360359
use core::cmp::Ordering::{Equal, Less, Greater};
361-
use core::slice::SliceExt;
362360
use core::option::Option;
363361
use core::option::Option::{Some, None};
364362
use core::result::Result::{Ok, Err};
@@ -404,7 +402,6 @@ def emit_charwidth_module(f, width_table):
404402
f.write("pub mod charwidth {\n")
405403
f.write(" use core::option::Option;\n")
406404
f.write(" use core::option::Option::{Some, None};\n")
407-
f.write(" use core::slice::SliceExt;\n")
408405
f.write(" use core::result::Result::{Ok, Err};\n")
409406
f.write("""
410407
fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {

src/liballoc/boxed.rs

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub struct ExchangeHeapSingleton {
104104
/// See the [module-level documentation](../../std/boxed/index.html) for more.
105105
#[lang = "owned_box"]
106106
#[stable(feature = "rust1", since = "1.0.0")]
107-
#[fundamental]
108107
pub struct Box<T: ?Sized>(Unique<T>);
109108

110109
/// `IntermediateBox` represents uninitialized backing storage for `Box`.

src/liballoc/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,15 @@
7575
#![cfg_attr(not(stage0), needs_allocator)]
7676

7777
#![cfg_attr(stage0, feature(rustc_attrs))]
78+
#![cfg_attr(stage0, feature(no_std))]
7879
#![cfg_attr(stage0, allow(unused_attributes))]
7980
#![feature(allocator)]
8081
#![feature(box_syntax)]
8182
#![feature(coerce_unsized)]
82-
#![feature(core)]
8383
#![feature(core_intrinsics)]
84-
#![feature(core_slice_ext)]
8584
#![feature(custom_attribute)]
8685
#![feature(fundamental)]
8786
#![feature(lang_items)]
88-
#![feature(no_std)]
8987
#![feature(nonzero)]
9088
#![feature(num_bits_bytes)]
9189
#![feature(optin_builtin_traits)]
@@ -103,9 +101,8 @@
103101
#![allow(unused_attributes)]
104102
#![feature(dropck_parametricity)]
105103
#![feature(unsize)]
106-
#![feature(core_slice_ext)]
107-
#![feature(core_str_ext)]
108104
#![feature(drop_in_place)]
105+
#![feature(fn_traits)]
109106

110107
#![cfg_attr(stage0, feature(alloc_system))]
111108
#![cfg_attr(not(stage0), feature(needs_allocator))]

src/liballoc/raw_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use core::ptr::Unique;
1212
use core::mem;
13-
use core::slice::{self, SliceExt};
13+
use core::slice;
1414
use heap;
1515
use super::oom;
1616
use super::boxed::Box;

src/liballoc_jemalloc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
issue = "27783")]
2222
#![feature(allocator)]
2323
#![feature(libc)]
24-
#![feature(no_std)]
2524
#![feature(staged_api)]
25+
#![cfg_attr(stage0, feature(no_std))]
2626

2727
extern crate libc;
2828

src/liballoc_system/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
issue = "27783")]
2222
#![feature(allocator)]
2323
#![feature(libc)]
24-
#![feature(no_std)]
2524
#![feature(staged_api)]
25+
#![cfg_attr(stage0, feature(no_std))]
2626

2727
extern crate libc;
2828

src/libcollections/binary_heap.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,7 @@ impl<T: Ord> BinaryHeap<T> {
581581
///
582582
/// The elements are removed in arbitrary order.
583583
#[inline]
584-
#[unstable(feature = "drain",
585-
reason = "matches collection reform specification, \
586-
waiting for dust to settle",
587-
issue = "27711")]
584+
#[stable(feature = "drain", since = "1.6.0")]
588585
pub fn drain(&mut self) -> Drain<T> {
589586
Drain { iter: self.data.drain(..) }
590587
}
@@ -738,7 +735,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
738735
impl<T> ExactSizeIterator for IntoIter<T> {}
739736

740737
/// An iterator that drains a `BinaryHeap`.
741-
#[unstable(feature = "drain", reason = "recent addition", issue = "27711")]
738+
#[stable(feature = "drain", since = "1.6.0")]
742739
pub struct Drain<'a, T: 'a> {
743740
iter: vec::Drain<'a, T>,
744741
}

src/libcollections/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
#![feature(box_patterns)]
4444
#![feature(box_syntax)]
4545
#![feature(core_intrinsics)]
46-
#![feature(core_slice_ext)]
47-
#![feature(core_str_ext)]
4846
#![feature(fmt_internals)]
4947
#![feature(fmt_radix)]
5048
#![feature(heap_api)]
@@ -68,9 +66,10 @@
6866
#![feature(unsafe_no_drop_flag, filling_drop)]
6967
#![feature(decode_utf16)]
7068
#![feature(drop_in_place)]
69+
#![feature(clone_from_slice)]
7170
#![cfg_attr(test, feature(clone_from_slice, rand, test))]
7271

73-
#![feature(no_std)]
72+
#![cfg_attr(stage0, feature(no_std))]
7473
#![no_std]
7574

7675
extern crate rustc_unicode;

src/libcollections/slice.rs

+30-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mod hack {
160160
where T: Clone
161161
{
162162
let mut vector = Vec::with_capacity(s.len());
163-
vector.push_all(s);
163+
vector.extend_from_slice(s);
164164
vector
165165
}
166166
}
@@ -777,6 +777,33 @@ impl<T> [T] {
777777
self.sort_by(|a, b| a.cmp(b))
778778
}
779779

780+
/// Sorts the slice, in place, using `key` to extract a key by which to
781+
/// order the sort by.
782+
///
783+
/// This sort is `O(n log n)` worst-case and stable, but allocates
784+
/// approximately `2 * n`, where `n` is the length of `self`.
785+
///
786+
/// This is a stable sort.
787+
///
788+
/// # Examples
789+
///
790+
/// ```rust
791+
/// #![feature(slice_sort_by_key)]
792+
///
793+
/// let mut v = [-5i32, 4, 1, -3, 2];
794+
///
795+
/// v.sort_by_key(|k| k.abs());
796+
/// assert!(v == [1, 2, -3, 4, -5]);
797+
/// ```
798+
#[unstable(feature = "slice_sort_by_key", reason = "recently added",
799+
issue = "27724")]
800+
#[inline]
801+
pub fn sort_by_key<B, F>(&mut self, mut f: F)
802+
where F: FnMut(&T) -> B, B: Ord
803+
{
804+
self.sort_by(|a, b| f(a).cmp(&f(b)))
805+
}
806+
780807
/// Sorts the slice, in place, using `compare` to compare
781808
/// elements.
782809
///
@@ -906,7 +933,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
906933
let size = self.iter().fold(0, |acc, v| acc + v.borrow().len());
907934
let mut result = Vec::with_capacity(size);
908935
for v in self {
909-
result.push_all(v.borrow())
936+
result.extend_from_slice(v.borrow())
910937
}
911938
result
912939
}
@@ -921,7 +948,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
921948
} else {
922949
result.push(sep.clone())
923950
}
924-
result.push_all(v.borrow())
951+
result.extend_from_slice(v.borrow())
925952
}
926953
result
927954
}

src/libcollections/string.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl String {
482482
let mut res = String::with_capacity(total);
483483

484484
if i > 0 {
485-
unsafe { res.as_mut_vec().push_all(&v[..i]) };
485+
unsafe { res.as_mut_vec().extend_from_slice(&v[..i]) };
486486
}
487487

488488
// subseqidx is the index of the first byte of the subsequence we're
@@ -498,10 +498,10 @@ impl String {
498498
macro_rules! error { () => ({
499499
unsafe {
500500
if subseqidx != i_ {
501-
res.as_mut_vec().push_all(&v[subseqidx..i_]);
501+
res.as_mut_vec().extend_from_slice(&v[subseqidx..i_]);
502502
}
503503
subseqidx = i;
504-
res.as_mut_vec().push_all(REPLACEMENT);
504+
res.as_mut_vec().extend_from_slice(REPLACEMENT);
505505
}
506506
})}
507507

@@ -566,7 +566,7 @@ impl String {
566566
}
567567
}
568568
if subseqidx < total {
569-
unsafe { res.as_mut_vec().push_all(&v[subseqidx..total]) };
569+
unsafe { res.as_mut_vec().extend_from_slice(&v[subseqidx..total]) };
570570
}
571571
Cow::Owned(res)
572572
}
@@ -699,7 +699,7 @@ impl String {
699699
#[inline]
700700
#[stable(feature = "rust1", since = "1.0.0")]
701701
pub fn push_str(&mut self, string: &str) {
702-
self.vec.push_all(string.as_bytes())
702+
self.vec.extend_from_slice(string.as_bytes())
703703
}
704704

705705
/// Returns the number of bytes that this string buffer can hold without
@@ -1026,8 +1026,6 @@ impl String {
10261026
/// # Examples
10271027
///
10281028
/// ```
1029-
/// #![feature(drain)]
1030-
///
10311029
/// let mut s = String::from("α is alpha, β is beta");
10321030
/// let beta_offset = s.find('β').unwrap_or(s.len());
10331031
///
@@ -1040,9 +1038,7 @@ impl String {
10401038
/// s.drain(..);
10411039
/// assert_eq!(s, "");
10421040
/// ```
1043-
#[unstable(feature = "drain",
1044-
reason = "recently added, matches RFC",
1045-
issue = "27711")]
1041+
#[stable(feature = "drain", since = "1.6.0")]
10461042
pub fn drain<R>(&mut self, range: R) -> Drain
10471043
where R: RangeArgument<usize>
10481044
{
@@ -1600,7 +1596,7 @@ impl fmt::Write for String {
16001596
}
16011597

16021598
/// A draining iterator for `String`.
1603-
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
1599+
#[stable(feature = "drain", since = "1.6.0")]
16041600
pub struct Drain<'a> {
16051601
/// Will be used as &'a mut String in the destructor
16061602
string: *mut String,
@@ -1612,12 +1608,12 @@ pub struct Drain<'a> {
16121608
iter: Chars<'a>,
16131609
}
16141610

1615-
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
1611+
#[stable(feature = "drain", since = "1.6.0")]
16161612
unsafe impl<'a> Sync for Drain<'a> {}
1617-
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
1613+
#[stable(feature = "drain", since = "1.6.0")]
16181614
unsafe impl<'a> Send for Drain<'a> {}
16191615

1620-
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
1616+
#[stable(feature = "drain", since = "1.6.0")]
16211617
impl<'a> Drop for Drain<'a> {
16221618
fn drop(&mut self) {
16231619
unsafe {
@@ -1631,7 +1627,7 @@ impl<'a> Drop for Drain<'a> {
16311627
}
16321628
}
16331629

1634-
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
1630+
#[stable(feature = "drain", since = "1.6.0")]
16351631
impl<'a> Iterator for Drain<'a> {
16361632
type Item = char;
16371633

@@ -1645,7 +1641,7 @@ impl<'a> Iterator for Drain<'a> {
16451641
}
16461642
}
16471643

1648-
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
1644+
#[stable(feature = "drain", since = "1.6.0")]
16491645
impl<'a> DoubleEndedIterator for Drain<'a> {
16501646
#[inline]
16511647
fn next_back(&mut self) -> Option<char> {

0 commit comments

Comments
 (0)