diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index dfd99a9beae..da8331fc062 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -16,8 +16,6 @@ #![feature(rustc_private)] #![feature(str_char)] #![feature(test)] -#![feature(vec_push_all)] -#![feature(path_components_peek)] #![deny(warnings)] diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 833ab553a13..1b1f5115b60 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1009,15 +1009,12 @@ fn check_expected_errors(expected_errors: Vec, } } -fn is_compiler_error_or_warning(mut line: &str) -> bool { - // Remove initial prefix which may contain a colon - let mut components = Path::new(line).components(); - if let Some(Component::Prefix(_)) = components.peek() { - components.next(); - } - - // Safe as path was originally constructed from a &str ^ - line = components.as_path().to_str().unwrap(); +fn is_compiler_error_or_warning(line: &str) -> bool { + let mut c = Path::new(line).components(); + let line = match c.next() { + Some(Component::Prefix(_)) => c.as_path().to_str().unwrap(), + _ => line, + }; let mut i = 0; return @@ -1314,7 +1311,7 @@ fn make_compile_args(config: &Config, "-L".to_owned(), config.build_base.to_str().unwrap().to_owned(), format!("--target={}", target)); - args.push_all(&extras); + args.extend_from_slice(&extras); if !props.no_prefer_dynamic { args.push("-C".to_owned()); args.push("prefer-dynamic".to_owned()); diff --git a/src/doc/book/custom-allocators.md b/src/doc/book/custom-allocators.md index 6b19abc728c..65626c11462 100644 --- a/src/doc/book/custom-allocators.md +++ b/src/doc/book/custom-allocators.md @@ -83,7 +83,6 @@ annotated version of `alloc_system` // Allocators are not allowed to depend on the standard library which in turn // requires an allocator in order to avoid circular dependencies. This crate, // however, can use all of libcore. -#![feature(no_std)] #![no_std] // Let's give a unique name to our custom allocator diff --git a/src/doc/book/lang-items.md b/src/doc/book/lang-items.md index 76b9f82827b..e492bd3e782 100644 --- a/src/doc/book/lang-items.md +++ b/src/doc/book/lang-items.md @@ -16,7 +16,7 @@ and one for deallocation. A freestanding program that uses the `Box` sugar for dynamic allocations via `malloc` and `free`: ```rust -#![feature(lang_items, box_syntax, start, no_std, libc)] +#![feature(lang_items, box_syntax, start, libc)] #![no_std] extern crate libc; diff --git a/src/doc/book/no-stdlib.md b/src/doc/book/no-stdlib.md index 0040878fb2f..3a4d4c306dc 100644 --- a/src/doc/book/no-stdlib.md +++ b/src/doc/book/no-stdlib.md @@ -16,7 +16,6 @@ in the same format as C: # #![feature(libc)] #![feature(lang_items)] #![feature(start)] -#![feature(no_std)] #![no_std] // Pull in the system libc library for what crt0.o likely requires @@ -46,7 +45,6 @@ compiler's name mangling too: ```rust # #![feature(libc)] -#![feature(no_std)] #![feature(lang_items)] #![feature(start)] #![no_std] @@ -104,9 +102,6 @@ vectors provided from C, using idiomatic Rust practices. # #![feature(libc)] #![feature(lang_items)] #![feature(start)] -#![feature(no_std)] -#![feature(core)] -#![feature(core_slice_ext)] #![feature(raw)] #![no_std] diff --git a/src/etc/unicode.py b/src/etc/unicode.py index 3eeb1ac4723..3c1659ba2e0 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -315,7 +315,6 @@ def emit_bsearch_range_table(f): f.write(""" fn bsearch_range_table(c: char, r: &'static [(char, char)]) -> bool { use core::cmp::Ordering::{Equal, Less, Greater}; - use core::slice::SliceExt; r.binary_search_by(|&(lo, hi)| { if lo <= c && c <= hi { Equal @@ -358,7 +357,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title): f.write("pub mod conversions {") f.write(""" use core::cmp::Ordering::{Equal, Less, Greater}; - use core::slice::SliceExt; use core::option::Option; use core::option::Option::{Some, None}; use core::result::Result::{Ok, Err}; @@ -404,7 +402,6 @@ def emit_charwidth_module(f, width_table): f.write("pub mod charwidth {\n") f.write(" use core::option::Option;\n") f.write(" use core::option::Option::{Some, None};\n") - f.write(" use core::slice::SliceExt;\n") f.write(" use core::result::Result::{Ok, Err};\n") f.write(""" fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 { diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 804c593467e..1afb49d9184 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -104,7 +104,6 @@ pub struct ExchangeHeapSingleton { /// See the [module-level documentation](../../std/boxed/index.html) for more. #[lang = "owned_box"] #[stable(feature = "rust1", since = "1.0.0")] -#[fundamental] pub struct Box(Unique); /// `IntermediateBox` represents uninitialized backing storage for `Box`. diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5d31385462c..f665b1e1924 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -75,17 +75,15 @@ #![cfg_attr(not(stage0), needs_allocator)] #![cfg_attr(stage0, feature(rustc_attrs))] +#![cfg_attr(stage0, feature(no_std))] #![cfg_attr(stage0, allow(unused_attributes))] #![feature(allocator)] #![feature(box_syntax)] #![feature(coerce_unsized)] -#![feature(core)] #![feature(core_intrinsics)] -#![feature(core_slice_ext)] #![feature(custom_attribute)] #![feature(fundamental)] #![feature(lang_items)] -#![feature(no_std)] #![feature(nonzero)] #![feature(num_bits_bytes)] #![feature(optin_builtin_traits)] @@ -103,9 +101,8 @@ #![allow(unused_attributes)] #![feature(dropck_parametricity)] #![feature(unsize)] -#![feature(core_slice_ext)] -#![feature(core_str_ext)] #![feature(drop_in_place)] +#![feature(fn_traits)] #![cfg_attr(stage0, feature(alloc_system))] #![cfg_attr(not(stage0), feature(needs_allocator))] diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 78deed0c84f..92f35c08a7d 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -10,7 +10,7 @@ use core::ptr::Unique; use core::mem; -use core::slice::{self, SliceExt}; +use core::slice; use heap; use super::oom; use super::boxed::Box; diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index 3db6d7f1a7b..ec6c6ae31c1 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -21,8 +21,8 @@ issue = "27783")] #![feature(allocator)] #![feature(libc)] -#![feature(no_std)] #![feature(staged_api)] +#![cfg_attr(stage0, feature(no_std))] extern crate libc; diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 7f2d362e5d9..a6e89d5d00c 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -21,8 +21,8 @@ issue = "27783")] #![feature(allocator)] #![feature(libc)] -#![feature(no_std)] #![feature(staged_api)] +#![cfg_attr(stage0, feature(no_std))] extern crate libc; diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 06ff8581b5e..b8ca48ac75d 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -581,10 +581,7 @@ impl BinaryHeap { /// /// The elements are removed in arbitrary order. #[inline] - #[unstable(feature = "drain", - reason = "matches collection reform specification, \ - waiting for dust to settle", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain { Drain { iter: self.data.drain(..) } } @@ -738,7 +735,7 @@ impl DoubleEndedIterator for IntoIter { impl ExactSizeIterator for IntoIter {} /// An iterator that drains a `BinaryHeap`. -#[unstable(feature = "drain", reason = "recent addition", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a, T: 'a> { iter: vec::Drain<'a, T>, } diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index b39c3cd4485..a7797d4b0d0 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -43,8 +43,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(core_intrinsics)] -#![feature(core_slice_ext)] -#![feature(core_str_ext)] #![feature(fmt_internals)] #![feature(fmt_radix)] #![feature(heap_api)] @@ -68,9 +66,10 @@ #![feature(unsafe_no_drop_flag, filling_drop)] #![feature(decode_utf16)] #![feature(drop_in_place)] +#![feature(clone_from_slice)] #![cfg_attr(test, feature(clone_from_slice, rand, test))] -#![feature(no_std)] +#![cfg_attr(stage0, feature(no_std))] #![no_std] extern crate rustc_unicode; diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 82cadd7ac0d..6342ae5c816 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -160,7 +160,7 @@ mod hack { where T: Clone { let mut vector = Vec::with_capacity(s.len()); - vector.push_all(s); + vector.extend_from_slice(s); vector } } @@ -777,6 +777,33 @@ impl [T] { self.sort_by(|a, b| a.cmp(b)) } + /// Sorts the slice, in place, using `key` to extract a key by which to + /// order the sort by. + /// + /// This sort is `O(n log n)` worst-case and stable, but allocates + /// approximately `2 * n`, where `n` is the length of `self`. + /// + /// This is a stable sort. + /// + /// # Examples + /// + /// ```rust + /// #![feature(slice_sort_by_key)] + /// + /// let mut v = [-5i32, 4, 1, -3, 2]; + /// + /// v.sort_by_key(|k| k.abs()); + /// assert!(v == [1, 2, -3, 4, -5]); + /// ``` + #[unstable(feature = "slice_sort_by_key", reason = "recently added", + issue = "27724")] + #[inline] + pub fn sort_by_key(&mut self, mut f: F) + where F: FnMut(&T) -> B, B: Ord + { + self.sort_by(|a, b| f(a).cmp(&f(b))) + } + /// Sorts the slice, in place, using `compare` to compare /// elements. /// @@ -906,7 +933,7 @@ impl> SliceConcatExt for [V] { let size = self.iter().fold(0, |acc, v| acc + v.borrow().len()); let mut result = Vec::with_capacity(size); for v in self { - result.push_all(v.borrow()) + result.extend_from_slice(v.borrow()) } result } @@ -921,7 +948,7 @@ impl> SliceConcatExt for [V] { } else { result.push(sep.clone()) } - result.push_all(v.borrow()) + result.extend_from_slice(v.borrow()) } result } diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index c5e0af3d800..a3c69182934 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -482,7 +482,7 @@ impl String { let mut res = String::with_capacity(total); if i > 0 { - unsafe { res.as_mut_vec().push_all(&v[..i]) }; + unsafe { res.as_mut_vec().extend_from_slice(&v[..i]) }; } // subseqidx is the index of the first byte of the subsequence we're @@ -498,10 +498,10 @@ impl String { macro_rules! error { () => ({ unsafe { if subseqidx != i_ { - res.as_mut_vec().push_all(&v[subseqidx..i_]); + res.as_mut_vec().extend_from_slice(&v[subseqidx..i_]); } subseqidx = i; - res.as_mut_vec().push_all(REPLACEMENT); + res.as_mut_vec().extend_from_slice(REPLACEMENT); } })} @@ -566,7 +566,7 @@ impl String { } } if subseqidx < total { - unsafe { res.as_mut_vec().push_all(&v[subseqidx..total]) }; + unsafe { res.as_mut_vec().extend_from_slice(&v[subseqidx..total]) }; } Cow::Owned(res) } @@ -699,7 +699,7 @@ impl String { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn push_str(&mut self, string: &str) { - self.vec.push_all(string.as_bytes()) + self.vec.extend_from_slice(string.as_bytes()) } /// Returns the number of bytes that this string buffer can hold without @@ -1026,8 +1026,6 @@ impl String { /// # Examples /// /// ``` - /// #![feature(drain)] - /// /// let mut s = String::from("α is alpha, β is beta"); /// let beta_offset = s.find('β').unwrap_or(s.len()); /// @@ -1040,9 +1038,7 @@ impl String { /// s.drain(..); /// assert_eq!(s, ""); /// ``` - #[unstable(feature = "drain", - reason = "recently added, matches RFC", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self, range: R) -> Drain where R: RangeArgument { @@ -1600,7 +1596,7 @@ impl fmt::Write for String { } /// A draining iterator for `String`. -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a> { /// Will be used as &'a mut String in the destructor string: *mut String, @@ -1612,12 +1608,12 @@ pub struct Drain<'a> { iter: Chars<'a>, } -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] unsafe impl<'a> Sync for Drain<'a> {} -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] unsafe impl<'a> Send for Drain<'a> {} -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] impl<'a> Drop for Drain<'a> { fn drop(&mut self) { unsafe { @@ -1631,7 +1627,7 @@ impl<'a> Drop for Drain<'a> { } } -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] impl<'a> Iterator for Drain<'a> { type Item = char; @@ -1645,7 +1641,7 @@ impl<'a> Iterator for Drain<'a> { } } -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] impl<'a> DoubleEndedIterator for Drain<'a> { #[inline] fn next_back(&mut self) -> Option { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 8c1f98bbd07..89b1b99cfa3 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -739,17 +739,13 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(drain)] - /// /// // Draining using `..` clears the whole vector. /// let mut v = vec![1, 2, 3]; /// let u: Vec<_> = v.drain(..).collect(); /// assert_eq!(v, &[]); /// assert_eq!(u, &[1, 2, 3]); /// ``` - #[unstable(feature = "drain", - reason = "recently added, matches RFC", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self, range: R) -> Drain where R: RangeArgument { @@ -933,6 +929,7 @@ impl Vec { /// /// ``` /// #![feature(vec_push_all)] + /// #![allow(deprecated)] /// /// let mut vec = vec![1]; /// vec.push_all(&[2, 3, 4]); @@ -942,7 +939,31 @@ impl Vec { #[unstable(feature = "vec_push_all", reason = "likely to be replaced by a more optimized extend", issue = "27744")] + #[rustc_deprecated(reason = "renamed to extend_from_slice", + since = "1.6.0")] pub fn push_all(&mut self, other: &[T]) { + self.extend_from_slice(other) + } + + /// Appends all elements in a slice to the `Vec`. + /// + /// Iterates over the slice `other`, clones each element, and then appends + /// it to this `Vec`. The `other` vector is traversed in-order. + /// + /// Note that this function is same as `extend` except that it is + /// specialized to work with slices instead. If and when Rust gets + /// specialization this function will likely be deprecated (but still + /// available). + /// + /// # Examples + /// + /// ``` + /// let mut vec = vec![1]; + /// vec.extend_from_slice(&[2, 3, 4]); + /// assert_eq!(vec, [1, 2, 3, 4]); + /// ``` + #[stable(feature = "vec_extend_from_slice", since = "1.6.0")] + pub fn extend_from_slice(&mut self, other: &[T]) { self.reserve(other.len()); for i in 0..other.len() { @@ -1103,7 +1124,7 @@ impl Clone for Vec { // self.len <= other.len due to the truncate above, so the // slice here is always in-bounds. - self.push_all(&other[len..]); + self.extend_from_slice(&other[len..]); } } @@ -1350,6 +1371,21 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for Vec { } } +macro_rules! __impl_slice_eq1 { + ($Lhs: ty, $Rhs: ty) => { + __impl_slice_eq1! { $Lhs, $Rhs, Sized } + }; + ($Lhs: ty, $Rhs: ty, $Bound: ident) => { + #[stable(feature = "rust1", since = "1.0.0")] + impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq { + #[inline] + fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] } + #[inline] + fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] } + } + } +} + __impl_slice_eq1! { Vec, Vec } __impl_slice_eq1! { Vec, &'b [B] } __impl_slice_eq1! { Vec, &'b mut [B] } @@ -1605,7 +1641,7 @@ impl Drop for IntoIter { } /// A draining iterator for `Vec`. -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a, T: 'a> { /// Index of tail to preserve tail_start: usize, @@ -1616,9 +1652,9 @@ pub struct Drain<'a, T: 'a> { vec: *mut Vec, } -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {} -#[unstable(feature = "drain", reason = "recently added", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] unsafe impl<'a, T: Send> Send for Drain<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 26b9944f062..53597f566b8 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -778,8 +778,6 @@ impl VecDeque { /// # Examples /// /// ``` - /// #![feature(drain)] - /// /// use std::collections::VecDeque; /// /// // draining using `..` clears the whole deque. @@ -789,9 +787,7 @@ impl VecDeque { /// assert!(v.is_empty()); /// ``` #[inline] - #[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self, range: R) -> Drain where R: RangeArgument { @@ -1893,9 +1889,7 @@ impl DoubleEndedIterator for IntoIter { impl ExactSizeIterator for IntoIter {} /// A draining VecDeque iterator -#[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a, T: 'a> { after_tail: usize, after_head: usize, @@ -1903,9 +1897,9 @@ pub struct Drain<'a, T: 'a> { deque: *mut VecDeque, } -#[unstable(feature = "drain", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {} -#[unstable(feature = "drain", issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] unsafe impl<'a, T: Send> Send for Drain<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 63c7bc15c8f..e57620dfb04 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -15,7 +15,7 @@ #![feature(collections)] #![feature(collections_bound)] #![feature(const_fn)] -#![feature(core)] +#![feature(fn_traits)] #![feature(deque_extras)] #![feature(drain)] #![feature(enumset)] diff --git a/src/libcore/array.rs b/src/libcore/array.rs index c986914440d..0c5eada2165 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -62,6 +62,38 @@ unsafe impl> FixedSizeArray for A { } } +macro_rules! __impl_slice_eq1 { + ($Lhs: ty, $Rhs: ty) => { + __impl_slice_eq1! { $Lhs, $Rhs, Sized } + }; + ($Lhs: ty, $Rhs: ty, $Bound: ident) => { + #[stable(feature = "rust1", since = "1.0.0")] + impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq { + #[inline] + fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] } + #[inline] + fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] } + } + } +} + +macro_rules! __impl_slice_eq2 { + ($Lhs: ty, $Rhs: ty) => { + __impl_slice_eq2! { $Lhs, $Rhs, Sized } + }; + ($Lhs: ty, $Rhs: ty, $Bound: ident) => { + __impl_slice_eq1!($Lhs, $Rhs, $Bound); + + #[stable(feature = "rust1", since = "1.0.0")] + impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq { + #[inline] + fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] } + #[inline] + fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] } + } + } +} + // macro for implementing n-ary tuple functions and operations macro_rules! array_impls { ($($N:expr)+) => { diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 5e13df43280..c02704217a8 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -257,19 +257,25 @@ pub fn from_digit(num: u32, radix: u32) -> Option { reason = "the stable interface is `impl char` in later crate", issue = "27701")] pub trait CharExt { + #[stable(feature = "core", since = "1.6.0")] fn is_digit(self, radix: u32) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn to_digit(self, radix: u32) -> Option; + #[stable(feature = "core", since = "1.6.0")] fn escape_unicode(self) -> EscapeUnicode; + #[stable(feature = "core", since = "1.6.0")] fn escape_default(self) -> EscapeDefault; + #[stable(feature = "core", since = "1.6.0")] fn len_utf8(self) -> usize; + #[stable(feature = "core", since = "1.6.0")] fn len_utf16(self) -> usize; + #[stable(feature = "core", since = "1.6.0")] fn encode_utf8(self, dst: &mut [u8]) -> Option; + #[stable(feature = "core", since = "1.6.0")] fn encode_utf16(self, dst: &mut [u16]) -> Option; } -#[unstable(feature = "core_char_ext", - reason = "the stable interface is `impl char` in later crate", - issue = "27701")] +#[stable(feature = "core", since = "1.6.0")] impl CharExt for char { #[inline] fn is_digit(self, radix: u32) -> bool { diff --git a/src/libcore/cmp_macros.rs b/src/libcore/cmp_macros.rs deleted file mode 100644 index 3863f63265b..00000000000 --- a/src/libcore/cmp_macros.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Utility macros for implementing PartialEq on slice-like types - -#![doc(hidden)] - -#[macro_export] -macro_rules! __impl_slice_eq1 { - ($Lhs: ty, $Rhs: ty) => { - __impl_slice_eq1! { $Lhs, $Rhs, Sized } - }; - ($Lhs: ty, $Rhs: ty, $Bound: ident) => { - #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq { - #[inline] - fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] } - #[inline] - fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] } - } - } -} - -#[macro_export] -macro_rules! __impl_slice_eq2 { - ($Lhs: ty, $Rhs: ty) => { - __impl_slice_eq2! { $Lhs, $Rhs, Sized } - }; - ($Lhs: ty, $Rhs: ty, $Bound: ident) => { - __impl_slice_eq1!($Lhs, $Rhs, $Bound); - - #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq { - #[inline] - fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] } - #[inline] - fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] } - } - } -} diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index dfd79895747..04676c0c9c8 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -878,7 +878,7 @@ impl<'a> Formatter<'a> { let mut prefixed = false; if self.alternate() { - prefixed = true; width += prefix.char_len(); + prefixed = true; width += prefix.chars().count(); } // Writes the sign if it exists, and then the prefix if it was requested @@ -942,18 +942,13 @@ impl<'a> Formatter<'a> { } // The `precision` field can be interpreted as a `max-width` for the // string being formatted - match self.precision { - Some(max) => { - // If there's a maximum width and our string is longer than - // that, then we must always have truncation. This is the only - // case where the maximum length will matter. - let char_len = s.char_len(); - if char_len >= max { - let nchars = ::cmp::min(max, char_len); - return self.buf.write_str(s.slice_chars(0, nchars)); - } + if let Some(max) = self.precision { + // If there's a maximum width and our string is longer than + // that, then we must always have truncation. This is the only + // case where the maximum length will matter. + if let Some((i, _)) = s.char_indices().skip(max).next() { + return self.buf.write_str(&s[..i]) } - None => {} } // The `width` field is more of a `min-width` parameter at this point. match self.width { @@ -962,13 +957,13 @@ impl<'a> Formatter<'a> { None => self.buf.write_str(s), // If we're under the maximum width, check if we're over the minimum // width, if so it's as easy as just emitting the string. - Some(width) if s.char_len() >= width => { + Some(width) if s.chars().count() >= width => { self.buf.write_str(s) } // If we're under both the maximum and the minimum width, then fill // up the minimum width with the specified string + some alignment. Some(width) => { - self.with_padding(width - s.char_len(), Alignment::Left, |me| { + self.with_padding(width - s.chars().count(), Alignment::Left, |me| { me.buf.write_str(s) }) } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 8cc7f531c58..86c00a254ca 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1903,6 +1903,7 @@ pub trait Iterator { /// /// ``` /// #![feature(iter_cmp)] + /// #![allow(deprecated)] /// /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10); @@ -1911,9 +1912,30 @@ pub trait Iterator { #[unstable(feature = "iter_cmp", reason = "may want to produce an Ordering directly; see #15311", issue = "27724")] + #[rustc_deprecated(reason = "renamed to max_by_key", since = "1.6.0")] fn max_by(self, f: F) -> Option where Self: Sized, F: FnMut(&Self::Item) -> B, + { + self.max_by_key(f) + } + + /// Returns the element that gives the maximum value from the + /// specified function. + /// + /// Returns the rightmost element if the comparison determines two elements + /// to be equally maximum. + /// + /// # Examples + /// + /// ``` + /// let a = [-3_i32, 0, 1, 5, -10]; + /// assert_eq!(*a.iter().max_by_key(|x| x.abs()).unwrap(), -10); + /// ``` + #[inline] + #[stable(feature = "iter_cmp_by_key", since = "1.6.0")] + fn max_by_key(self, f: F) -> Option + where Self: Sized, F: FnMut(&Self::Item) -> B, { select_fold1(self, f, @@ -1933,6 +1955,7 @@ pub trait Iterator { /// /// ``` /// #![feature(iter_cmp)] + /// #![allow(deprecated)] /// /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0); @@ -1941,9 +1964,29 @@ pub trait Iterator { #[unstable(feature = "iter_cmp", reason = "may want to produce an Ordering directly; see #15311", issue = "27724")] + #[rustc_deprecated(reason = "renamed to min_by_key", since = "1.6.0")] fn min_by(self, f: F) -> Option where Self: Sized, F: FnMut(&Self::Item) -> B, + { + self.min_by_key(f) + } + + /// Returns the element that gives the minimum value from the + /// specified function. + /// + /// Returns the latest element if the comparison determines two elements + /// to be equally minimum. + /// + /// # Examples + /// + /// ``` + /// let a = [-3_i32, 0, 1, 5, -10]; + /// assert_eq!(*a.iter().min_by_key(|x| x.abs()).unwrap(), 0); + /// ``` + #[stable(feature = "iter_cmp_by_key", since = "1.6.0")] + fn min_by_key(self, f: F) -> Option + where Self: Sized, F: FnMut(&Self::Item) -> B, { select_fold1(self, f, @@ -3588,7 +3631,7 @@ impl Peekable { /// Basic usage: /// /// ``` - /// #![feature(core)] + /// #![feature(peekable_is_empty)] /// /// let xs = [1, 2, 3]; /// @@ -3604,7 +3647,7 @@ impl Peekable { /// /// assert_eq!(iter.is_empty(), true); /// ``` - #[unstable(feature = "core", issue = "27701")] + #[unstable(feature = "peekable_is_empty", issue = "27701")] #[inline] pub fn is_empty(&mut self) -> bool { self.peek().is_none() diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index f8bda4b6b2b..86f2e3bcec3 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -52,18 +52,16 @@ // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "core"] -#![unstable(feature = "core", - reason = "the libcore library has not yet been scrutinized for \ - stabilization in terms of structure and naming", - issue = "27701")] +#![stable(feature = "core", since = "1.6.0")] #![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", - issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] -#![doc(test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] + issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", + test(no_crate_inject, attr(deny(warnings))), + test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] #![no_core] #![deny(missing_docs)] @@ -91,9 +89,6 @@ #[macro_use] mod macros; -#[macro_use] -mod cmp_macros; - #[path = "num/float_macros.rs"] #[macro_use] mod float_macros; diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index bc8656b32b8..03d3cb11b3e 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -11,6 +11,7 @@ /// Entry point of thread panic, for details, see std::macros #[macro_export] #[allow_internal_unstable] +#[stable(feature = "core", since = "1.6.0")] macro_rules! panic { () => ( panic!("explicit panic") @@ -154,21 +155,47 @@ macro_rules! debug_assert { /// debug_assert_eq!(a, b); /// ``` #[macro_export] +#[stable(feature = "rust1", since = "1.0.0")] macro_rules! debug_assert_eq { ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); }) } -/// Short circuiting evaluation on Err +/// Helper macro for unwrapping `Result` values while returning early with an +/// error if the value of the expression is `Err`. Can only be used in +/// functions that return `Result` because of the early return of `Err` that +/// it provides. /// -/// `libstd` contains a more general `try!` macro that uses `From`. +/// # Examples +/// +/// ``` +/// use std::io; +/// use std::fs::File; +/// use std::io::prelude::*; +/// +/// fn write_to_file_using_try() -> Result<(), io::Error> { +/// let mut file = try!(File::create("my_best_friends.txt")); +/// try!(file.write_all(b"This is a list of my best friends.")); +/// println!("I wrote to the file"); +/// Ok(()) +/// } +/// // This is equivalent to: +/// fn write_to_file_using_match() -> Result<(), io::Error> { +/// let mut file = try!(File::create("my_best_friends.txt")); +/// match file.write_all(b"This is a list of my best friends.") { +/// Ok(_) => (), +/// Err(e) => return Err(e), +/// } +/// println!("I wrote to the file"); +/// Ok(()) +/// } +/// ``` #[macro_export] +#[stable(feature = "rust1", since = "1.0.0")] macro_rules! try { - ($e:expr) => ({ - use $crate::result::Result::{Ok, Err}; - - match $e { - Ok(e) => e, - Err(e) => return Err(e), + ($expr:expr) => (match $expr { + $crate::result::Result::Ok(val) => val, + $crate::result::Result::Err(err) => { + return $crate::result::Result::Err($crate::convert::From::from(err)) } }) } @@ -194,6 +221,7 @@ macro_rules! try { /// assert_eq!(w, b"testformatted arguments"); /// ``` #[macro_export] +#[stable(feature = "core", since = "1.6.0")] macro_rules! write { ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*))) } @@ -271,9 +299,7 @@ macro_rules! writeln { /// } /// ``` #[macro_export] -#[unstable(feature = "core", - reason = "relationship with panic is unclear", - issue = "27701")] +#[stable(feature = "core", since = "1.6.0")] macro_rules! unreachable { () => ({ panic!("internal error: entered unreachable code") @@ -334,9 +360,7 @@ macro_rules! unreachable { /// } /// ``` #[macro_export] -#[unstable(feature = "core", - reason = "relationship with panic is unclear", - issue = "27701")] +#[stable(feature = "core", since = "1.6.0")] macro_rules! unimplemented { () => (panic!("not yet implemented")) } diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 1261bd0388c..359d15640f9 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -243,14 +243,14 @@ impl Float for f32 { /// Returns `true` if `self` is positive, including `+0.0` and /// `Float::infinity()`. #[inline] - fn is_positive(self) -> bool { + fn is_sign_positive(self) -> bool { self > 0.0 || (1.0 / self) == Float::infinity() } /// Returns `true` if `self` is negative, including `-0.0` and /// `Float::neg_infinity()`. #[inline] - fn is_negative(self) -> bool { + fn is_sign_negative(self) -> bool { self < 0.0 || (1.0 / self) == Float::neg_infinity() } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index c4a24631552..1a6acc5f4ab 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -243,14 +243,14 @@ impl Float for f64 { /// Returns `true` if `self` is positive, including `+0.0` and /// `Float::infinity()`. #[inline] - fn is_positive(self) -> bool { + fn is_sign_positive(self) -> bool { self > 0.0 || (1.0 / self) == Float::infinity() } /// Returns `true` if `self` is negative, including `-0.0` and /// `Float::neg_infinity()`. #[inline] - fn is_negative(self) -> bool { + fn is_sign_negative(self) -> bool { self < 0.0 || (1.0 / self) == Float::neg_infinity() } diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index 57d4bccbfa6..46f3c463ff0 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -132,7 +132,6 @@ functions. use prelude::v1::*; use i16; -use slice::bytes; pub use self::decoder::{decode, DecodableFloat, FullDecoded, Decoded}; pub mod estimator; @@ -211,7 +210,7 @@ impl<'a> Part<'a> { } } Part::Copy(buf) => { - bytes::copy_memory(buf, out); + out.clone_from_slice(buf); } } Some(len) @@ -246,7 +245,7 @@ impl<'a> Formatted<'a> { /// (It may still leave partially written bytes in the buffer; do not rely on that.) pub fn write(&self, out: &mut [u8]) -> Option { if out.len() < self.sign.len() { return None; } - bytes::copy_memory(self.sign, out); + out.clone_from_slice(self.sign); let mut written = self.sign.len(); for part in self.parts { diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index fdff49b1a57..e1e5c01adb7 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1748,62 +1748,96 @@ pub enum FpCategory { issue = "27702")] pub trait Float: Sized { /// Returns the NaN value. + #[unstable(feature = "float_extras", reason = "needs removal", + issue = "27752")] fn nan() -> Self; /// Returns the infinite value. + #[unstable(feature = "float_extras", reason = "needs removal", + issue = "27752")] fn infinity() -> Self; /// Returns the negative infinite value. + #[unstable(feature = "float_extras", reason = "needs removal", + issue = "27752")] fn neg_infinity() -> Self; /// Returns -0.0. + #[unstable(feature = "float_extras", reason = "needs removal", + issue = "27752")] fn neg_zero() -> Self; /// Returns 0.0. + #[unstable(feature = "float_extras", reason = "needs removal", + issue = "27752")] fn zero() -> Self; /// Returns 1.0. + #[unstable(feature = "float_extras", reason = "needs removal", + issue = "27752")] fn one() -> Self; /// Parses the string `s` with the radix `r` as a float. + #[unstable(feature = "float_from_str_radix", reason = "recently moved API", + issue = "27736")] + #[rustc_deprecated(since = "1.4.0", + reason = "unclear how useful or correct this is")] fn from_str_radix(s: &str, r: u32) -> Result; /// Returns true if this value is NaN and false otherwise. + #[stable(feature = "core", since = "1.6.0")] fn is_nan(self) -> bool; /// Returns true if this value is positive infinity or negative infinity and /// false otherwise. + #[stable(feature = "core", since = "1.6.0")] fn is_infinite(self) -> bool; /// Returns true if this number is neither infinite nor NaN. + #[stable(feature = "core", since = "1.6.0")] fn is_finite(self) -> bool; /// Returns true if this number is neither zero, infinite, denormal, or NaN. + #[stable(feature = "core", since = "1.6.0")] fn is_normal(self) -> bool; /// Returns the category that this number falls into. + #[stable(feature = "core", since = "1.6.0")] fn classify(self) -> FpCategory; /// Returns the mantissa, exponent and sign as integers, respectively. + #[unstable(feature = "float_extras", reason = "signature is undecided", + issue = "27752")] fn integer_decode(self) -> (u64, i16, i8); /// Computes the absolute value of `self`. Returns `Float::nan()` if the /// number is `Float::nan()`. + #[stable(feature = "core", since = "1.6.0")] fn abs(self) -> Self; /// Returns a number that represents the sign of `self`. /// /// - `1.0` if the number is positive, `+0.0` or `Float::infinity()` /// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()` /// - `Float::nan()` if the number is `Float::nan()` + #[stable(feature = "core", since = "1.6.0")] fn signum(self) -> Self; + /// Returns `true` if `self` is positive, including `+0.0` and /// `Float::infinity()`. - fn is_positive(self) -> bool; + #[stable(feature = "core", since = "1.6.0")] + fn is_sign_positive(self) -> bool; /// Returns `true` if `self` is negative, including `-0.0` and /// `Float::neg_infinity()`. - fn is_negative(self) -> bool; + #[stable(feature = "core", since = "1.6.0")] + fn is_sign_negative(self) -> bool; /// Take the reciprocal (inverse) of a number, `1/x`. + #[stable(feature = "core", since = "1.6.0")] fn recip(self) -> Self; /// Raise a number to an integer power. /// /// Using this function is generally faster than using `powf` + #[stable(feature = "core", since = "1.6.0")] fn powi(self, n: i32) -> Self; /// Convert radians to degrees. + #[unstable(feature = "float_extras", reason = "desirability is unclear", + issue = "27752")] fn to_degrees(self) -> Self; /// Convert degrees to radians. + #[unstable(feature = "float_extras", reason = "desirability is unclear", + issue = "27752")] fn to_radians(self) -> Self; } diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index c379b8744ac..0abbd70762d 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1732,7 +1732,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T { #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait Fn : FnMut { /// This is called when the call operator is used. - #[unstable(feature = "core", issue = "27701")] + #[unstable(feature = "fn_traits", issue = "29625")] extern "rust-call" fn call(&self, args: Args) -> Self::Output; } @@ -1743,7 +1743,7 @@ pub trait Fn : FnMut { #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait FnMut : FnOnce { /// This is called when the call operator is used. - #[unstable(feature = "core", issue = "27701")] + #[unstable(feature = "fn_traits", issue = "29625")] extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } @@ -1754,11 +1754,11 @@ pub trait FnMut : FnOnce { #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait FnOnce { /// The returned type after the call operator is used. - #[unstable(feature = "core", issue = "27701")] + #[unstable(feature = "fn_traits", issue = "29625")] type Output; /// This is called when the call operator is used. - #[unstable(feature = "core", issue = "27701")] + #[unstable(feature = "fn_traits", issue = "29625")] extern "rust-call" fn call_once(self, args: Args) -> Self::Output; } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index f92692a9d71..70175086147 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -61,72 +61,98 @@ use raw::Slice as RawSlice; // /// Extension methods for slices. -#[allow(missing_docs)] // docs in libcollections -#[doc(hidden)] #[unstable(feature = "core_slice_ext", reason = "stable interface provided by `impl [T]` in later crates", issue = "27701")] +#[allow(missing_docs)] // documented elsewhere pub trait SliceExt { type Item; + #[stable(feature = "core", since = "1.6.0")] fn split_at(&self, mid: usize) -> (&[Self::Item], &[Self::Item]); + #[stable(feature = "core", since = "1.6.0")] fn iter(&self) -> Iter; + #[stable(feature = "core", since = "1.6.0")] fn split

(&self, pred: P) -> Split where P: FnMut(&Self::Item) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn splitn

(&self, n: usize, pred: P) -> SplitN where P: FnMut(&Self::Item) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn rsplitn

(&self, n: usize, pred: P) -> RSplitN where P: FnMut(&Self::Item) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn windows(&self, size: usize) -> Windows; + #[stable(feature = "core", since = "1.6.0")] fn chunks(&self, size: usize) -> Chunks; + #[stable(feature = "core", since = "1.6.0")] fn get(&self, index: usize) -> Option<&Self::Item>; + #[stable(feature = "core", since = "1.6.0")] fn first(&self) -> Option<&Self::Item>; - fn tail(&self) -> &[Self::Item]; - fn init(&self) -> &[Self::Item]; + #[stable(feature = "core", since = "1.6.0")] fn split_first(&self) -> Option<(&Self::Item, &[Self::Item])>; + #[stable(feature = "core", since = "1.6.0")] fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])>; + #[stable(feature = "core", since = "1.6.0")] fn last(&self) -> Option<&Self::Item>; + #[stable(feature = "core", since = "1.6.0")] unsafe fn get_unchecked(&self, index: usize) -> &Self::Item; + #[stable(feature = "core", since = "1.6.0")] fn as_ptr(&self) -> *const Self::Item; - fn binary_search_by(&self, f: F) -> Result where - F: FnMut(&Self::Item) -> Ordering; + #[stable(feature = "core", since = "1.6.0")] + fn binary_search(&self, x: &Self::Item) -> Result + where Self::Item: Ord; + #[stable(feature = "core", since = "1.6.0")] + fn binary_search_by(&self, f: F) -> Result + where F: FnMut(&Self::Item) -> Ordering; + #[stable(feature = "core", since = "1.6.0")] fn len(&self) -> usize; + #[stable(feature = "core", since = "1.6.0")] fn is_empty(&self) -> bool { self.len() == 0 } + #[stable(feature = "core", since = "1.6.0")] fn get_mut(&mut self, index: usize) -> Option<&mut Self::Item>; + #[stable(feature = "core", since = "1.6.0")] fn iter_mut(&mut self) -> IterMut; + #[stable(feature = "core", since = "1.6.0")] fn first_mut(&mut self) -> Option<&mut Self::Item>; - fn tail_mut(&mut self) -> &mut [Self::Item]; - fn init_mut(&mut self) -> &mut [Self::Item]; + #[stable(feature = "core", since = "1.6.0")] fn split_first_mut(&mut self) -> Option<(&mut Self::Item, &mut [Self::Item])>; + #[stable(feature = "core", since = "1.6.0")] fn split_last_mut(&mut self) -> Option<(&mut Self::Item, &mut [Self::Item])>; + #[stable(feature = "core", since = "1.6.0")] fn last_mut(&mut self) -> Option<&mut Self::Item>; + #[stable(feature = "core", since = "1.6.0")] fn split_mut

(&mut self, pred: P) -> SplitMut where P: FnMut(&Self::Item) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn splitn_mut

(&mut self, n: usize, pred: P) -> SplitNMut where P: FnMut(&Self::Item) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn rsplitn_mut

(&mut self, n: usize, pred: P) -> RSplitNMut where P: FnMut(&Self::Item) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut; + #[stable(feature = "core", since = "1.6.0")] fn swap(&mut self, a: usize, b: usize); + #[stable(feature = "core", since = "1.6.0")] fn split_at_mut(&mut self, mid: usize) -> (&mut [Self::Item], &mut [Self::Item]); + #[stable(feature = "core", since = "1.6.0")] fn reverse(&mut self); + #[stable(feature = "core", since = "1.6.0")] unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut Self::Item; + #[stable(feature = "core", since = "1.6.0")] fn as_mut_ptr(&mut self) -> *mut Self::Item; - fn position_elem(&self, t: &Self::Item) -> Option where Self::Item: PartialEq; - - fn rposition_elem(&self, t: &Self::Item) -> Option where Self::Item: PartialEq; - + #[stable(feature = "core", since = "1.6.0")] fn contains(&self, x: &Self::Item) -> bool where Self::Item: PartialEq; + #[stable(feature = "core", since = "1.6.0")] fn starts_with(&self, needle: &[Self::Item]) -> bool where Self::Item: PartialEq; + #[stable(feature = "core", since = "1.6.0")] fn ends_with(&self, needle: &[Self::Item]) -> bool where Self::Item: PartialEq; - fn binary_search(&self, x: &Self::Item) -> Result where Self::Item: Ord; - fn next_permutation(&mut self) -> bool where Self::Item: Ord; - fn prev_permutation(&mut self) -> bool where Self::Item: Ord; - + #[unstable(feature = "clone_from_slice", issue= "27750")] fn clone_from_slice(&mut self, &[Self::Item]) -> usize where Self::Item: Clone; } @@ -241,17 +267,11 @@ impl SliceExt for [T] { if self.is_empty() { None } else { Some(&self[0]) } } - #[inline] - fn tail(&self) -> &[T] { &self[1..] } - #[inline] fn split_first(&self) -> Option<(&T, &[T])> { if self.is_empty() { None } else { Some((&self[0], &self[1..])) } } - #[inline] - fn init(&self) -> &[T] { &self[..self.len() - 1] } - #[inline] fn split_last(&self) -> Option<(&T, &[T])> { let len = self.len(); @@ -346,9 +366,6 @@ impl SliceExt for [T] { if self.is_empty() { None } else { Some(&mut self[0]) } } - #[inline] - fn tail_mut(&mut self) -> &mut [T] { &mut self[1 ..] } - #[inline] fn split_first_mut(&mut self) -> Option<(&mut T, &mut [T])> { if self.is_empty() { None } else { @@ -357,12 +374,6 @@ impl SliceExt for [T] { } } - #[inline] - fn init_mut(&mut self) -> &mut [T] { - let len = self.len(); - &mut self[.. (len - 1)] - } - #[inline] fn split_last_mut(&mut self) -> Option<(&mut T, &mut [T])> { let len = self.len(); @@ -444,16 +455,6 @@ impl SliceExt for [T] { self.repr().data as *mut T } - #[inline] - fn position_elem(&self, x: &T) -> Option where T: PartialEq { - self.iter().position(|y| *x == *y) - } - - #[inline] - fn rposition_elem(&self, t: &T) -> Option where T: PartialEq { - self.iter().rposition(|x| *x == *t) - } - #[inline] fn contains(&self, x: &T) -> bool where T: PartialEq { self.iter().any(|elt| *x == *elt) @@ -475,66 +476,6 @@ impl SliceExt for [T] { self.binary_search_by(|p| p.cmp(x)) } - fn next_permutation(&mut self) -> bool where T: Ord { - // These cases only have 1 permutation each, so we can't do anything. - if self.len() < 2 { return false; } - - // Step 1: Identify the longest, rightmost weakly decreasing part of the vector - let mut i = self.len() - 1; - while i > 0 && self[i-1] >= self[i] { - i -= 1; - } - - // If that is the entire vector, this is the last-ordered permutation. - if i == 0 { - return false; - } - - // Step 2: Find the rightmost element larger than the pivot (i-1) - let mut j = self.len() - 1; - while j >= i && self[j] <= self[i-1] { - j -= 1; - } - - // Step 3: Swap that element with the pivot - self.swap(j, i-1); - - // Step 4: Reverse the (previously) weakly decreasing part - self[i..].reverse(); - - true - } - - fn prev_permutation(&mut self) -> bool where T: Ord { - // These cases only have 1 permutation each, so we can't do anything. - if self.len() < 2 { return false; } - - // Step 1: Identify the longest, rightmost weakly increasing part of the vector - let mut i = self.len() - 1; - while i > 0 && self[i-1] <= self[i] { - i -= 1; - } - - // If that is the entire vector, this is the first-ordered permutation. - if i == 0 { - return false; - } - - // Step 2: Reverse the weakly increasing part - self[i..].reverse(); - - // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1) - let mut j = self.len() - 1; - while j >= i && self[j-1] < self[i-1] { - j -= 1; - } - - // Step 4: Swap that element with the pivot - self.swap(i-1, j); - - true - } - #[inline] fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone { let min = cmp::min(self.len(), src.len()); @@ -1514,6 +1455,9 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] { /// Operations on `[u8]`. #[unstable(feature = "slice_bytes", reason = "needs review", issue = "27740")] +#[rustc_deprecated(reason = "unidiomatic functions not pulling their weight", + since = "1.6.0")] +#[allow(deprecated)] pub mod bytes { use ptr; use slice::SliceExt; diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 127c4287f32..7aacdbeb768 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1385,58 +1385,120 @@ pub trait StrExt { // NB there are no docs here are they're all located on the StrExt trait in // libcollections, not here. + #[stable(feature = "core", since = "1.6.0")] fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool; - fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn chars(&self) -> Chars; + #[stable(feature = "core", since = "1.6.0")] fn bytes(&self) -> Bytes; + #[stable(feature = "core", since = "1.6.0")] fn char_indices(&self) -> CharIndices; + #[stable(feature = "core", since = "1.6.0")] fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P>; + #[stable(feature = "core", since = "1.6.0")] fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P> where P::Searcher: ReverseSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn splitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> SplitN<'a, P>; + #[stable(feature = "core", since = "1.6.0")] fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P> where P::Searcher: ReverseSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>; + #[stable(feature = "core", since = "1.6.0")] fn rsplit_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplitTerminator<'a, P> where P::Searcher: ReverseSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P>; + #[stable(feature = "core", since = "1.6.0")] fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P> where P::Searcher: ReverseSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>; + #[stable(feature = "core", since = "1.6.0")] fn rmatch_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatchIndices<'a, P> where P::Searcher: ReverseSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn lines(&self) -> Lines; + #[stable(feature = "core", since = "1.6.0")] + #[rustc_deprecated(since = "1.6.0", reason = "use lines() instead now")] #[allow(deprecated)] fn lines_any(&self) -> LinesAny; - fn char_len(&self) -> usize; - fn slice_chars(&self, begin: usize, end: usize) -> &str; + #[stable(feature = "core", since = "1.6.0")] unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str; + #[stable(feature = "core", since = "1.6.0")] unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str; + #[stable(feature = "core", since = "1.6.0")] fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool where P::Searcher: ReverseSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str where P::Searcher: DoubleEndedSearcher<'a>; + #[stable(feature = "core", since = "1.6.0")] fn trim_left_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str; + #[stable(feature = "core", since = "1.6.0")] fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str where P::Searcher: ReverseSearcher<'a>; + #[unstable(feature = "str_char", + reason = "it is unclear whether this method pulls its weight \ + with the existence of the char_indices iterator or \ + this method may want to be replaced with checked \ + slicing", + issue = "27754")] fn is_char_boundary(&self, index: usize) -> bool; + #[unstable(feature = "str_char", + reason = "often replaced by char_indices, this method may \ + be removed in favor of just char_at() or eventually \ + removed altogether", + issue = "27754")] fn char_range_at(&self, start: usize) -> CharRange; + #[unstable(feature = "str_char", + reason = "often replaced by char_indices, this method may \ + be removed in favor of just char_at_reverse() or \ + eventually removed altogether", + issue = "27754")] fn char_range_at_reverse(&self, start: usize) -> CharRange; + #[unstable(feature = "str_char", + reason = "frequently replaced by the chars() iterator, this \ + method may be removed or possibly renamed in the \ + future; it is normally replaced by chars/char_indices \ + iterators or by getting the first char from a \ + subslice", + issue = "27754")] fn char_at(&self, i: usize) -> char; + #[unstable(feature = "str_char", + reason = "see char_at for more details, but reverse semantics \ + are also somewhat unclear, especially with which \ + cases generate panics", + issue = "27754")] fn char_at_reverse(&self, i: usize) -> char; + #[stable(feature = "core", since = "1.6.0")] fn as_bytes(&self) -> &[u8]; + #[stable(feature = "core", since = "1.6.0")] fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option; + #[stable(feature = "core", since = "1.6.0")] fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option where P::Searcher: ReverseSearcher<'a>; fn find_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option; + #[stable(feature = "core", since = "1.6.0")] fn split_at(&self, mid: usize) -> (&str, &str); + #[stable(feature = "core", since = "1.6.0")] fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str); + #[unstable(feature = "str_char", + reason = "awaiting conventions about shifting and slices and \ + may not be warranted with the existence of the chars \ + and/or char_indices iterators", + issue = "27754")] fn slice_shift_char(&self) -> Option<(char, &str)>; - fn subslice_offset(&self, inner: &str) -> usize; + #[stable(feature = "core", since = "1.6.0")] fn as_ptr(&self) -> *const u8; + #[stable(feature = "core", since = "1.6.0")] fn len(&self) -> usize; + #[stable(feature = "core", since = "1.6.0")] fn is_empty(&self) -> bool; + #[stable(feature = "core", since = "1.6.0")] fn parse(&self) -> Result; } @@ -1448,20 +1510,13 @@ fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! { begin, end, s); } -#[unstable(feature = "core_str_ext", - reason = "stable interface provided by `impl str` in later crates", - issue = "27701")] +#[stable(feature = "core", since = "1.6.0")] impl StrExt for str { #[inline] fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool { pat.is_contained_in(self) } - #[inline] - fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool { - pat.is_contained_in(self) - } - #[inline] fn chars(&self) -> Chars { Chars{iter: self.as_bytes().iter()} @@ -1559,32 +1614,6 @@ impl StrExt for str { LinesAny(self.lines()) } - #[inline] - fn char_len(&self) -> usize { self.chars().count() } - - fn slice_chars(&self, begin: usize, end: usize) -> &str { - assert!(begin <= end); - let mut count = 0; - let mut begin_byte = None; - let mut end_byte = None; - - // This could be even more efficient by not decoding, - // only finding the char boundaries - for (idx, _) in self.char_indices() { - if count == begin { begin_byte = Some(idx); } - if count == end { end_byte = Some(idx); break; } - count += 1; - } - if begin_byte.is_none() && count == begin { begin_byte = Some(self.len()) } - if end_byte.is_none() && count == end { end_byte = Some(self.len()) } - - match (begin_byte, end_byte) { - (None, _) => panic!("slice_chars: `begin` is beyond end of string"), - (_, None) => panic!("slice_chars: `end` is beyond end of string"), - (Some(a), Some(b)) => unsafe { self.slice_unchecked(a, b) } - } - } - #[inline] unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str { mem::transmute(Slice { @@ -1774,17 +1803,6 @@ impl StrExt for str { } } - fn subslice_offset(&self, inner: &str) -> usize { - let a_start = self.as_ptr() as usize; - let a_end = a_start + self.len(); - let b_start = inner.as_ptr() as usize; - let b_end = b_start + inner.len(); - - assert!(a_start <= b_start); - assert!(b_end <= a_end); - b_start - a_start - } - #[inline] fn as_ptr(&self) -> *const u8 { self.repr().data diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 96886c91048..20da4a86bf5 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -31,6 +31,7 @@ #![feature(libc)] #![feature(nonzero)] #![feature(num_bits_bytes)] +#![feature(peekable_is_empty)] #![feature(ptr_as_ref)] #![feature(rand)] #![feature(range_inclusive)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 7c71e51ec43..404bbd902bf 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -174,7 +174,6 @@ #![feature(box_syntax)] #![feature(const_fn)] -#![feature(iter_cmp)] #![feature(staged_api)] #![feature(static_mutex)] @@ -418,7 +417,7 @@ fn init() { }); let max_level = { - let max = directives.iter().max_by(|d| d.level); + let max = directives.iter().max_by_key(|d| d.level); max.map(|d| d.level).unwrap_or(DEFAULT_LOG_LEVEL) }; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 4d0f5e9f160..013efb129d8 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -32,13 +32,12 @@ issue = "27703")] #![feature(core_float)] #![feature(core_intrinsics)] -#![feature(core_slice_ext)] -#![feature(no_std)] #![feature(num_bits_bytes)] #![feature(staged_api)] #![feature(step_by)] #![feature(custom_attribute)] #![allow(unused_attributes)] +#![cfg_attr(stage0, feature(no_std))] #![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index d51280a187c..9cb160b7dec 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -126,7 +126,7 @@ #![feature(rustc_private)] #![feature(staged_api)] -#![feature(slice_bytes)] +#![feature(clone_from_slice)] #![cfg_attr(test, feature(test))] @@ -241,7 +241,6 @@ pub mod reader { use std::isize; use std::mem::transmute; - use std::slice::bytes; use serialize; @@ -482,7 +481,7 @@ pub mod reader { // of the page and segfault. let mut b = [0; 8]; - bytes::copy_memory(&d.data[d.end-8..d.end], &mut b); + b.clone_from_slice(&d.data[d.end-8..d.end]); let data = unsafe { (*(b.as_ptr() as *const u64)).to_be() }; let len = d.end - d.start; if len < 8 { @@ -872,7 +871,6 @@ pub mod writer { use std::mem; use std::io::prelude::*; use std::io::{self, SeekFrom, Cursor}; - use std::slice::bytes; use super::{ EsVec, EsMap, EsEnum, EsSub8, EsSub32, EsVecElt, EsMapKey, EsU64, EsU32, EsU16, EsU8, EsI64, EsI32, EsI16, EsI8, @@ -962,7 +960,7 @@ pub mod writer { { let last_size_pos = last_size_pos as usize; let data = &self.writer.get_ref()[last_size_pos+4..cur_pos as usize]; - bytes::copy_memory(data, &mut buf); + buf.clone_from_slice(data); } // overwrite the size and data and continue diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 6c0a2eb381c..3f4696cdfd9 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -872,7 +872,6 @@ You can build a free-standing crate by adding `#![no_std]` to the crate attributes: ``` -#![feature(no_std)] #![no_std] ``` diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 8b69767eee0..bd97cb128e9 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -28,15 +28,13 @@ #![feature(associated_consts)] #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(cell_extras)] #![feature(clone_from_slice)] #![feature(collections)] #![feature(const_fn)] -#![feature(core)] -#![feature(duration_span)] #![feature(enumset)] #![feature(hashmap_hasher)] #![feature(into_cow)] -#![feature(iter_cmp)] #![feature(iter_arith)] #![feature(libc)] #![feature(nonzero)] @@ -48,9 +46,8 @@ #![feature(slice_patterns)] #![feature(staged_api)] #![feature(str_char)] -#![feature(vec_push_all)] +#![feature(time2)] #![feature(wrapping)] -#![feature(cell_extras)] #![cfg_attr(test, feature(test))] #![allow(trivial_casts)] diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index a292c83682c..f54e3097ac4 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -980,8 +980,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], } }; head.map(|mut head| { - head.push_all(&r[..col]); - head.push_all(&r[col + 1..]); + head.extend_from_slice(&r[..col]); + head.extend_from_slice(&r[col + 1..]); head }) } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index acd635874e3..ec1b447d711 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -255,7 +255,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> { // necessary for the pattern to match. Those construction sites // can't be reached unless the variant is constructed elsewhere. let len = self.ignore_variant_stack.len(); - self.ignore_variant_stack.push_all(&*variants); + self.ignore_variant_stack.extend_from_slice(&*variants); intravisit::walk_arm(self, arm); self.ignore_variant_stack.truncate(len); } else { diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 5563cd80438..3f91c20c32a 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -1523,7 +1523,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { parameters: new_parameters }; let mut new_segs = Vec::new(); - new_segs.push_all(path.segments.split_last().unwrap().1); + new_segs.extend_from_slice(path.segments.split_last().unwrap().1); new_segs.push(new_seg); hir::Path { span: path.span, @@ -1831,7 +1831,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, Some(node) => match node { ast_map::NodeItem(item) => match item.node { hir::ItemFn(_, _, _, _, ref gen, _) => { - taken.push_all(&gen.lifetimes); + taken.extend_from_slice(&gen.lifetimes); None }, _ => None @@ -1839,7 +1839,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, ast_map::NodeImplItem(ii) => { match ii.node { hir::ImplItemKind::Method(ref sig, _) => { - taken.push_all(&sig.generics.lifetimes); + taken.extend_from_slice(&sig.generics.lifetimes); Some(ii.id) } _ => None, @@ -1856,7 +1856,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, Some(node) => match node { ast_map::NodeItem(item) => match item.node { hir::ItemImpl(_, _, ref gen, _, _, _) => { - taken.push_all(&gen.lifetimes); + taken.extend_from_slice(&gen.lifetimes); } _ => () }, diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index e794ab39e54..031b50f4620 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -178,7 +178,7 @@ pub fn pat_contains_ref_binding(dm: &RefCell, pat: &hir::Pat) -> Option< pub fn arm_contains_ref_binding(dm: &RefCell, arm: &hir::Arm) -> Option { arm.pats.iter() .filter_map(|pat| pat_contains_ref_binding(dm, pat)) - .max_by(|m| match *m { + .max_by_key(|m| match *m { hir::MutMutable => 1, hir::MutImmutable => 0, }) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index e3504b6a744..546b91c9d5d 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -630,7 +630,7 @@ impl RegionMaps { } *vec = Vec::with_capacity(64); - vec.push_all(buf); + vec.extend_from_slice(buf); loop { vec.push(scope); match scope_map[scope.0 as usize].into_option() { diff --git a/src/librustc/middle/ty/sty.rs b/src/librustc/middle/ty/sty.rs index 37ed716eaa0..425a324c7e0 100644 --- a/src/librustc/middle/ty/sty.rs +++ b/src/librustc/middle/ty/sty.rs @@ -1185,7 +1185,8 @@ impl<'tcx> TyS<'tcx> { } TyTrait(ref obj) => { let mut v = vec![obj.bounds.region_bound]; - v.push_all(obj.principal.skip_binder().substs.regions().as_slice()); + v.extend_from_slice(obj.principal.skip_binder() + .substs.regions().as_slice()); v } TyEnum(_, substs) | diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index dbeb4c3ed73..ecc93ce1ba0 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -659,7 +659,7 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig { append_configuration(&mut user_cfg, InternedString::new("test")) } let mut v = user_cfg.into_iter().collect::>(); - v.push_all(&default_cfg[..]); + v.extend_from_slice(&default_cfg[..]); v } @@ -818,7 +818,7 @@ pub fn rustc_short_optgroups() -> Vec { /// long-term interface for rustc. pub fn rustc_optgroups() -> Vec { let mut opts = rustc_short_optgroups(); - opts.push_all(&[ + opts.extend_from_slice(&[ opt::multi("", "extern", "Specify where an external rust library is \ located", "NAME=PATH"), diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index c6f58ef2880..2a3d9cfa6b8 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -18,7 +18,7 @@ use std::fmt::Debug; use std::hash::Hash; use std::iter::repeat; use std::path::Path; -use std::time::Duration; +use std::time::Instant; use rustc_front::hir; use rustc_front::intravisit; @@ -44,15 +44,9 @@ pub fn time(do_it: bool, what: &str, f: F) -> T where r }); - let mut rv = None; - let dur = { - let ref mut rvp = rv; - - Duration::span(move || { - *rvp = Some(f()) - }) - }; - let rv = rv.unwrap(); + let start = Instant::now(); + let rv = f(); + let dur = start.elapsed(); // Hack up our own formatting for the duration to make it easier for scripts // to parse (always use the same number of decimal places and the same unit). diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index 593e1c2a726..700cfb645bf 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -36,10 +36,9 @@ #![feature(libc)] #![feature(rand)] #![feature(rustc_private)] -#![feature(slice_bytes)] +#![feature(clone_from_slice)] #![feature(staged_api)] #![feature(step_by)] -#![feature(vec_push_all)] #![cfg_attr(test, feature(test, rand))] extern crate syntax; diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index 6674d3135a0..b926f8b061e 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -35,7 +35,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec { let libs = config.used_crates.clone(); let libs = libs.into_iter().filter_map(|(_, l)| l).collect::>(); let rpaths = get_rpaths(config, &libs[..]); - flags.push_all(&rpaths_to_flags(&rpaths[..])); + flags.extend_from_slice(&rpaths_to_flags(&rpaths[..])); flags } @@ -73,7 +73,7 @@ fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec { log_rpaths("fallback", &fallback_rpaths[..]); let mut rpaths = rel_rpaths; - rpaths.push_all(&fallback_rpaths[..]); + rpaths.extend_from_slice(&fallback_rpaths[..]); // Remove duplicates let rpaths = minimize_rpaths(&rpaths[..]); diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index 4f904c20a51..840f9abce93 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -12,7 +12,6 @@ //! use. This implementation is not intended for external use or for any use where security is //! important. -use std::slice::bytes::{MutableByteVector, copy_memory}; use serialize::hex::ToHex; /// Write a u32 into a vector, which must be 4 bytes long. The value is written in big-endian @@ -134,16 +133,14 @@ impl FixedBuffer for FixedBuffer64 { if self.buffer_idx != 0 { let buffer_remaining = size - self.buffer_idx; if input.len() >= buffer_remaining { - copy_memory( - &input[..buffer_remaining], - &mut self.buffer[self.buffer_idx..size]); + self.buffer[self.buffer_idx..size] + .clone_from_slice(&input[..buffer_remaining]); self.buffer_idx = 0; func(&self.buffer); i += buffer_remaining; } else { - copy_memory( - input, - &mut self.buffer[self.buffer_idx..self.buffer_idx + input.len()]); + self.buffer[self.buffer_idx..self.buffer_idx + input.len()] + .clone_from_slice(input); self.buffer_idx += input.len(); return; } @@ -160,9 +157,7 @@ impl FixedBuffer for FixedBuffer64 { // data left in the input vector will be less than the buffer size and the buffer will // be empty. let input_remaining = input.len() - i; - copy_memory( - &input[i..], - &mut self.buffer[..input_remaining]); + self.buffer[..input_remaining].clone_from_slice(&input[i..]); self.buffer_idx += input_remaining; } @@ -172,7 +167,9 @@ impl FixedBuffer for FixedBuffer64 { fn zero_until(&mut self, idx: usize) { assert!(idx >= self.buffer_idx); - self.buffer[self.buffer_idx..idx].set_memory(0); + for slot in self.buffer[self.buffer_idx..idx].iter_mut() { + *slot = 0; + } self.buffer_idx = idx; } diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs index 3ea5cfcaff0..97816a2b2ae 100644 --- a/src/librustc_bitflags/lib.rs +++ b/src/librustc_bitflags/lib.rs @@ -16,7 +16,7 @@ #![feature(staged_api)] #![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] -#![feature(no_std)] +#![cfg_attr(stage0, feature(no_std))] #![no_std] #![unstable(feature = "rustc_private", issue = "27812")] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 3a91b573fd4..e293a950687 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -32,7 +32,6 @@ #![feature(rustc_private)] #![feature(set_stdio)] #![feature(staged_api)] -#![feature(vec_push_all)] #![feature(raw)] // remove after snapshot extern crate arena; @@ -932,12 +931,12 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry { use syntax::diagnostics::registry::Registry; let mut all_errors = Vec::new(); - all_errors.push_all(&rustc::DIAGNOSTICS); - all_errors.push_all(&rustc_typeck::DIAGNOSTICS); - all_errors.push_all(&rustc_borrowck::DIAGNOSTICS); - all_errors.push_all(&rustc_resolve::DIAGNOSTICS); - all_errors.push_all(&rustc_privacy::DIAGNOSTICS); - all_errors.push_all(&rustc_trans::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_typeck::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_borrowck::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_resolve::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_trans::DIAGNOSTICS); Registry::new(&*all_errors) } diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 26187ade464..2b9adf5490a 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -32,7 +32,6 @@ #![feature(libc)] #![feature(link_args)] #![feature(staged_api)] -#![feature(vec_push_all)] #![feature(linked_from)] extern crate libc; @@ -2309,7 +2308,7 @@ pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef, let slice = slice::from_raw_parts(ptr as *const u8, size as usize); let sr = sr as RustStringRepr; - (*sr).borrow_mut().push_all(slice); + (*sr).borrow_mut().extend_from_slice(slice); } pub fn build_string(f: F) -> Option where F: FnOnce(RustStringRef){ diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index 822b11112f2..aae3a762c19 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -122,8 +122,8 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { cdata.with_local_path(|cpath| { let mut r = Vec::with_capacity(cpath.len() + path.len()); - r.push_all(cpath); - r.push_all(&path); + r.extend_from_slice(cpath); + r.extend_from_slice(&path); r }) } @@ -135,7 +135,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { let mut r = Vec::with_capacity(path.len() + 1); let crate_name = hir_map::PathMod(token::intern(&cdata.name)); r.push(crate_name); - r.push_all(&path); + r.extend_from_slice(&path); r } diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 6affbd2b593..d2a6b0eaedf 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -19,13 +19,12 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_patterns)] -#![feature(duration_span)] #![feature(enumset)] #![feature(quote)] -#![feature(staged_api)] -#![feature(vec_push_all)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] +#![feature(staged_api)] +#![feature(time2)] #[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/librustc_metadata/loader.rs b/src/librustc_metadata/loader.rs index 72938a7660a..bd9f9c36f63 100644 --- a/src/librustc_metadata/loader.rs +++ b/src/librustc_metadata/loader.rs @@ -237,7 +237,7 @@ use std::io; use std::path::{Path, PathBuf}; use std::ptr; use std::slice; -use std::time::Duration; +use std::time::Instant; use flate; @@ -728,12 +728,11 @@ impl ArchiveMetadata { // Just a small wrapper to time how long reading metadata takes. fn get_metadata_section(target: &Target, filename: &Path) -> Result { - let mut ret = None; - let dur = Duration::span(|| { - ret = Some(get_metadata_section_imp(target, filename)); - }); - info!("reading {:?} => {:?}", filename.file_name().unwrap(), dur); - ret.unwrap() + let start = Instant::now(); + let ret = get_metadata_section_imp(target, filename); + info!("reading {:?} => {:?}", filename.file_name().unwrap(), + start.elapsed()); + return ret } fn get_metadata_section_imp(target: &Target, filename: &Path) diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index d03af6b6722..34f289456bb 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -280,7 +280,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> { let mut result = String::new(); while self.peek() != term { unsafe { - result.as_mut_vec().push_all(&[self.next_byte()]) + result.as_mut_vec().extend_from_slice(&[self.next_byte()]) } } self.next(); diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index d7b4243afee..975323375f1 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -907,7 +907,7 @@ fn link_natively(sess: &Session, dylib: bool, prog.status)); sess.note(&format!("{:?}", &cmd)); let mut output = prog.stderr.clone(); - output.push_all(&prog.stdout); + output.extend_from_slice(&prog.stdout); sess.note(&*escape_string(&output[..])); sess.abort_if_errors(); } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 5ac27d61227..c553843f858 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -925,7 +925,7 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) { prog.status)); sess.note(&format!("{:?}", &cmd)); let mut note = prog.stderr.clone(); - note.push_all(&prog.stdout); + note.extend_from_slice(&prog.stdout); sess.note(str::from_utf8(¬e[..]).unwrap()); sess.abort_if_errors(); } diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index b672c49bdca..83d0106fd4c 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -30,7 +30,6 @@ #![feature(const_fn)] #![feature(custom_attribute)] #![allow(unused_attributes)] -#![feature(iter_cmp)] #![feature(iter_arith)] #![feature(libc)] #![feature(path_relative_from)] @@ -40,7 +39,6 @@ #![feature(slice_patterns)] #![feature(staged_api)] #![feature(unicode)] -#![feature(vec_push_all)] #![allow(trivial_casts)] diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index b2e989bc874..1687b229a7f 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -559,7 +559,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, enter_match(bcx, dm, m, col, val, |pats| { if pat_is_binding_or_wild(&dm.borrow(), &*pats[col]) { let mut r = pats[..col].to_vec(); - r.push_all(&pats[col + 1..]); + r.extend_from_slice(&pats[col + 1..]); Some(r) } else { None @@ -877,7 +877,7 @@ fn pick_column_to_specialize(def_map: &RefCell, m: &[Match]) -> Option(mut bcx: Block<'blk, 'tcx>, let dm = &tcx.def_map; let mut vals_left = vals[0..col].to_vec(); - vals_left.push_all(&vals[col + 1..]); + vals_left.extend_from_slice(&vals[col + 1..]); let ccx = bcx.fcx.ccx; // Find a real id (we're adding placeholder wildcard patterns, but @@ -1241,7 +1241,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let mut vals: Vec<_> = field_vals.into_iter() .map(|v|MatchInput::from_val(v)) .collect(); - vals.push_all(&vals_left); + vals.extend_from_slice(&vals_left); compile_submatch(bcx, &pats, &vals, chk, has_genuine_default); return; } @@ -1401,7 +1401,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let mut opt_vals: Vec<_> = unpacked.into_iter() .map(|v|MatchInput::from_val(v)) .collect(); - opt_vals.push_all(&vals_left[..]); + opt_vals.extend_from_slice(&vals_left[..]); compile_submatch(opt_cx, &opt_ms[..], &opt_vals[..], diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index a4f66110450..29ba2d65e6b 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -346,7 +346,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, // Use the minimum integer type we figured out above let fields : Vec<_> = cases.iter().map(|c| { let mut ftys = vec!(ty_of_inttype(cx.tcx(), min_ity)); - ftys.push_all(&c.tys); + ftys.extend_from_slice(&c.tys); if dtor { ftys.push(cx.tcx().dtor_type()); } mk_struct(cx, &ftys, false, t) }).collect(); @@ -399,7 +399,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let fields : Vec<_> = cases.iter().map(|c| { let mut ftys = vec!(ty_of_inttype(cx.tcx(), ity)); - ftys.push_all(&c.tys); + ftys.extend_from_slice(&c.tys); if dtor { ftys.push(cx.tcx().dtor_type()); } mk_struct(cx, &ftys[..], false, t) }).collect(); @@ -444,7 +444,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, let field_ty = monomorphize::field_ty(tcx, substs, &nonzero_fields[0]); match field_ty.sty { ty::TyRawPtr(ty::TypeAndMut { ty, .. }) if !type_is_sized(tcx, ty) => { - path.push_all(&[0, FAT_PTR_ADDR]); + path.extend_from_slice(&[0, FAT_PTR_ADDR]); Some(path) }, ty::TyRawPtr(..) | ty::TyInt(..) | ty::TyUint(..) => { @@ -1212,9 +1212,9 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr let (max_sz, _) = union_size_and_align(&cases[..]); let lldiscr = C_integral(ll_inttype(ccx, ity), discr as u64, true); let mut f = vec![lldiscr]; - f.push_all(vals); + f.extend_from_slice(vals); let mut contents = build_const_struct(ccx, case, &f[..]); - contents.push_all(&[padding(ccx, max_sz - case.size)]); + contents.extend_from_slice(&[padding(ccx, max_sz - case.size)]); C_struct(ccx, &contents[..], false) } Univariant(ref st, _dro) => { diff --git a/src/librustc_trans/trans/asm.rs b/src/librustc_trans/trans/asm.rs index c59237e3078..1de94bed3dd 100644 --- a/src/librustc_trans/trans/asm.rs +++ b/src/librustc_trans/trans/asm.rs @@ -71,7 +71,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) callee::DontAutorefArg, &mut inputs); } - inputs.push_all(&ext_inputs[..]); + inputs.extend_from_slice(&ext_inputs[..]); // no failure occurred preparing operands, no need to cleanup fcx.pop_custom_cleanup_scope(temp_scope); diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/trans/attributes.rs index 90a649405cd..28dfa4e07e6 100644 --- a/src/librustc_trans/trans/attributes.rs +++ b/src/librustc_trans/trans/attributes.rs @@ -156,7 +156,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx match fn_sig.inputs[0].sty { ty::TyTuple(ref inputs) => { let mut full_inputs = vec![env_ty.expect("Missing closure environment")]; - full_inputs.push_all(inputs); + full_inputs.extend_from_slice(inputs); full_inputs } _ => ccx.sess().bug("expected tuple'd inputs") @@ -167,7 +167,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx match fn_sig.inputs[1].sty { ty::TyTuple(ref t_in) => { - inputs.push_all(&t_in[..]); + inputs.extend_from_slice(&t_in[..]); inputs } _ => ccx.sess().bug("expected tuple'd inputs") diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index d6b33672df0..e6f215cee67 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2772,7 +2772,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &hir::Crate, reachable: &N cx.tcx(), cx.export_map(), cx.item_symbols(), cx.link_meta(), reachable, krate); let mut compressed = cstore.metadata_encoding_version().to_vec(); - compressed.push_all(&flate::deflate_bytes(&metadata)); + compressed.extend_from_slice(&flate::deflate_bytes(&metadata)); let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[..]); let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false); diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 0c0bda45d8c..4aa7c0ff587 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -1009,7 +1009,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, } } ArgVals(vs) => { - llargs.push_all(vs); + llargs.extend_from_slice(vs); } } diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index c6ca2e176aa..d4d2f01f774 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -376,7 +376,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { self.local_ccxs .iter() .zip(0..self.local_ccxs.len()) - .min_by(|&(local_ccx, _idx)| local_ccx.n_llvm_insns.get()) + .min_by_key(|&(local_ccx, _idx)| local_ccx.n_llvm_insns.get()) .unwrap(); CrateContext { shared: self, diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7de262dfa5b..84d2a63580e 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1036,7 +1036,7 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>, let hi = bounds.iter().map(|x| match *x { hir::TraitTyParamBound(ref tr, _) => tr.span.hi, hir::RegionTyParamBound(ref r) => r.span.hi, - }).max_by(|x| x.to_usize()); + }).max_by_key(|x| x.to_usize()); let full_span = hi.map(|hi| Span { lo: ty.span.lo, hi: hi, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 1a3812147d8..8c68a546235 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -451,7 +451,7 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // supertype, as the "discriminant type" (issue #23116). let contains_ref_bindings = arms.iter() .filter_map(|a| tcx.arm_contains_ref_binding(a)) - .max_by(|m| match *m { + .max_by_key(|m| match *m { hir::MutMutable => 1, hir::MutImmutable => 0, }); diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 5f4eecf4951..f980945dbf2 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -1733,7 +1733,7 @@ fn projection_declared_bounds<'a, 'tcx>(rcx: &Rcx<'a,'tcx>, let mut declared_bounds = declared_generic_bounds_from_env(rcx, GenericKind::Projection(projection_ty)); - declared_bounds.push_all( + declared_bounds.extend_from_slice( &declared_projection_bounds_from_trait(rcx, span, projection_ty)); declared_bounds diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 4c09df41895..495b8995cee 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -77,14 +77,11 @@ This API is completely unstable and subject to change. #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(drain)] -#![feature(iter_cmp)] #![feature(iter_arith)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(vec_push_all)] #![feature(cell_extras)] #[macro_use] extern crate log; diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index f51770fd653..e440b117186 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -35,12 +35,10 @@ #![no_std] #![cfg_attr(stage0, feature(rustc_attrs))] +#![cfg_attr(stage0, feature(no_std))] #![cfg_attr(stage0, allow(unused_attributes))] #![feature(core_char_ext)] -#![feature(core_slice_ext)] -#![feature(core_str_ext)] #![feature(lang_items)] -#![feature(no_std)] #![feature(staged_api)] mod tables; diff --git a/src/librustc_unicode/tables.rs b/src/librustc_unicode/tables.rs index a314ffb2642..cf75cf52577 100644 --- a/src/librustc_unicode/tables.rs +++ b/src/librustc_unicode/tables.rs @@ -18,7 +18,6 @@ pub const UNICODE_VERSION: (u64, u64, u64) = (8, 0, 0); fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { use core::cmp::Ordering::{Equal, Less, Greater}; - use core::slice::SliceExt; r.binary_search_by(|&(lo,hi)| { if lo <= c && c <= hi { Equal } else if hi < c { Less } @@ -1190,7 +1189,6 @@ pub mod property { pub mod conversions { use core::cmp::Ordering::{Equal, Less, Greater}; - use core::slice::SliceExt; use core::option::Option; use core::option::Option::{Some, None}; use core::result::Result::{Ok, Err}; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 6997fa45cec..1b450092dbd 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -31,7 +31,6 @@ #![feature(staged_api)] #![feature(test)] #![feature(unicode)] -#![feature(vec_push_all)] extern crate arena; extern crate getopts; diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index d011ba08a9c..957957eaec6 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -346,7 +346,7 @@ pub fn unindent(s: &str) -> String { if !lines.is_empty() { let mut unindented = vec![ lines[0].trim().to_string() ]; - unindented.push_all(&lines[1..].iter().map(|&line| { + unindented.extend_from_slice(&lines[1..].iter().map(|&line| { if line.chars().all(|c| c.is_whitespace()) { line.to_string() } else { diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index c8b377ba3be..77c4149f992 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -986,8 +986,6 @@ impl HashMap /// # Examples /// /// ``` - /// #![feature(drain)] - /// /// use std::collections::HashMap; /// /// let mut a = HashMap::new(); @@ -1002,9 +1000,7 @@ impl HashMap /// assert!(a.is_empty()); /// ``` #[inline] - #[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain { fn last_two((_, b, c): (A, B, C)) -> (B, C) { (b, c) } let last_two: fn((SafeHash, K, V)) -> (K, V) = last_two; // coerce to fn pointer @@ -1327,9 +1323,7 @@ impl<'a, K, V> Clone for Values<'a, K, V> { } /// HashMap drain iterator. -#[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] +#[stable(feature = "drain", since = "1.6.0")] pub struct Drain<'a, K: 'a, V: 'a> { inner: iter::Map, fn((SafeHash, K, V)) -> (K, V)> } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index daabb0f9fa8..08f356463bc 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -413,9 +413,7 @@ impl HashSet /// Clears the set, returning all elements in an iterator. #[inline] - #[unstable(feature = "drain", - reason = "matches collection reform specification, waiting for dust to settle", - issue = "27711")] + #[stable(feature = "drain", since = "1.6.0")] pub fn drain(&mut self) -> Drain { fn first((a, _): (A, B)) -> A { a } let first: fn((T, ())) -> T = first; // coerce to fn pointer diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 7409d9b45d2..90b108e6770 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -72,6 +72,8 @@ impl OsString { /// On Windows system, only UTF-8 byte sequences will successfully /// convert; non UTF-8 data will produce `None`. #[unstable(feature = "convert", reason = "recently added", issue = "27704")] + #[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics", + since = "1.6.0")] pub fn from_bytes(bytes: B) -> Option where B: Into> { Self::_from_bytes(bytes.into()) } @@ -256,6 +258,8 @@ impl OsStr { /// valid unicode, in which case it produces UTF-8-encoded /// data. This may entail checking validity. #[unstable(feature = "convert", reason = "recently added", issue = "27704")] + #[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics", + since = "1.6.0")] pub fn to_bytes(&self) -> Option<&[u8]> { if cfg!(windows) { self.to_str().map(|s| s.as_bytes()) @@ -272,6 +276,9 @@ impl OsStr { /// `self.to_bytes()`, and inherits the platform behavior of the /// `to_bytes` method. #[unstable(feature = "convert", reason = "recently added", issue = "27704")] + #[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics", + since = "1.6.0")] + #[allow(deprecated)] pub fn to_cstring(&self) -> Option { self.to_bytes().and_then(|b| CString::new(b).ok()) } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 7f256e6fae0..bfad2248359 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -91,6 +91,8 @@ pub struct DirEntry(fs_imp::DirEntry); may change and this may end up accounting for files such \ as symlinks differently", issue = "27707")] +#[rustc_deprecated(reason = "superceded by the walkdir crate", + since = "1.6.0")] pub struct WalkDir { cur: Option, stack: Vec>, @@ -156,8 +158,7 @@ pub struct FileType(fs_imp::FileType); /// A builder used to create directories in various manners. /// /// This builder also supports platform-specific options. -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] +#[stable(feature = "dir_builder", since = "1.6.0")] pub struct DirBuilder { inner: fs_imp::DirBuilder, recursive: bool, @@ -1132,16 +1133,23 @@ pub fn read_dir>(path: P) -> io::Result { may change and this may end up accounting for files such \ as symlinks differently", issue = "27707")] +#[rustc_deprecated(reason = "superceded by the walkdir crate", + since = "1.6.0")] +#[allow(deprecated)] pub fn walk_dir>(path: P) -> io::Result { _walk_dir(path.as_ref()) } +#[allow(deprecated)] fn _walk_dir(path: &Path) -> io::Result { let start = try!(read_dir(path)); Ok(WalkDir { cur: Some(start), stack: Vec::new() }) } #[unstable(feature = "fs_walk", issue = "27707")] +#[rustc_deprecated(reason = "superceded by the walkdir crate", + since = "1.6.0")] +#[allow(deprecated)] impl Iterator for WalkDir { type Item = io::Result; @@ -1275,11 +1283,10 @@ pub fn set_permissions>(path: P, perm: Permissions) fs_imp::set_perm(path.as_ref(), perm.0) } -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] impl DirBuilder { /// Creates a new set of options with default mode/security settings for all /// platforms and also non-recursive. + #[stable(feature = "dir_builder", since = "1.6.0")] pub fn new() -> DirBuilder { DirBuilder { inner: fs_imp::DirBuilder::new(), @@ -1292,6 +1299,7 @@ impl DirBuilder { /// permissions settings. /// /// This option defaults to `false` + #[stable(feature = "dir_builder", since = "1.6.0")] pub fn recursive(&mut self, recursive: bool) -> &mut Self { self.recursive = recursive; self @@ -1303,7 +1311,6 @@ impl DirBuilder { /// # Examples /// /// ```no_run - /// #![feature(dir_builder)] /// use std::fs::{self, DirBuilder}; /// /// let path = "/tmp/foo/bar/baz"; @@ -1313,6 +1320,7 @@ impl DirBuilder { /// /// assert!(fs::metadata(path).unwrap().is_dir()); /// ``` + #[stable(feature = "dir_builder", since = "1.6.0")] pub fn create>(&self, path: P) -> io::Result<()> { self._create(path.as_ref()) } diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index e4f00c4874e..de09451e7c0 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -13,7 +13,6 @@ use io::prelude::*; use cmp; use io::{self, SeekFrom, Error, ErrorKind}; -use slice; /// A `Cursor` wraps another type and provides it with a /// [`Seek`](trait.Seek.html) implementation. @@ -255,8 +254,8 @@ impl Write for Cursor> { // there (left), and what will be appended on the end (right) let space = self.inner.len() - pos as usize; let (left, right) = buf.split_at(cmp::min(space, buf.len())); - slice::bytes::copy_memory(left, &mut self.inner[(pos as usize)..]); - self.inner.push_all(right); + self.inner[(pos as usize)..].clone_from_slice(left); + self.inner.extend_from_slice(right); // Bump us forward self.set_position(pos + buf.len() as u64); diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index 6f18aad6235..4af9596d6d0 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -79,6 +79,7 @@ struct Custom { /// exhaustively match against it. #[derive(Copy, PartialEq, Eq, Clone, Debug)] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub enum ErrorKind { /// An entity was not found, often a file. #[stable(feature = "rust1", since = "1.0.0")] @@ -155,9 +156,20 @@ pub enum ErrorKind { /// This typically means that an operation could only succeed if it read a /// particular number of bytes but only a smaller number of bytes could be /// read. - #[unstable(feature = "read_exact", reason = "recently added", issue = "27585")] + #[unstable(feature = "read_exact_old", reason = "recently added", + issue = "0")] + #[rustc_deprecated(since = "1.6.0", reason = "renamed to UnexpectedEof")] UnexpectedEOF, + /// An error returned when an operation could not be completed because an + /// "end of file" was reached prematurely. + /// + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. + #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + /// Any I/O error not part of this list. #[unstable(feature = "io_error_internals", reason = "better expressed through extensible enums that this \ diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index 5b587dd921b..95f630c9658 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -13,7 +13,6 @@ use cmp; use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; use fmt; use mem; -use slice; use string::String; use vec::Vec; @@ -157,7 +156,7 @@ impl<'a> Read for &'a [u8] { fn read(&mut self, buf: &mut [u8]) -> io::Result { let amt = cmp::min(buf.len(), self.len()); let (a, b) = self.split_at(amt); - slice::bytes::copy_memory(a, buf); + buf.clone_from_slice(a); *self = b; Ok(amt) } @@ -165,10 +164,11 @@ impl<'a> Read for &'a [u8] { #[inline] fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { if buf.len() > self.len() { - return Err(Error::new(ErrorKind::UnexpectedEOF, "failed to fill whole buffer")); + return Err(Error::new(ErrorKind::UnexpectedEof, + "failed to fill whole buffer")); } let (a, b) = self.split_at(buf.len()); - slice::bytes::copy_memory(a, buf); + buf.clone_from_slice(a); *self = b; Ok(()) } @@ -189,7 +189,7 @@ impl<'a> Write for &'a mut [u8] { fn write(&mut self, data: &[u8]) -> io::Result { let amt = cmp::min(data.len(), self.len()); let (a, b) = mem::replace(self, &mut []).split_at_mut(amt); - slice::bytes::copy_memory(&data[..amt], a); + a.clone_from_slice(&data[..amt]); *self = b; Ok(amt) } @@ -211,13 +211,13 @@ impl<'a> Write for &'a mut [u8] { impl Write for Vec { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { - self.push_all(buf); + self.extend_from_slice(buf); Ok(buf.len()) } #[inline] fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - self.push_all(buf); + self.extend_from_slice(buf); Ok(()) } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index ebf322fab4d..e957297bf62 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -593,7 +593,6 @@ pub trait Read { /// [file]: ../std/fs/struct.File.html /// /// ``` - /// #![feature(read_exact)] /// use std::io; /// use std::io::prelude::*; /// use std::fs::File; @@ -607,7 +606,7 @@ pub trait Read { /// # Ok(()) /// # } /// ``` - #[unstable(feature = "read_exact", reason = "recently added", issue = "27585")] + #[stable(feature = "read_exact", since = "1.6.0")] fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { while !buf.is_empty() { match self.read(buf) { @@ -618,7 +617,7 @@ pub trait Read { } } if !buf.is_empty() { - Err(Error::new(ErrorKind::UnexpectedEOF, + Err(Error::new(ErrorKind::UnexpectedEof, "failed to fill whole buffer")) } else { Ok(()) @@ -838,6 +837,10 @@ pub trait Read { of where errors happen is currently \ unclear and may change", issue = "27802")] + #[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] + #[allow(deprecated)] fn tee(self, out: W) -> Tee where Self: Sized { Tee { reader: self, writer: out } } @@ -1101,6 +1104,10 @@ pub trait Write { of where errors happen is currently \ unclear and may change", issue = "27802")] + #[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] + #[allow(deprecated)] fn broadcast(self, other: W) -> Broadcast where Self: Sized { @@ -1189,11 +1196,11 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) }; match available.iter().position(|x| *x == delim) { Some(i) => { - buf.push_all(&available[..i + 1]); + buf.extend_from_slice(&available[..i + 1]); (true, i + 1) } None => { - buf.push_all(available); + buf.extend_from_slice(available); (false, available.len()) } } @@ -1484,6 +1491,9 @@ pub trait BufRead: Read { /// [broadcast]: trait.Write.html#method.broadcast #[unstable(feature = "io", reason = "awaiting stability of Write::broadcast", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] pub struct Broadcast { first: T, second: U, @@ -1491,6 +1501,10 @@ pub struct Broadcast { #[unstable(feature = "io", reason = "awaiting stability of Write::broadcast", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] +#[allow(deprecated)] impl Write for Broadcast { fn write(&mut self, data: &[u8]) -> Result { let n = try!(self.first.write(data)); @@ -1593,6 +1607,9 @@ impl BufRead for Take { /// [tee]: trait.Read.html#method.tee #[unstable(feature = "io", reason = "awaiting stability of Read::tee", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] pub struct Tee { reader: R, writer: W, @@ -1600,6 +1617,10 @@ pub struct Tee { #[unstable(feature = "io", reason = "awaiting stability of Read::tee", issue = "27802")] +#[rustc_deprecated(reason = "error handling semantics unclear and \ + don't seem to have an ergonomic resolution", + since = "1.6.0")] +#[allow(deprecated)] impl Read for Tee { fn read(&mut self, buf: &mut [u8]) -> Result { let n = try!(self.reader.read(buf)); @@ -1907,7 +1928,7 @@ mod tests { let mut c = Cursor::new(&b""[..]); assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); let mut c = Cursor::new(&b"123"[..]).chain(Cursor::new(&b"456789"[..])); c.read_exact(&mut buf).unwrap(); @@ -1915,7 +1936,7 @@ mod tests { c.read_exact(&mut buf).unwrap(); assert_eq!(&buf, b"5678"); assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); } #[test] @@ -1924,11 +1945,11 @@ mod tests { let mut c = &b""[..]; assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); let mut c = &b"123"[..]; assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(), - io::ErrorKind::UnexpectedEOF); + io::ErrorKind::UnexpectedEof); // make sure the optimized (early returning) method is being used assert_eq!(&buf, &[0; 4]); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 37a58fdeda4..0385dff65d1 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -217,6 +217,7 @@ #![cfg_attr(stage0, allow(improper_ctypes))] #![cfg_attr(stage0, feature(rustc_attrs))] +#![cfg_attr(stage0, feature(no_std))] #![cfg_attr(stage0, allow(unused_attributes))] #![feature(alloc)] #![feature(allow_internal_unstable)] @@ -230,12 +231,10 @@ #![feature(collections)] #![feature(collections_bound)] #![feature(const_fn)] -#![feature(core)] #![feature(core_float)] #![feature(core_intrinsics)] #![feature(core_simd)] #![feature(decode_utf16)] -#![feature(drain)] #![feature(drop_in_place)] #![feature(dropck_parametricity)] #![feature(float_extras)] @@ -249,7 +248,6 @@ #![feature(link_args)] #![feature(linkage)] #![feature(macro_reexport)] -#![feature(no_std)] #![feature(oom)] #![feature(optin_builtin_traits)] #![feature(placement_in_syntax)] @@ -288,7 +286,7 @@ // imported by the compiler (via our #[no_std] attribute) In this case we just // add a new crate name so we can attach the reexports to it. #[macro_reexport(assert, assert_eq, debug_assert, debug_assert_eq, - unreachable, unimplemented, write, writeln)] + unreachable, unimplemented, write, writeln, try)] extern crate core as __core; #[macro_use] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 7a1ab790b0b..0917346213f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -120,46 +120,6 @@ macro_rules! println { ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*)); } -/// Helper macro for unwrapping `Result` values while returning early with an -/// error if the value of the expression is `Err`. Can only be used in -/// functions that return `Result` because of the early return of `Err` that -/// it provides. -/// -/// # Examples -/// -/// ``` -/// use std::io; -/// use std::fs::File; -/// use std::io::prelude::*; -/// -/// fn write_to_file_using_try() -> Result<(), io::Error> { -/// let mut file = try!(File::create("my_best_friends.txt")); -/// try!(file.write_all(b"This is a list of my best friends.")); -/// println!("I wrote to the file"); -/// Ok(()) -/// } -/// // This is equivalent to: -/// fn write_to_file_using_match() -> Result<(), io::Error> { -/// let mut file = try!(File::create("my_best_friends.txt")); -/// match file.write_all(b"This is a list of my best friends.") { -/// Ok(_) => (), -/// Err(e) => return Err(e), -/// } -/// println!("I wrote to the file"); -/// Ok(()) -/// } -/// ``` -#[macro_export] -#[stable(feature = "rust1", since = "1.0.0")] -macro_rules! try { - ($expr:expr) => (match $expr { - $crate::result::Result::Ok(val) => val, - $crate::result::Result::Err(err) => { - return $crate::result::Result::Err($crate::convert::From::from(err)) - } - }) -} - /// A macro to select an event from a number of receivers. /// /// This macro is used to wait for the first event to occur on a number of diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index c175482bbec..9c4e2b1a54c 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -14,7 +14,9 @@ use fmt; use hash; use io; use mem; -use net::{lookup_host, ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr}; +use net::{lookup_host, ntoh, hton, Ipv4Addr, Ipv6Addr}; +#[allow(deprecated)] +use net::IpAddr; use option; use sys::net::netc as c; use sys_common::{FromInner, AsInner, IntoInner}; @@ -49,6 +51,9 @@ pub struct SocketAddrV6 { inner: c::sockaddr_in6 } impl SocketAddr { /// Creates a new socket address from the (ip, port) pair. #[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")] + #[rustc_deprecated(reason = "ip type too small a type to pull its weight", + since = "1.6.0")] + #[allow(deprecated)] pub fn new(ip: IpAddr, port: u16) -> SocketAddr { match ip { IpAddr::V4(a) => SocketAddr::V4(SocketAddrV4::new(a, port)), @@ -58,6 +63,9 @@ impl SocketAddr { /// Returns the IP address associated with this socket address. #[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")] + #[rustc_deprecated(reason = "too small a type to pull its weight", + since = "1.6.0")] + #[allow(deprecated)] pub fn ip(&self) -> IpAddr { match *self { SocketAddr::V4(ref a) => IpAddr::V4(*a.ip()), @@ -351,6 +359,7 @@ impl ToSocketAddrs for SocketAddrV6 { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl ToSocketAddrs for (IpAddr, u16) { type Iter = option::IntoIter; fn to_socket_addrs(&self) -> io::Result> { diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index c657a7aa0bd..ea32ab95282 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -25,7 +25,10 @@ use sys_common::{AsInner, FromInner}; /// An IP address, either an IPv4 or IPv6 address. #[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")] +#[rustc_deprecated(reason = "too small a type to pull its weight", + since = "1.6.0")] #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, PartialOrd, Ord)] +#[allow(deprecated)] pub enum IpAddr { /// Representation of an IPv4 address. V4(Ipv4Addr), @@ -180,6 +183,7 @@ impl Ipv4Addr { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl fmt::Display for IpAddr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index 383dce737f5..6bbbabfc269 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -18,6 +18,7 @@ use io::{self, Error, ErrorKind}; use sys_common::net as net_imp; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}; @@ -136,6 +137,9 @@ pub fn lookup_host(host: &str) -> io::Result { /// cannot be resolved, it is returned in string format. #[unstable(feature = "lookup_addr", reason = "recent addition", issue = "27705")] +#[rustc_deprecated(reason = "ipaddr type is being deprecated", + since = "1.6.0")] +#[allow(deprecated)] pub fn lookup_addr(addr: &IpAddr) -> io::Result { net_imp::lookup_addr(addr) } diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 1619dac78ca..79a269ff87c 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -17,6 +17,7 @@ use prelude::v1::*; use error::Error; use fmt; +#[allow(deprecated)] use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use str::FromStr; @@ -261,6 +262,7 @@ impl<'a> Parser<'a> { self.read_atomically(|p| p.read_ipv6_addr_impl()) } + #[allow(deprecated)] fn read_ip_addr(&mut self) -> Option { let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(IpAddr::V4); let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(IpAddr::V6); @@ -306,6 +308,7 @@ impl<'a> Parser<'a> { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl FromStr for IpAddr { type Err = AddrParseError; fn from_str(s: &str) -> Result { diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index ab15867d365..c87becd741e 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -131,6 +131,7 @@ impl f32 { issue = "27736")] #[rustc_deprecated(since = "1.4.0", reason = "unclear how useful or correct this is")] + #[allow(deprecated)] pub fn from_str_radix(s: &str, radix: u32) -> Result { num::Float::from_str_radix(s, radix) } @@ -424,7 +425,7 @@ impl f32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_positive(self) -> bool { num::Float::is_positive(self) } + pub fn is_sign_positive(self) -> bool { num::Float::is_sign_positive(self) } /// Returns `true` if `self`'s sign is negative, including `-0.0` /// and `NEG_INFINITY`. @@ -443,7 +444,7 @@ impl f32 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_negative(self) -> bool { num::Float::is_negative(self) } + pub fn is_sign_negative(self) -> bool { num::Float::is_sign_negative(self) } /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error. This produces a more accurate result with better performance than diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index cad42ee64f1..6b9c753443b 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -88,6 +88,7 @@ impl f64 { issue = "27736")] #[rustc_deprecated(since = "1.4.0", reason = "unclear how useful or correct this is")] + #[allow(deprecated)] pub fn from_str_radix(s: &str, radix: u32) -> Result { num::Float::from_str_radix(s, radix) } @@ -352,12 +353,12 @@ impl f64 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_positive(self) -> bool { num::Float::is_positive(self) } + pub fn is_sign_positive(self) -> bool { num::Float::is_sign_positive(self) } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_positive")] #[inline] - pub fn is_positive(self) -> bool { num::Float::is_positive(self) } + pub fn is_positive(self) -> bool { num::Float::is_sign_positive(self) } /// Returns `true` if `self`'s sign is negative, including `-0.0` /// and `NEG_INFINITY`. @@ -377,12 +378,12 @@ impl f64 { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_sign_negative(self) -> bool { num::Float::is_negative(self) } + pub fn is_sign_negative(self) -> bool { num::Float::is_sign_negative(self) } #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_negative")] #[inline] - pub fn is_negative(self) -> bool { num::Float::is_negative(self) } + pub fn is_negative(self) -> bool { num::Float::is_sign_negative(self) } /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error. This produces a more accurate result with better performance than diff --git a/src/libstd/path.rs b/src/libstd/path.rs index f97ad5b8835..d0b9cc4c460 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -777,6 +777,8 @@ impl<'a> Components<'a> { /// Examine the next component without consuming it. #[unstable(feature = "path_components_peek", issue = "27727")] + #[rustc_deprecated(reason = "use peekable() instead", + since = "1.6.0")] pub fn peek(&self) -> Option> { self.clone().next() } diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 5677c5538c4..6b20e51967d 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -254,7 +254,7 @@ impl Mutex { /// /// If another user of this mutex panicked while holding the mutex, then /// this call will return an error instead. - #[unstable(feature = "mutex_into_inner", reason = "recently added", issue = "28968")] + #[stable(feature = "mutex_into_inner", since = "1.6.0")] pub fn into_inner(self) -> LockResult where T: Sized { // We know statically that there are no outstanding references to // `self` so there's no need to lock the inner StaticMutex. @@ -284,7 +284,7 @@ impl Mutex { /// /// If another user of this mutex panicked while holding the mutex, then /// this call will return an error instead. - #[unstable(feature = "mutex_get_mut", reason = "recently added", issue = "28968")] + #[stable(feature = "mutex_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { // We know statically that there are no other references to `self`, so // there's no need to lock the inner StaticMutex. diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 4c236d21545..3dbef435481 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -275,7 +275,7 @@ impl RwLock { /// is poisoned whenever a writer panics while holding an exclusive lock. An /// error will only be returned if the lock would have otherwise been /// acquired. - #[unstable(feature = "rwlock_into_inner", reason = "recently added", issue = "28968")] + #[stable(feature = "rwlock_into_inner", since = "1.6.0")] pub fn into_inner(self) -> LockResult where T: Sized { // We know statically that there are no outstanding references to // `self` so there's no need to lock the inner StaticRwLock. @@ -307,7 +307,7 @@ impl RwLock { /// is poisoned whenever a writer panics while holding an exclusive lock. An /// error will only be returned if the lock would have otherwise been /// acquired. - #[unstable(feature = "rwlock_get_mut", reason = "recently added", issue = "28968")] + #[stable(feature = "rwlock_get_mut", since = "1.6.0")] pub fn get_mut(&mut self) -> LockResult<&mut T> { // We know statically that there are no other references to `self`, so // there's no need to lock the inner StaticRwLock. diff --git a/src/libstd/sys/common/gnu/libbacktrace.rs b/src/libstd/sys/common/gnu/libbacktrace.rs index 3b846fd462e..f8463388384 100644 --- a/src/libstd/sys/common/gnu/libbacktrace.rs +++ b/src/libstd/sys/common/gnu/libbacktrace.rs @@ -134,9 +134,9 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, } else { None }; - let filename = match selfname.as_ref().and_then(|s| s.as_os_str().to_bytes()) { + let filename = match selfname.as_ref().and_then(|s| s.to_str()) { Some(path) => { - let bytes = path; + let bytes = path.as_bytes(); if bytes.len() < LAST_FILENAME.len() { let i = bytes.iter(); for (slot, val) in LAST_FILENAME.iter_mut().zip(i) { diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 449cd9d8c97..7e05895b2cc 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -15,6 +15,7 @@ use fmt; use io::{self, Error, ErrorKind}; use libc::{c_int, c_char, c_void}; use mem; +#[allow(deprecated)] use net::{SocketAddr, Shutdown, IpAddr}; use ptr; use str::from_utf8; @@ -129,6 +130,7 @@ pub fn lookup_host(host: &str) -> io::Result { // lookup_addr //////////////////////////////////////////////////////////////////////////////// +#[allow(deprecated)] pub fn lookup_addr(addr: &IpAddr) -> io::Result { init(); diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 702a34633dc..2e092d5f770 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -243,7 +243,7 @@ impl Wtf8Buf { /// Append a UTF-8 slice at the end of the string. #[inline] pub fn push_str(&mut self, other: &str) { - self.bytes.push_all(other.as_bytes()) + self.bytes.extend_from_slice(other.as_bytes()) } /// Append a WTF-8 slice at the end of the string. @@ -262,9 +262,9 @@ impl Wtf8Buf { // 4 bytes for the supplementary code point self.bytes.reserve(4 + other_without_trail_surrogate.len()); self.push_char(decode_surrogate_pair(lead, trail)); - self.bytes.push_all(other_without_trail_surrogate); + self.bytes.extend_from_slice(other_without_trail_surrogate); } - _ => self.bytes.push_all(&other.bytes) + _ => self.bytes.extend_from_slice(&other.bytes) } } @@ -331,10 +331,8 @@ impl Wtf8Buf { match self.next_surrogate(pos) { Some((surrogate_pos, _)) => { pos = surrogate_pos + 3; - slice::bytes::copy_memory( - UTF8_REPLACEMENT_CHARACTER, - &mut self.bytes[surrogate_pos .. pos], - ); + self.bytes[surrogate_pos..pos] + .clone_from_slice(UTF8_REPLACEMENT_CHARACTER); }, None => return unsafe { String::from_utf8_unchecked(self.bytes) } } @@ -493,18 +491,18 @@ impl Wtf8 { }; let wtf8_bytes = &self.bytes; let mut utf8_bytes = Vec::with_capacity(self.len()); - utf8_bytes.push_all(&wtf8_bytes[..surrogate_pos]); - utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER); + utf8_bytes.extend_from_slice(&wtf8_bytes[..surrogate_pos]); + utf8_bytes.extend_from_slice(UTF8_REPLACEMENT_CHARACTER); let mut pos = surrogate_pos + 3; loop { match self.next_surrogate(pos) { Some((surrogate_pos, _)) => { - utf8_bytes.push_all(&wtf8_bytes[pos .. surrogate_pos]); - utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER); + utf8_bytes.extend_from_slice(&wtf8_bytes[pos .. surrogate_pos]); + utf8_bytes.extend_from_slice(UTF8_REPLACEMENT_CHARACTER); pos = surrogate_pos + 3; }, None => { - utf8_bytes.push_all(&wtf8_bytes[pos..]); + utf8_bytes.extend_from_slice(&wtf8_bytes[pos..]); return Cow::Owned(unsafe { String::from_utf8_unchecked(utf8_bytes) }) } } diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index d2a16b5de97..16e1578296d 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -246,17 +246,16 @@ pub fn symlink, Q: AsRef>(src: P, dst: Q) -> io::Result<()> sys::fs::symlink(src.as_ref(), dst.as_ref()) } -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] +#[stable(feature = "dir_builder", since = "1.6.0")] /// An extension trait for `fs::DirBuilder` for unix-specific options. pub trait DirBuilderExt { /// Sets the mode to create new directories with. This option defaults to /// 0o777. + #[stable(feature = "dir_builder", since = "1.6.0")] fn mode(&mut self, mode: raw::mode_t) -> &mut Self; } -#[unstable(feature = "dir_builder", reason = "recently added API", - issue = "27710")] +#[stable(feature = "dir_builder", since = "1.6.0")] impl DirBuilderExt for fs::DirBuilder { fn mode(&mut self, mode: raw::mode_t) -> &mut fs::DirBuilder { self.as_inner_mut().set_mode(mode); diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 018c9100288..8ea8f0c6c77 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -355,8 +355,7 @@ impl DirBuilder { } fn cstr(path: &Path) -> io::Result { - path.as_os_str().to_cstring().ok_or( - io::Error::new(io::ErrorKind::InvalidInput, "path contained a null")) + Ok(try!(CString::new(path.as_os_str().as_bytes()))) } impl FromInner for File { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index dabc8090270..c2bf0651cff 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -149,7 +149,7 @@ pub fn join_paths(paths: I) -> Result if path.contains(&sep) { return Err(JoinPathsError) } - joined.push_all(path); + joined.extend_from_slice(path); } Ok(OsStringExt::from_vec(joined)) } diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index f0f08a72ed8..0524df218a1 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -53,7 +53,7 @@ impl Buf { } pub fn push_slice(&mut self, s: &Slice) { - self.inner.push_all(&s.inner) + self.inner.extend_from_slice(&s.inner) } } diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 8d80296ab03..407fcb0a1b8 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -43,7 +43,7 @@ pub struct Command { impl Command { pub fn new(program: &OsStr) -> Command { Command { - program: program.to_cstring().unwrap(), + program: os2c(program), args: Vec::new(), env: None, cwd: None, @@ -54,10 +54,10 @@ impl Command { } pub fn arg(&mut self, arg: &OsStr) { - self.args.push(arg.to_cstring().unwrap()) + self.args.push(os2c(arg)); } pub fn args<'a, I: Iterator>(&mut self, args: I) { - self.args.extend(args.map(|s| s.to_cstring().unwrap())) + self.args.extend(args.map(os2c)); } fn init_env_map(&mut self) { if self.env.is_none() { @@ -76,10 +76,14 @@ impl Command { self.env = Some(HashMap::new()) } pub fn cwd(&mut self, dir: &OsStr) { - self.cwd = Some(dir.to_cstring().unwrap()) + self.cwd = Some(os2c(dir)); } } +fn os2c(s: &OsStr) -> CString { + CString::new(s.as_bytes()).unwrap() +} + //////////////////////////////////////////////////////////////////////////////// // Processes //////////////////////////////////////////////////////////////////////////////// @@ -430,9 +434,9 @@ fn make_envp(env: Option<&HashMap>) for pair in env { let mut kv = Vec::new(); - kv.push_all(pair.0.as_bytes()); + kv.extend_from_slice(pair.0.as_bytes()); kv.push('=' as u8); - kv.push_all(pair.1.as_bytes()); + kv.extend_from_slice(pair.1.as_bytes()); kv.push(0); // terminating null tmps.push(kv); } diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 4396b90a5ce..48c9b70dce4 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -196,10 +196,10 @@ pub fn join_paths(paths: I) -> Result return Err(JoinPathsError) } else if v.contains(&sep) { joined.push(b'"' as u16); - joined.push_all(&v[..]); + joined.extend_from_slice(&v[..]); joined.push(b'"' as u16); } else { - joined.push_all(&v[..]); + joined.extend_from_slice(&v[..]); } } diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 63d517606a0..0981a8c4a5b 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -66,6 +66,8 @@ impl Duration { wait for a more general \"moment in time\" \ abstraction", issue = "27799")] + #[rustc_deprecated(reason = "use std::time::Instant instead", + since = "1.6.0")] pub fn span(f: F) -> Duration where F: FnOnce() { let start = Instant::now(); f(); diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index fc6cacb40f1..496f6a429a3 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -178,7 +178,7 @@ pub mod rt { let mut v = vec![]; for (i, x) in self.iter().enumerate() { if i > 0 { - v.push_all(&$sep); + v.extend_from_slice(&$sep); } v.extend(x.to_tokens(cx)); } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e00c3e3bea4..c456b7dc8b9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -132,7 +132,7 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option, Status ("unmarked_api", "1.0.0", None, Active), // Allows using #![no_std] - ("no_std", "1.0.0", Some(27701), Active), + ("no_std", "1.0.0", None, Accepted), // Allows using #![no_core] ("no_core", "1.3.0", Some(29639), Active), @@ -286,8 +286,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat ("plugin", CrateLevel, Gated("plugin", "compiler plugins are experimental \ and possibly buggy")), - ("no_std", CrateLevel, Gated("no_std", - "no_std is experimental")), + ("no_std", CrateLevel, Ungated), ("no_core", CrateLevel, Gated("no_core", "no_core is experimental")), ("lang", Normal, Gated("lang_items", diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 9401999465b..4498120a78f 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -29,7 +29,6 @@ #![cfg_attr(stage0, feature(rustc_attrs))] #![cfg_attr(stage0, allow(unused_attributes))] #![feature(associated_consts)] -#![feature(drain)] #![feature(filling_drop)] #![feature(libc)] #![feature(rustc_private)] @@ -37,7 +36,6 @@ #![feature(str_char)] #![feature(str_escape)] #![feature(unicode)] -#![feature(vec_push_all)] extern crate fmt_macros; extern crate serialize; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index aa55cb847fa..f7105951296 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -120,17 +120,15 @@ pub fn print_crate<'a>(cm: &'a CodeMap, // However we don't want these attributes in the AST because // of the feature gate, so we fake them up here. - let no_std_meta = attr::mk_word_item(InternedString::new("no_std")); + // #![feature(prelude_import)] let prelude_import_meta = attr::mk_word_item(InternedString::new("prelude_import")); - - // #![feature(no_std)] - let fake_attr = attr::mk_attr_inner(attr::mk_attr_id(), - attr::mk_list_item(InternedString::new("feature"), - vec![no_std_meta.clone(), - prelude_import_meta])); + let list = attr::mk_list_item(InternedString::new("feature"), + vec![prelude_import_meta]); + let fake_attr = attr::mk_attr_inner(attr::mk_attr_id(), list); try!(s.print_attribute(&fake_attr)); // #![no_std] + let no_std_meta = attr::mk_word_item(InternedString::new("no_std")); let fake_attr = attr::mk_attr_inner(attr::mk_attr_id(), no_std_meta); try!(s.print_attribute(&fake_attr)); } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 71eddd80c74..7ffe567ac83 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -37,13 +37,12 @@ #![feature(asm)] #![feature(box_syntax)] -#![feature(duration_span)] #![feature(fnbox)] -#![feature(iter_cmp)] #![feature(libc)] #![feature(rustc_private)] #![feature(set_stdio)] #![feature(staged_api)] +#![feature(time2)] extern crate getopts; extern crate serialize; @@ -79,7 +78,7 @@ use std::path::PathBuf; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; use std::thread; -use std::time::Duration; +use std::time::{Instant, Duration}; // to be used by rustc to compile tests in libtest pub mod test { @@ -714,7 +713,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec ) -> io::Res PadOnRight => t.desc.name.as_slice().len(), } } - match tests.iter().max_by(|t|len_if_padded(*t)) { + match tests.iter().max_by_key(|t|len_if_padded(*t)) { Some(t) => { let n = t.desc.name.as_slice(); st.max_name_len = n.len(); @@ -1121,12 +1120,12 @@ pub fn black_box(dummy: T) -> T { dummy } impl Bencher { /// Callback for benchmark functions to run in their body. pub fn iter(&mut self, mut inner: F) where F: FnMut() -> T { - self.dur = Duration::span(|| { - let k = self.iterations; - for _ in 0..k { - black_box(inner()); - } - }); + let start = Instant::now(); + let k = self.iterations; + for _ in 0..k { + black_box(inner()); + } + self.dur = start.elapsed(); } pub fn ns_elapsed(&mut self) -> u64 { @@ -1169,29 +1168,24 @@ impl Bencher { let mut total_run = Duration::new(0, 0); let samples : &mut [f64] = &mut [0.0_f64; 50]; loop { - let mut summ = None; - let mut summ5 = None; + let loop_start = Instant::now(); - let loop_run = Duration::span(|| { + for p in &mut *samples { + self.bench_n(n, |x| f(x)); + *p = self.ns_per_iter() as f64; + }; - for p in &mut *samples { - self.bench_n(n, |x| f(x)); - *p = self.ns_per_iter() as f64; - }; + stats::winsorize(samples, 5.0); + let summ = stats::Summary::new(samples); - stats::winsorize(samples, 5.0); - summ = Some(stats::Summary::new(samples)); + for p in &mut *samples { + self.bench_n(5 * n, |x| f(x)); + *p = self.ns_per_iter() as f64; + }; - for p in &mut *samples { - self.bench_n(5 * n, |x| f(x)); - *p = self.ns_per_iter() as f64; - }; - - stats::winsorize(samples, 5.0); - summ5 = Some(stats::Summary::new(samples)); - }); - let summ = summ.unwrap(); - let summ5 = summ5.unwrap(); + stats::winsorize(samples, 5.0); + let summ5 = stats::Summary::new(samples); + let loop_run = loop_start.elapsed(); // If we've run for 100ms and seem to have converged to a // stable median. diff --git a/src/rtstartup/rsbegin.rs b/src/rtstartup/rsbegin.rs index af9a01ea2e4..a81eac279d0 100644 --- a/src/rtstartup/rsbegin.rs +++ b/src/rtstartup/rsbegin.rs @@ -22,7 +22,7 @@ // object (usually called `crtX.o), which then invokes initialization callbacks // of other runtime components (registered via yet another special image section). -#![feature(no_std)] +#![cfg_attr(stage0, feature(no_std))] #![crate_type="rlib"] #![no_std] diff --git a/src/rtstartup/rsend.rs b/src/rtstartup/rsend.rs index ecb6a228e17..e3b691ce2f7 100644 --- a/src/rtstartup/rsend.rs +++ b/src/rtstartup/rsend.rs @@ -10,7 +10,7 @@ // See rsbegin.rs for details. -#![feature(no_std)] +#![cfg_attr(stage0, feature(no_std))] #![crate_type="rlib"] #![no_std] diff --git a/src/test/auxiliary/allocator-dummy.rs b/src/test/auxiliary/allocator-dummy.rs index 0194fb1ddda..a1d21db8f4d 100644 --- a/src/test/auxiliary/allocator-dummy.rs +++ b/src/test/auxiliary/allocator-dummy.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(allocator, no_std, core, core_intrinsics, libc)] +#![feature(allocator, core_intrinsics, libc)] #![allocator] #![crate_type = "rlib"] #![no_std] diff --git a/src/test/auxiliary/allocator1.rs b/src/test/auxiliary/allocator1.rs index 4e9cef64348..b24784838d0 100644 --- a/src/test/auxiliary/allocator1.rs +++ b/src/test/auxiliary/allocator1.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(allocator, no_std, core)] +#![feature(allocator)] #![allocator] #![crate_type = "rlib"] #![no_std] diff --git a/src/test/auxiliary/allocator2.rs b/src/test/auxiliary/allocator2.rs index 4e9cef64348..b24784838d0 100644 --- a/src/test/auxiliary/allocator2.rs +++ b/src/test/auxiliary/allocator2.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(allocator, no_std, core)] +#![feature(allocator)] #![allocator] #![crate_type = "rlib"] #![no_std] diff --git a/src/test/auxiliary/allocator3.rs b/src/test/auxiliary/allocator3.rs index 1ee21bc7ddb..d3eb1f6f7ab 100644 --- a/src/test/auxiliary/allocator3.rs +++ b/src/test/auxiliary/allocator3.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(no_std, allocator)] +#![feature(allocator)] #![no_std] #![allocator] #![crate_type = "rlib"] diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs index 7d78c426281..41ceb924ab3 100644 --- a/src/test/auxiliary/lang-item-public.rs +++ b/src/test/auxiliary/lang-item-public.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std, core, libc)] +#![feature(libc)] #![no_std] #![feature(lang_items)] diff --git a/src/test/auxiliary/needs_allocator.rs b/src/test/auxiliary/needs_allocator.rs index c09b153d921..51003160427 100644 --- a/src/test/auxiliary/needs_allocator.rs +++ b/src/test/auxiliary/needs_allocator.rs @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(no_std, needs_allocator)] +#![feature(needs_allocator)] #![no_std] #![needs_allocator] #![crate_type = "rlib"] diff --git a/src/test/auxiliary/no_std_crate.rs b/src/test/auxiliary/no_std_crate.rs index d830aef54f5..7cfae6d121d 100644 --- a/src/test/auxiliary/no_std_crate.rs +++ b/src/test/auxiliary/no_std_crate.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] pub fn foo() {} diff --git a/src/test/auxiliary/weak-lang-items.rs b/src/test/auxiliary/weak-lang-items.rs index 7342652fb96..6434e62b6f7 100644 --- a/src/test/auxiliary/weak-lang-items.rs +++ b/src/test/auxiliary/weak-lang-items.rs @@ -13,7 +13,6 @@ // This aux-file will require the eh_personality function to be codegen'd, but // it hasn't been defined just yet. Make sure we don't explode. -#![feature(no_std)] #![no_std] #![crate_type = "rlib"] diff --git a/src/test/compile-fail/cfg-attr-crate-2.rs b/src/test/compile-fail/cfg-attr-crate-2.rs index 4867dd8d0b4..a79c7663861 100644 --- a/src/test/compile-fail/cfg-attr-crate-2.rs +++ b/src/test/compile-fail/cfg-attr-crate-2.rs @@ -12,6 +12,6 @@ // https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 -#![cfg_attr(broken, no_std)] //~ ERROR no_std is experimental +#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental fn main() { } diff --git a/src/test/compile-fail/derive-no-std-not-supported.rs b/src/test/compile-fail/derive-no-std-not-supported.rs index 327e2c9e0f9..01c81a8bbce 100644 --- a/src/test/compile-fail/derive-no-std-not-supported.rs +++ b/src/test/compile-fail/derive-no-std-not-supported.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] extern crate core; diff --git a/src/test/compile-fail/fail-no-dead-code-core.rs b/src/test/compile-fail/fail-no-dead-code-core.rs index 9923db3c566..aed76e36fca 100644 --- a/src/test/compile-fail/fail-no-dead-code-core.rs +++ b/src/test/compile-fail/fail-no-dead-code-core.rs @@ -10,10 +10,9 @@ #![deny(dead_code)] #![allow(unreachable_code)] -#![feature(core)] - -#[macro_use] extern crate core; +#[macro_use] +extern crate core; fn foo() { //~ ERROR function is never used diff --git a/src/test/compile-fail/gated-no-std.rs b/src/test/compile-fail/gated-no-core.rs similarity index 91% rename from src/test/compile-fail/gated-no-std.rs rename to src/test/compile-fail/gated-no-core.rs index 893ba8a8a86..0a55a8a78ce 100644 --- a/src/test/compile-fail/gated-no-std.rs +++ b/src/test/compile-fail/gated-no-core.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![no_std] //~ ERROR no_std is experimental +#![no_core] //~ ERROR no_core is experimental fn main() {} diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index 9749e596895..26770a1d37c 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] #![allow(unused_variables)] #![allow(non_camel_case_types)] diff --git a/src/test/compile-fail/no-std-inject.rs b/src/test/compile-fail/no-std-inject.rs index a03972410c9..21675434e24 100644 --- a/src/test/compile-fail/no-std-inject.rs +++ b/src/test/compile-fail/no-std-inject.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std, core)] #![no_std] extern crate core; //~ ERROR: an external crate named `core` has already diff --git a/src/test/compile-fail/no_owned_box_lang_item.rs b/src/test/compile-fail/no_owned_box_lang_item.rs index 39fec2ddfbd..72eb687adc6 100644 --- a/src/test/compile-fail/no_owned_box_lang_item.rs +++ b/src/test/compile-fail/no_owned_box_lang_item.rs @@ -12,8 +12,8 @@ // error-pattern: requires `owned_box` lang_item +#![feature(lang_items, box_syntax)] #![no_std] -#![feature(lang_items, no_std, box_syntax)] fn main() { let x = box 1i32; diff --git a/src/test/compile-fail/placement-expr-unstable.rs b/src/test/compile-fail/placement-expr-unstable.rs index 23fc8e7a07e..b3aa4e9187d 100644 --- a/src/test/compile-fail/placement-expr-unstable.rs +++ b/src/test/compile-fail/placement-expr-unstable.rs @@ -11,7 +11,6 @@ // Check that placement in respects unstable code checks. #![feature(placement_in_syntax)] -#![feature(core)] extern crate core; diff --git a/src/test/compile-fail/single-primitive-inherent-impl.rs b/src/test/compile-fail/single-primitive-inherent-impl.rs index b2cfcfab78b..5ceb870528a 100644 --- a/src/test/compile-fail/single-primitive-inherent-impl.rs +++ b/src/test/compile-fail/single-primitive-inherent-impl.rs @@ -12,7 +12,6 @@ #![crate_type = "lib"] #![feature(lang_items)] -#![feature(no_std)] #![no_std] // OK diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs index af242b96a84..6416e1cacdc 100644 --- a/src/test/compile-fail/unused-attr.rs +++ b/src/test/compile-fail/unused-attr.rs @@ -10,7 +10,7 @@ #![deny(unused_attributes)] #![allow(dead_code, unused_imports)] -#![feature(core, custom_attribute)] +#![feature(custom_attribute)] #![foo] //~ ERROR unused attribute diff --git a/src/test/compile-fail/warn-pub-extern-crate.rs b/src/test/compile-fail/warn-pub-extern-crate.rs index fec0b8e1a4c..de3cc27c49b 100644 --- a/src/test/compile-fail/warn-pub-extern-crate.rs +++ b/src/test/compile-fail/warn-pub-extern-crate.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Check that `pub extern crate` gives a warning. - +#![feature(rustc_attrs)] pub extern crate core; //~WARN `pub extern crate` does not work -//~^ ERROR core -fn main() { -} +#[rustc_error] +fn main() {} //~ ERROR: compilation successful diff --git a/src/test/compile-fail/weak-lang-item.rs b/src/test/compile-fail/weak-lang-item.rs index e3a905c536b..fdf50c27bf4 100644 --- a/src/test/compile-fail/weak-lang-item.rs +++ b/src/test/compile-fail/weak-lang-item.rs @@ -12,7 +12,6 @@ // error-pattern: language item required, but not found: `panic_fmt` // error-pattern: language item required, but not found: `eh_personality` -#![feature(no_std)] #![no_std] extern crate core; diff --git a/src/test/run-make/alloc-extern-crates/fakealloc.rs b/src/test/run-make/alloc-extern-crates/fakealloc.rs index c64b3170ffe..43f97489314 100644 --- a/src/test/run-make/alloc-extern-crates/fakealloc.rs +++ b/src/test/run-make/alloc-extern-crates/fakealloc.rs @@ -9,10 +9,8 @@ // except according to those terms. #![crate_type = "rlib"] -#![feature(no_std)] #![no_std] - #[inline] pub unsafe fn allocate(_size: usize, _align: usize) -> *mut u8 { 0 as *mut u8 } diff --git a/src/test/run-make/no-duplicate-libs/bar.rs b/src/test/run-make/no-duplicate-libs/bar.rs index 2df7604f961..8a15afb328a 100644 --- a/src/test/run-make/no-duplicate-libs/bar.rs +++ b/src/test/run-make/no-duplicate-libs/bar.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, no_std, libc)] -#![no_std] +#![feature(lang_items, libc)] #![crate_type = "dylib"] +#![no_std] extern crate libc; diff --git a/src/test/run-make/no-duplicate-libs/foo.rs b/src/test/run-make/no-duplicate-libs/foo.rs index 4e81f0ea06e..ab8d2eca936 100644 --- a/src/test/run-make/no-duplicate-libs/foo.rs +++ b/src/test/run-make/no-duplicate-libs/foo.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, no_std, libc)] +#![feature(lang_items, libc)] #![no_std] #![crate_type = "dylib"] diff --git a/src/test/run-make/use-extern-for-plugins/foo.rs b/src/test/run-make/use-extern-for-plugins/foo.rs index 554c0fe0326..0afd3be466d 100644 --- a/src/test/run-make/use-extern-for-plugins/foo.rs +++ b/src/test/run-make/use-extern-for-plugins/foo.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] #![crate_type = "lib"] #![crate_name = "a"] diff --git a/src/test/run-pass/cfg-attr-crate.rs b/src/test/run-pass/cfg-attr-crate.rs index 25d689475fb..21dc7ff7e01 100644 --- a/src/test/run-pass/cfg-attr-crate.rs +++ b/src/test/run-pass/cfg-attr-crate.rs @@ -12,6 +12,6 @@ // pretty-expanded FIXME #23616 -#![cfg_attr(not_used, no_std)] +#![cfg_attr(not_used, no_core)] fn main() { } diff --git a/src/test/run-pass/derive-no-std.rs b/src/test/run-pass/derive-no-std.rs index e7c6b67b820..78e9da001f7 100644 --- a/src/test/run-pass/derive-no-std.rs +++ b/src/test/run-pass/derive-no-std.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std, rand, collections, rustc_private)] +#![feature(rand, collections, rustc_private)] #![no_std] extern crate rand; diff --git a/src/test/run-pass/for-loop-no-std.rs b/src/test/run-pass/for-loop-no-std.rs index 2f327bdebbf..73de1fa9c0d 100644 --- a/src/test/run-pass/for-loop-no-std.rs +++ b/src/test/run-pass/for-loop-no-std.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, start, no_std, core_slice_ext, collections)] +#![feature(lang_items, start, collections)] #![no_std] extern crate std as other; diff --git a/src/test/run-pass/format-no-std.rs b/src/test/run-pass/format-no-std.rs index baa159b0e0e..62d54da56b2 100644 --- a/src/test/run-pass/format-no-std.rs +++ b/src/test/run-pass/format-no-std.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, start, no_std, collections)] +#![feature(lang_items, start, collections)] #![no_std] extern crate std as other; diff --git a/src/test/run-pass/issue-13655.rs b/src/test/run-pass/issue-13655.rs index 11219b04f2b..51a9c9264a8 100644 --- a/src/test/run-pass/issue-13655.rs +++ b/src/test/run-pass/issue-13655.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(unboxed_closures, core)] +#![feature(fn_traits, unboxed_closures)] use std::ops::Fn; struct Foo(T); diff --git a/src/test/run-pass/issue-14958.rs b/src/test/run-pass/issue-14958.rs index ec482a776de..0709ccf1406 100644 --- a/src/test/run-pass/issue-14958.rs +++ b/src/test/run-pass/issue-14958.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(unboxed_closures, core)] +#![feature(fn_traits, unboxed_closures)] trait Foo { fn dummy(&self) { }} diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs index 5accaf36349..42824b563be 100644 --- a/src/test/run-pass/issue-14959.rs +++ b/src/test/run-pass/issue-14959.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(unboxed_closures, core)] +#![feature(fn_traits, unboxed_closures)] use std::ops::Fn; diff --git a/src/test/run-pass/issue-16739.rs b/src/test/run-pass/issue-16739.rs index f8cffdd38ca..ca2b9209eba 100644 --- a/src/test/run-pass/issue-16739.rs +++ b/src/test/run-pass/issue-16739.rs @@ -11,7 +11,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -#![feature(unboxed_closures, core)] +#![feature(unboxed_closures, fn_traits)] // Test that unboxing shim for calling rust-call ABI methods through a // trait box works and does not cause an ICE. diff --git a/src/test/run-pass/issue-18661.rs b/src/test/run-pass/issue-18661.rs index 302f5ddcc6c..48d29095ec6 100644 --- a/src/test/run-pass/issue-18661.rs +++ b/src/test/run-pass/issue-18661.rs @@ -13,10 +13,8 @@ // pretty-expanded FIXME #23616 -#![feature(unboxed_closures, core)] - pub fn inside(c: F) { - c.call(()); + c(); } // Use different number of type parameters and closure type to trigger diff --git a/src/test/run-pass/issue-19098.rs b/src/test/run-pass/issue-19098.rs index a0368063f2c..e54fdfb5b5e 100644 --- a/src/test/run-pass/issue-19098.rs +++ b/src/test/run-pass/issue-19098.rs @@ -8,18 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - -#![feature(unboxed_closures, core)] - pub trait Handler { fn handle(&self, &mut String); } -impl Handler for F -where F: for<'a, 'b> Fn(&'a mut String) { +impl Handler for F where F: for<'a, 'b> Fn(&'a mut String) { fn handle(&self, st: &mut String) { - self.call((st,)) + self(st) } } diff --git a/src/test/run-pass/issue-19982.rs b/src/test/run-pass/issue-19982.rs index 9442b039bc6..30edf24e8b1 100644 --- a/src/test/run-pass/issue-19982.rs +++ b/src/test/run-pass/issue-19982.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(core,unboxed_closures)] +#![feature(fn_traits, unboxed_closures)] #[allow(dead_code)] struct Foo; diff --git a/src/test/run-pass/issue-20544.rs b/src/test/run-pass/issue-20544.rs index c70b059d3e7..322c326ef0d 100644 --- a/src/test/run-pass/issue-20544.rs +++ b/src/test/run-pass/issue-20544.rs @@ -9,7 +9,7 @@ // except according to those terms. #![feature(unboxed_closures)] -#![feature(core)] +#![feature(fn_traits)] struct Fun(F); diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index 867cb35f1f6..5fbcfadf870 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -10,21 +10,15 @@ // Make sure #1399 stays fixed - -#![allow(unknown_features)] -#![feature(box_syntax)] -#![feature(unboxed_closures, core)] - struct A { a: Box } fn foo() -> Box isize + 'static> { - let k: Box<_> = box 22; + let k: Box<_> = Box::new(22); let _u = A {a: k.clone()}; let result = || 22; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(result) } pub fn main() { - assert_eq!(foo().call_mut(()), 22); + assert_eq!(foo()(), 22); } diff --git a/src/test/run-pass/no-std-1.rs b/src/test/run-pass/no-std-1.rs index 95bf3158e12..9298d74f9c4 100644 --- a/src/test/run-pass/no-std-1.rs +++ b/src/test/run-pass/no-std-1.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] extern crate std; diff --git a/src/test/run-pass/no-std-2.rs b/src/test/run-pass/no-std-2.rs index 043b016bdb9..1b24987052b 100644 --- a/src/test/run-pass/no-std-2.rs +++ b/src/test/run-pass/no-std-2.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] extern crate std; diff --git a/src/test/run-pass/no-std-3.rs b/src/test/run-pass/no-std-3.rs index 318b29d99cc..685c62f5a53 100644 --- a/src/test/run-pass/no-std-3.rs +++ b/src/test/run-pass/no-std-3.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std)] #![no_std] extern crate std; diff --git a/src/test/run-pass/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded-calls-param-vtables.rs index 597075c5500..c15c6df5fac 100644 --- a/src/test/run-pass/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded-calls-param-vtables.rs @@ -12,7 +12,7 @@ // pretty-expanded FIXME #23616 -#![feature(unboxed_closures, core)] +#![feature(unboxed_closures, fn_traits)] use std::marker::PhantomData; use std::ops::Fn; diff --git a/src/test/run-pass/overloaded-calls-simple.rs b/src/test/run-pass/overloaded-calls-simple.rs index 6566f6c1260..24a79a26837 100644 --- a/src/test/run-pass/overloaded-calls-simple.rs +++ b/src/test/run-pass/overloaded-calls-simple.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![feature(lang_items, unboxed_closures, core)] +#![feature(lang_items, unboxed_closures, fn_traits)] use std::ops::{Fn, FnMut, FnOnce}; diff --git a/src/test/run-pass/overloaded-calls-zero-args.rs b/src/test/run-pass/overloaded-calls-zero-args.rs index 621b2f94209..5fd6d5cb10f 100644 --- a/src/test/run-pass/overloaded-calls-zero-args.rs +++ b/src/test/run-pass/overloaded-calls-zero-args.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![feature(unboxed_closures, core)] +#![feature(unboxed_closures, fn_traits)] use std::ops::FnMut; diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 3c01a7f8923..371823ece29 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -8,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![allow(unknown_features)] -#![feature(unboxed_closures, core)] - struct closure_box<'a> { cl: Box, } @@ -25,9 +21,8 @@ pub fn main() { assert_eq!(i, 3); { let cl = || i += 1; - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let mut cl_box = box_it(Box::new(cl)); - cl_box.cl.call_mut(()); + (cl_box.cl)(); } assert_eq!(i, 4); } diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index ae39c266808..fa1c3b230c6 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -8,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] -#![feature(unboxed_closures, core)] - struct closure_box<'a> { cl: Box, } @@ -21,11 +17,10 @@ fn box_it<'a>(x: Box) -> closure_box<'a> { } fn call_static_closure(mut cl: closure_box<'static>) { - cl.cl.call_mut(()) + (cl.cl)(); } pub fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let cl_box = box_it(Box::new(|| println!("Hello, world!"))); call_static_closure(cl_box); } diff --git a/src/test/run-pass/unboxed-closures-extern-fn-hr.rs b/src/test/run-pass/unboxed-closures-extern-fn-hr.rs index e71757abd0e..75cd61b9cf0 100644 --- a/src/test/run-pass/unboxed-closures-extern-fn-hr.rs +++ b/src/test/run-pass/unboxed-closures-extern-fn-hr.rs @@ -10,11 +10,6 @@ // Checks that higher-ranked extern fn pointers implement the full range of Fn traits. - -#![feature(unboxed_closures, core)] - -use std::ops::{Fn,FnMut,FnOnce}; - fn square(x: &isize) -> isize { (*x) * (*x) } fn call_itisize>(f: &F, x: isize) -> isize { @@ -22,7 +17,7 @@ fn call_itisize>(f: &F, x: isize) -> isize { } fn call_it_boxed(f: &Fn(&isize) -> isize, x: isize) -> isize { - f.call((&x,)) + f(&x) } fn call_it_mutisize>(f: &mut F, x: isize) -> isize { diff --git a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs index 5d6d372ea5c..2e63c600a46 100644 --- a/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs +++ b/src/test/run-pass/unboxed-closures-fn-as-fnmut-and-fnonce.rs @@ -12,7 +12,7 @@ // any Fn trait to be used where Fn is implemented. -#![feature(unboxed_closures, core)] +#![feature(unboxed_closures, fn_traits)] use std::ops::{Fn,FnMut,FnOnce}; diff --git a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs index c19b5b273c7..ce93fcafc9e 100644 --- a/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs +++ b/src/test/run-pass/unboxed-closures-fnmut-as-fnonce.rs @@ -12,9 +12,7 @@ // FnMut or FnOnce to be used where FnMut is implemented. -#![feature(unboxed_closures, core)] - -use std::ops::{FnMut,FnOnce}; +#![feature(unboxed_closures, fn_traits)] struct S; diff --git a/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs b/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs index e499ab5cca0..ac303e3a090 100644 --- a/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs +++ b/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(core,unboxed_closures)] +#![feature(fn_traits, unboxed_closures)] use std::marker::PhantomData; diff --git a/src/test/run-pass/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures-manual-impl.rs index 74c5f694908..e2d05884f3a 100644 --- a/src/test/run-pass/unboxed-closures-manual-impl.rs +++ b/src/test/run-pass/unboxed-closures-manual-impl.rs @@ -8,10 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(unboxed_closures, core)] - -use std::ops::FnMut; +#![feature(unboxed_closures, fn_traits)] struct S; diff --git a/src/test/run-pass/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures-monomorphization.rs index f16f757c645..d0d36d969b7 100644 --- a/src/test/run-pass/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures-monomorphization.rs @@ -11,30 +11,25 @@ // Test that unboxed closures in contexts with free type parameters // monomorphize correctly (issue #16791) -#![allow(unknown_features)] -#![feature(box_syntax)] -#![feature(unboxed_closures, core)] - fn main(){ fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Box::new(move || t.clone()) } let mut f = bar(42_u32); - assert_eq!(f.call_mut(()), 42); + assert_eq!(f(), 42); let mut f = bar("forty-two"); - assert_eq!(f.call_mut(()), "forty-two"); + assert_eq!(f(), "forty-two"); let x = 42_u32; let mut f = bar(&x); - assert_eq!(f.call_mut(()), &x); + assert_eq!(f(), &x); #[derive(Clone, Copy, Debug, PartialEq)] struct Foo(usize, &'static str); let x = Foo(42, "forty-two"); let mut f = bar(x); - assert_eq!(f.call_mut(()), x); + assert_eq!(f(), x); } diff --git a/src/test/run-pass/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures-prelude.rs index 313fb67637e..b7835324010 100644 --- a/src/test/run-pass/unboxed-closures-prelude.rs +++ b/src/test/run-pass/unboxed-closures-prelude.rs @@ -12,14 +12,9 @@ // pretty-expanded FIXME #23616 -#![allow(unknown_features)] -#![feature(box_syntax)] -#![feature(unboxed_closures, core)] - fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let task: Box isize> = Box::new(|x| x); - task.call((0, )); + task(0); let mut task: Box isize> = Box::new(|x| x); task(0); diff --git a/src/test/run-pass/vec-macro-no-std.rs b/src/test/run-pass/vec-macro-no-std.rs index ddac0ecc13c..a51ef732264 100644 --- a/src/test/run-pass/vec-macro-no-std.rs +++ b/src/test/run-pass/vec-macro-no-std.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, start, no_std, core_slice_ext, libc, collections)] +#![feature(lang_items, start, libc, collections)] #![no_std] extern crate std as other; @@ -18,8 +18,6 @@ extern crate libc; #[macro_use] extern crate collections; -use core::option::Option::Some; -use core::slice::SliceExt; use collections::vec::Vec; // Issue #16806 diff --git a/src/test/rustdoc/issue-15318.rs b/src/test/rustdoc/issue-15318.rs index fd46b6e9909..bd22548a888 100644 --- a/src/test/rustdoc/issue-15318.rs +++ b/src/test/rustdoc/issue-15318.rs @@ -11,7 +11,6 @@ // aux-build:issue-15318.rs // ignore-cross-compile -#![feature(no_std)] #![no_std] extern crate issue_15318; diff --git a/src/test/rustdoc/issue-23511.rs b/src/test/rustdoc/issue-23511.rs index 1e8d20f74f9..50c31d309ee 100644 --- a/src/test/rustdoc/issue-23511.rs +++ b/src/test/rustdoc/issue-23511.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(no_std, lang_items, core)] +#![feature(lang_items)] #![no_std] pub mod str {