diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-06-10 19:33:04 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-06-17 09:07:17 -0700 |
| commit | b4a2823cd6c6f1a560469587f902f3a1f49d3c79 (patch) | |
| tree | 162e8021fd73ffc7dfe0798dc99097138343977a | |
| parent | aa931e9c6f92557b99978f1cc562c99051190f79 (diff) | |
| download | rust-b4a2823cd6c6f1a560469587f902f3a1f49d3c79.tar.gz rust-b4a2823cd6c6f1a560469587f902f3a1f49d3c79.zip | |
More test fixes and fallout of stability changes
40 files changed, 111 insertions, 122 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 282fca8d6c2..7bfeaec36d7 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -290,7 +290,7 @@ pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { Arc::strong_count(this) reason = "this function is unsafe with weak pointers")] pub unsafe fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> { // FIXME(#24880) potential race with upgraded weak pointers here - if strong_count(this) == 1 && weak_count(this) == 0 { + if Arc::strong_count(this) == 1 && Arc::weak_count(this) == 0 { // This unsafety is ok because we're guaranteed that the pointer // returned is the *only* pointer that will ever be returned to T. Our // reference count is guaranteed to be 1 at this point, and we required diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 0e6554702be..1a360ebc05c 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -267,7 +267,7 @@ impl Box<Any> { if self.is::<T>() { unsafe { // Get the raw representation of the trait object - let raw = into_raw(self); + let raw = Box::into_raw(self); let to: TraitObject = mem::transmute::<*mut Any, TraitObject>(raw); diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index bdf02b23ff4..d5b6c86ef35 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -148,26 +148,24 @@ //! ``` #![stable(feature = "rust1", since = "1.0.0")] + +use core::prelude::*; + #[cfg(not(test))] -use boxed; +use boxed::Box; #[cfg(test)] -use std::boxed; +use std::boxed::Box; + use core::cell::Cell; -use core::clone::Clone; -use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; -use core::default::Default; +use core::cmp::Ordering; use core::fmt; use core::hash::{Hasher, Hash}; use core::intrinsics::{assume, drop_in_place}; -use core::marker::{self, Sized, Unsize}; +use core::marker::{self, Unsize}; use core::mem::{self, min_align_of, size_of, min_align_of_val, size_of_val, forget}; use core::nonzero::NonZero; -use core::ops::{CoerceUnsized, Deref, Drop}; -use core::option::Option; -use core::option::Option::{Some, None}; +use core::ops::{CoerceUnsized, Deref}; use core::ptr; -use core::result::Result; -use core::result::Result::{Ok, Err}; use heap::deallocate; @@ -212,7 +210,7 @@ impl<T> Rc<T> { // pointers, which ensures that the weak destructor never frees // the allocation while the strong destructor is running, even // if the weak pointer is stored inside the strong one. - _ptr: NonZero::new(boxed::into_raw(box RcBox { + _ptr: NonZero::new(Box::into_raw(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value: value @@ -230,14 +228,14 @@ impl<T> Rc<T> { /// /// ``` /// # #![feature(rc_unique)] - /// use std::rc::{self, Rc}; + /// use std::rc::Rc; /// /// let x = Rc::new(3); - /// assert_eq!(rc::try_unwrap(x), Ok(3)); + /// assert_eq!(Rc::try_unwrap(x), Ok(3)); /// /// let x = Rc::new(4); /// let _y = x.clone(); - /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); + /// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4))); /// ``` #[inline] #[unstable(feature = "rc_unique")] @@ -295,17 +293,16 @@ impl<T: ?Sized> Rc<T> { /// /// ``` /// # #![feature(rc_unique)] - /// use std::rc; /// use std::rc::Rc; /// /// let five = Rc::new(5); /// - /// rc::is_unique(&five); + /// assert!(Rc::is_unique(&five)); /// ``` #[inline] #[unstable(feature = "rc_unique")] pub fn is_unique(rc: &Rc<T>) -> bool { - weak_count(rc) == 0 && strong_count(rc) == 1 + Rc::weak_count(rc) == 0 && Rc::strong_count(rc) == 1 } /// Returns a mutable reference to the contained value if the `Rc<T>` is @@ -317,14 +314,14 @@ impl<T: ?Sized> Rc<T> { /// /// ``` /// # #![feature(rc_unique)] - /// use std::rc::{self, Rc}; + /// use std::rc::Rc; /// /// let mut x = Rc::new(3); - /// *rc::get_mut(&mut x).unwrap() = 4; + /// *Rc::get_mut(&mut x).unwrap() = 4; /// assert_eq!(*x, 4); /// /// let _y = x.clone(); - /// assert!(rc::get_mut(&mut x).is_none()); + /// assert!(Rc::get_mut(&mut x).is_none()); /// ``` #[inline] #[unstable(feature = "rc_unique")] @@ -432,7 +429,7 @@ impl<T: Clone> Rc<T> { #[inline] #[unstable(feature = "rc_unique")] pub fn make_unique(&mut self) -> &mut T { - if !is_unique(self) { + if !Rc::is_unique(self) { *self = Rc::new((**self).clone()) } // This unsafety is ok because we're guaranteed that the pointer diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 6a07c2c47eb..51914900fdd 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -86,6 +86,7 @@ use core::cmp::Ordering; use core::cmp; use core::fmt; use core::hash; +#[allow(deprecated)] use core::iter::RandomAccessIterator; use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned}; use core::iter::{self, FromIterator}; @@ -1188,6 +1189,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { impl<'a> ExactSizeIterator for Iter<'a> {} #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl<'a> RandomAccessIterator for Iter<'a> { #[inline] fn indexable(&self) -> usize { diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index d27d04c3a6c..27b10213ecd 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -685,10 +685,7 @@ mod stack { /// tied to the original tree. pub fn into_top(mut self) -> &'a mut V { unsafe { - mem::copy_mut_lifetime( - self.map, - self.top.from_raw_mut().val_mut() - ) + &mut *(self.top.from_raw_mut().val_mut() as *mut V) } } } diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index b08a3b85e4c..8d0f57de4c5 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -34,7 +34,6 @@ #![feature(box_patterns)] #![feature(box_raw)] #![feature(box_syntax)] -#![feature(copy_lifetime)] #![feature(core)] #![feature(core_intrinsics)] #![feature(core_prelude)] @@ -56,7 +55,7 @@ #![feature(staged_api)] #![feature(step_by)] #![feature(str_char)] -#![feature(str_internals)] +#![feature(str_match_indices)] #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 7d74f83552d..d49463911e6 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -151,6 +151,7 @@ mod hack { } } + #[allow(deprecated)] pub fn permutations<T>(s: &[T]) -> Permutations<T> where T: Clone { Permutations{ swaps: ElementSwaps::new(s.len()), @@ -871,6 +872,7 @@ impl<T> [T] { /// assert_eq!(Some(vec![1, 3, 2]), perms.next()); /// assert_eq!(Some(vec![3, 1, 2]), perms.next()); /// ``` + #[allow(deprecated)] #[unstable(feature = "permutations")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] #[inline] @@ -896,6 +898,7 @@ impl<T> [T] { /// let b: &mut [_] = &mut [1, 0, 2]; /// assert!(v == b); /// ``` + #[allow(deprecated)] #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] @@ -920,6 +923,7 @@ impl<T> [T] { /// let b: &mut [_] = &mut [0, 1, 2]; /// assert!(v == b); /// ``` + #[allow(deprecated)] #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] @@ -1067,6 +1071,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] { /// /// The last generated swap is always (0, 1), and it returns the /// sequence to its initial order. +#[allow(deprecated)] #[unstable(feature = "permutations")] #[derive(Clone)] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] @@ -1078,6 +1083,7 @@ pub struct ElementSwaps { swaps_made : usize, } +#[allow(deprecated)] impl ElementSwaps { /// Creates an `ElementSwaps` iterator for a sequence of `length` elements. #[unstable(feature = "permutations")] @@ -1137,6 +1143,7 @@ struct SizeDirection { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl Iterator for ElementSwaps { type Item = (usize, usize); @@ -1205,12 +1212,14 @@ impl Iterator for ElementSwaps { /// Generates even and odd permutations alternately. #[unstable(feature = "permutations")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] +#[allow(deprecated)] pub struct Permutations<T> { swaps: ElementSwaps, v: Vec<T>, } #[unstable(feature = "permutations", reason = "trait is unstable")] +#[allow(deprecated)] impl<T: Clone> Iterator for Permutations<T> { type Item = Vec<T>; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 55265aac99f..5e8a9bca342 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1520,7 +1520,6 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] /// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect(); /// assert_eq!(v, ["abc", "abc", "abc"]); /// @@ -1552,7 +1551,6 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] /// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect(); /// assert_eq!(v, ["abc", "abc", "abc"]); /// @@ -1593,7 +1591,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] + /// # #![feature(str_match_indices)] /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect(); /// assert_eq!(v, [(0, 3), (6, 9), (12, 15)]); /// @@ -1637,7 +1635,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] + /// # #![feature(str_match_indices)] /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".rmatch_indices("abc").collect(); /// assert_eq!(v, [(12, 15), (6, 9), (0, 3)]); /// diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 6b1e4bb4f8e..54528c50f1d 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1709,12 +1709,14 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone { } } +#[allow(deprecated)] impl<'a, T: 'a> IntoCow<'a, [T]> for Vec<T> where T: Clone { fn into_cow(self) -> Cow<'a, [T]> { Cow::Owned(self) } } +#[allow(deprecated)] impl<'a, T> IntoCow<'a, [T]> for &'a [T] where T: Clone { fn into_cow(self) -> Cow<'a, [T]> { Cow::Borrowed(self) diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index c80fcfc5fed..edcd1008747 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -1530,6 +1530,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Iter<'a, T> { #[inline] fn indexable(&self) -> usize { diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 437657cec16..20a3625fe5a 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -43,7 +43,7 @@ #![feature(step_by)] #![feature(str_char)] #![feature(str_escape)] -#![feature(str_matches)] +#![feature(str_match_indices)] #![feature(str_utf16)] #![feature(subslice_offset)] #![feature(test)] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2f45ffd1418..3026f91e853 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1234,6 +1234,7 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I { reason = "trait has not proven itself as a widely useful \ abstraction for iterators, and more time may be needed \ for iteration on the design")] +#[allow(deprecated)] pub trait RandomAccessIterator: Iterator { /// Returns the number of indexable elements. At most `std::usize::MAX` /// elements are indexable, even if the iterator represents a longer range. @@ -1313,6 +1314,7 @@ impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I> RandomAccessIterator for Rev<I> where I: DoubleEndedIterator + RandomAccessIterator { @@ -1416,6 +1418,7 @@ impl<'a, I, T: 'a> ExactSizeIterator for Cloned<I> {} #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, I, T: 'a> RandomAccessIterator for Cloned<I> where I: RandomAccessIterator<Item=&'a T>, T: Clone { @@ -1463,6 +1466,7 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I> RandomAccessIterator for Cycle<I> where I: Clone + RandomAccessIterator, { @@ -1577,6 +1581,7 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<A, B> RandomAccessIterator for Chain<A, B> where A: RandomAccessIterator, B: RandomAccessIterator<Item = A::Item>, @@ -1665,6 +1670,7 @@ impl<A, B> DoubleEndedIterator for Zip<A, B> where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<A, B> RandomAccessIterator for Zip<A, B> where A: RandomAccessIterator, B: RandomAccessIterator @@ -1719,6 +1725,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<B, I: RandomAccessIterator, F> RandomAccessIterator for Map<I, F> where F: FnMut(I::Item) -> B, { @@ -1893,6 +1900,7 @@ impl<I> DoubleEndedIterator for Enumerate<I> where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I> RandomAccessIterator for Enumerate<I> where I: RandomAccessIterator { #[inline] fn indexable(&self) -> usize { @@ -2143,6 +2151,7 @@ impl<I> Iterator for Skip<I> where I: Iterator { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I> RandomAccessIterator for Skip<I> where I: RandomAccessIterator{ #[inline] fn indexable(&self) -> usize { @@ -2215,6 +2224,7 @@ impl<I> Iterator for Take<I> where I: Iterator{ } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I> RandomAccessIterator for Take<I> where I: RandomAccessIterator{ #[inline] fn indexable(&self) -> usize { @@ -2416,6 +2426,7 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator { // Allow RandomAccessIterators to be fused without affecting random-access behavior #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I> RandomAccessIterator for Fuse<I> where I: RandomAccessIterator { #[inline] fn indexable(&self) -> usize { @@ -2491,6 +2502,7 @@ impl<I: DoubleEndedIterator, F> DoubleEndedIterator for Inspect<I, F> } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F> where F: FnMut(&I::Item), { @@ -2545,6 +2557,7 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F> #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] pub struct Unfold<St, F> { f: F, /// Internal state that will be passed to the closure on the next iteration @@ -2556,6 +2569,7 @@ pub struct Unfold<St, F> { #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the closure @@ -2569,6 +2583,7 @@ impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> { type Item = A; @@ -2977,7 +2992,7 @@ impl<A: Clone> Iterator for Repeat<A> { type Item = A; #[inline] - fn next(&mut self) -> Option<A> { self.idx(0) } + fn next(&mut self) -> Option<A> { Some(self.element.clone()) } #[inline] fn size_hint(&self) -> (usize, Option<usize>) { (usize::MAX, None) } } @@ -2985,10 +3000,11 @@ impl<A: Clone> Iterator for Repeat<A> { #[stable(feature = "rust1", since = "1.0.0")] impl<A: Clone> DoubleEndedIterator for Repeat<A> { #[inline] - fn next_back(&mut self) -> Option<A> { self.idx(0) } + fn next_back(&mut self) -> Option<A> { Some(self.element.clone()) } } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<A: Clone> RandomAccessIterator for Repeat<A> { #[inline] fn indexable(&self) -> usize { usize::MAX } @@ -3004,6 +3020,7 @@ type IterateState<T, F> = (F, Option<T>, bool); #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>) -> Option<T>>; /// Creates a new iterator that produces an infinite sequence of @@ -3012,6 +3029,7 @@ pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>) #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] pub fn iterate<T, F>(seed: T, f: F) -> Iterate<T, F> where T: Clone, F: FnMut(T) -> T, diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 91acb0d6955..a8c995f37cc 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -802,6 +802,7 @@ impl<'a, T> Clone for Iter<'a, T> { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Iter<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1174,6 +1175,7 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> { impl<'a, T> ExactSizeIterator for Windows<'a, T> {} #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Windows<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1261,6 +1263,7 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Chunks<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1520,6 +1523,7 @@ pub trait IntSliceExt<U, S> { macro_rules! impl_int_slice { ($u:ty, $s:ty, $t:ty) => { #[unstable(feature = "int_slice")] + #[allow(deprecated)] impl IntSliceExt<$u, $s> for [$t] { #[inline] fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } } diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 246b5909865..7bafd9382f0 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -173,12 +173,10 @@ #![feature(box_syntax)] #![feature(const_fn)] #![feature(iter_cmp)] -#![feature(once_new)] #![feature(rt)] #![feature(staged_api)] #![feature(static_mutex)] -use std::boxed; use std::cell::RefCell; use std::fmt; use std::io::{self, Stderr}; @@ -437,12 +435,12 @@ fn init() { assert!(FILTER.is_null()); match filter { - Some(f) => FILTER = boxed::into_raw(box f), + Some(f) => FILTER = Box::into_raw(box f), None => {} } assert!(DIRECTIVES.is_null()); - DIRECTIVES = boxed::into_raw(box directives); + DIRECTIVES = Box::into_raw(box directives); // Schedule the cleanup for the globals for when the runtime exits. let _ = rt::at_exit(move || { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 377b60570e5..240aaae0e55 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -57,7 +57,7 @@ #![feature(slice_position_elem)] #![feature(staged_api)] #![feature(str_char)] -#![feature(str_matches)] +#![feature(str_match_indices)] #![feature(vec_push_all)] #![feature(wrapping)] #![cfg_attr(test, feature(test))] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 052ec4897d1..fe3ffe97981 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -26,7 +26,6 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] -#![feature(exit_status)] #![feature(libc)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] @@ -73,6 +72,7 @@ use std::env; use std::io::{self, Read, Write}; use std::iter::repeat; use std::path::PathBuf; +use std::process; use std::str; use std::sync::{Arc, Mutex}; use std::thread; @@ -861,5 +861,5 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry { pub fn main() { let result = run(env::args().collect()); - std::env::set_exit_status(result as i32); + process::exit(result as i32); } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 1b8f049972f..267f0b6d953 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -25,7 +25,6 @@ use syntax::diagnostic::{Emitter, Handler, Level}; use std::ffi::{CStr, CString}; use std::fs; -use std::iter::Unfold; use std::mem; use std::path::Path; use std::process::{Command, Stdio}; @@ -913,11 +912,10 @@ fn run_work_singlethreaded(sess: &Session, reachable: &[String], work_items: Vec<WorkItem>) { let cgcx = CodegenContext::new_with_session(sess, reachable); - let mut work_items = work_items; // Since we're running single-threaded, we can pass the session to // the proc, allowing `optimize_and_codegen` to perform LTO. - for work in Unfold::new((), |_| work_items.pop()) { + for work in work_items.into_iter().rev() { execute_work_item(&cgcx, work); } } diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index a1e1b395d98..8ced85d336b 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -31,9 +31,7 @@ #![feature(fs)] #![feature(iter_cmp)] #![feature(iter_arith)] -#![feature(iter_unfold)] #![feature(libc)] -#![feature(once_new)] #![feature(path_ext)] #![feature(path_ext)] #![feature(path_relative_from)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 9db9af32baa..17d912dd4cb 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -23,7 +23,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(dynamic_lib)] -#![feature(exit_status)] #![feature(libc)] #![feature(owned_ascii_ext)] #![feature(path_ext)] @@ -61,6 +60,7 @@ use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::path::PathBuf; +use std::process; use std::rc::Rc; use std::sync::mpsc::channel; @@ -134,7 +134,7 @@ pub fn main() { let s = env::args().collect::<Vec<_>>(); main_args(&s) }).unwrap().join().unwrap(); - env::set_exit_status(res as i32); + process::exit(res as i32); } pub fn opts() -> Vec<getopts::OptGroup> { diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 5951e4f823e..e7d9751cf4b 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -32,7 +32,6 @@ Core encoding and decoding interfaces. #![feature(enumset)] #![feature(hashmap_hasher)] #![feature(num_bits_bytes)] -#![feature(num_wrapping)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(str_char)] diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 1677f95ca90..17e8859d63f 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -48,7 +48,7 @@ // reconsider what crate these items belong in. use any::TypeId; -use boxed::{self, Box}; +use boxed::Box; use convert::From; use fmt::{self, Debug, Display}; use marker::{Send, Sync, Reflect}; @@ -249,7 +249,7 @@ impl Error { if self.is::<T>() { unsafe { // Get the raw representation of the trait object - let raw = boxed::into_raw(self); + let raw = Box::into_raw(self); let to: TraitObject = transmute::<*mut Error, TraitObject>(raw); diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index d5df9b3aa72..becc697bcd9 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -8,9 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - use borrow::{Cow, ToOwned}; -use boxed::{self, Box}; +use boxed::Box; use clone::Clone; use convert::{Into, From}; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; @@ -226,7 +225,7 @@ impl CString { // It is important that the bytes be sized to fit - we need // the capacity to be determinable from the string length, and // shrinking to fit is the only way to be sure. - boxed::into_raw(self.inner) as *const libc::c_char + Box::into_raw(self.inner) as *const libc::c_char } /// Returns the contents of this `CString` as a slice of bytes. diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 95363870cd0..1d0152e2751 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -465,6 +465,7 @@ pub struct BufStream<S: Write> { leading to issues like #17136")] #[deprecated(since = "1.2.0", reason = "use the crates.io `bufstream` crate instead")] +#[allow(deprecated)] impl<S: Read + Write> BufStream<S> { /// Creates a new buffered stream with explicitly listed capacities for the /// reader/writer buffer. @@ -516,6 +517,7 @@ impl<S: Read + Write> BufStream<S> { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl<S: Read + Write> BufRead for BufStream<S> { fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() } fn consume(&mut self, amt: usize) { self.inner.consume(amt) } @@ -524,6 +526,7 @@ impl<S: Read + Write> BufRead for BufStream<S> { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl<S: Read + Write> Read for BufStream<S> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.inner.read(buf) @@ -533,6 +536,7 @@ impl<S: Read + Write> Read for BufStream<S> { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl<S: Read + Write> Write for BufStream<S> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.inner.inner.get_mut().write(buf) @@ -545,6 +549,7 @@ impl<S: Read + Write> Write for BufStream<S> { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl<S: Write> fmt::Debug for BufStream<S> where S: fmt::Debug { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let reader = &self.inner; diff --git a/src/libstd/io/lazy.rs b/src/libstd/io/lazy.rs index d398cb88af4..c3e309d182b 100644 --- a/src/libstd/io/lazy.rs +++ b/src/libstd/io/lazy.rs @@ -10,7 +10,6 @@ use prelude::v1::*; -use boxed; use cell::Cell; use rt; use sync::{StaticMutex, Arc}; @@ -60,7 +59,7 @@ impl<T: Send + Sync + 'static> Lazy<T> { }); let ret = (self.init)(); if registered.is_ok() { - self.ptr.set(boxed::into_raw(Box::new(ret.clone()))); + self.ptr.set(Box::into_raw(Box::new(ret.clone()))); } return ret } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9f9435f4123..251f962c5e3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -106,7 +106,6 @@ #![feature(alloc)] #![feature(allow_internal_unstable)] #![feature(associated_consts)] -#![feature(borrow_state)] #![feature(box_raw)] #![feature(box_syntax)] #![feature(char_internals)] diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs index 19a17be4ccf..17d2940a6f1 100644 --- a/src/libstd/rt/at_exit_imp.rs +++ b/src/libstd/rt/at_exit_imp.rs @@ -16,13 +16,12 @@ // segfaults (the queue's memory is mysteriously gone), so // instead the cleanup is tied to the `std::rt` entry point. -use boxed; +use alloc::boxed::FnBox; use boxed::Box; -use vec::Vec; -use thunk::Thunk; use sys_common::mutex::Mutex; +use vec::Vec; -type Queue = Vec<Thunk<'static>>; +type Queue = Vec<Box<FnBox()>>; // NB these are specifically not types from `std::sync` as they currently rely // on poisoning and this module needs to operate at a lower level than requiring @@ -40,7 +39,7 @@ const ITERS: usize = 10; unsafe fn init() -> bool { if QUEUE.is_null() { let state: Box<Queue> = box Vec::new(); - QUEUE = boxed::into_raw(state); + QUEUE = Box::into_raw(state); } else if QUEUE as usize == 1 { // can't re-init after a cleanup return false @@ -71,7 +70,7 @@ pub fn cleanup() { } } -pub fn push(f: Thunk<'static>) -> bool { +pub fn push(f: Box<FnBox()>) -> bool { let mut ret = true; unsafe { LOCK.lock(); diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 1b8e81e2b79..1729d20da20 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -139,7 +139,9 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize { if failed { rt::DEFAULT_ERROR_CODE } else { - env::get_exit_status() as isize + #[allow(deprecated)] + fn exit_status() -> isize { env::get_exit_status() as isize } + exit_status() } } diff --git a/src/libstd/rt/unwind/gcc.rs b/src/libstd/rt/unwind/gcc.rs index 39b32a3f08e..84c6d6864a9 100644 --- a/src/libstd/rt/unwind/gcc.rs +++ b/src/libstd/rt/unwind/gcc.rs @@ -11,7 +11,6 @@ use prelude::v1::*; use any::Any; -use boxed; use libc::c_void; use rt::libunwind as uw; @@ -29,7 +28,7 @@ pub unsafe fn panic(data: Box<Any + Send + 'static>) -> ! { }, cause: Some(data), }; - let exception_param = boxed::into_raw(exception) as *mut uw::_Unwind_Exception; + let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; let error = uw::_Unwind_RaiseException(exception_param); rtabort!("Could not unwind stack, error = {}", error as isize); diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index e3ddc1034a5..28dc124f033 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -32,10 +32,11 @@ reason = "futures as-is have yet to be deeply reevaluated with recent \ core changes to Rust's synchronization story, and will likely \ become stable in the future but are unstable until that time")] -#[deprecated(since = "1.2.0", - reason = "implementation does not match the quality of the \ - standard library and this will likely be prototyped \ - outside in crates.io first")] +#![deprecated(since = "1.2.0", + reason = "implementation does not match the quality of the \ + standard library and this will likely be prototyped \ + outside in crates.io first")] +#![allow(deprecated)] use core::prelude::*; use core::mem::replace; diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 91e9714fbef..ab8d4587cfd 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -30,6 +30,7 @@ pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard}; pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT}; pub use self::semaphore::{Semaphore, SemaphoreGuard}; +#[allow(deprecated)] pub use self::future::Future; pub mod mpsc; diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index f3edf0d68c7..d6d173e5e7e 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -42,7 +42,6 @@ pub use self::PopResult::*; use core::prelude::*; -use alloc::boxed; use alloc::boxed::Box; use core::ptr; use core::cell::UnsafeCell; @@ -80,7 +79,7 @@ unsafe impl<T: Send> Sync for Queue<T> { } impl<T> Node<T> { unsafe fn new(v: Option<T>) -> *mut Node<T> { - boxed::into_raw(box Node { + Box::into_raw(box Node { next: AtomicPtr::new(ptr::null_mut()), value: v, }) diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 770068a66be..3cf75de5a46 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -35,7 +35,6 @@ use core::prelude::*; -use alloc::boxed; use alloc::boxed::Box; use core::ptr; use core::cell::UnsafeCell; @@ -78,7 +77,7 @@ unsafe impl<T: Send> Sync for Queue<T> { } impl<T> Node<T> { fn new() -> *mut Node<T> { - boxed::into_raw(box Node { + Box::into_raw(box Node { value: None, next: AtomicPtr::new(ptr::null_mut::<Node<T>>()), }) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 64a5027cc89..41cd11e4c69 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -85,8 +85,6 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; /// To recover from a poisoned mutex: /// /// ``` -/// #![feature(sync_poison)] -/// /// use std::sync::{Arc, Mutex}; /// use std::thread; /// diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 428c8560d88..8ea673d2162 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -28,7 +28,7 @@ use core::prelude::*; use core::char::{encode_utf8_raw, encode_utf16_raw}; -use core::str::{char_range_at_raw, next_code_point}; +use core::str::next_code_point; use ascii::*; use borrow::Cow; @@ -1149,30 +1149,6 @@ mod tests { } #[test] - fn wtf8_code_point_at() { - let mut string = Wtf8Buf::from_str("aé "); - string.push(CodePoint::from_u32(0xD83D).unwrap()); - string.push_char('💩'); - assert_eq!(string.code_point_at(0), CodePoint::from_char('a')); - assert_eq!(string.code_point_at(1), CodePoint::from_char('é')); - assert_eq!(string.code_point_at(3), CodePoint::from_char(' ')); - assert_eq!(string.code_point_at(4), CodePoint::from_u32(0xD83D).unwrap()); - assert_eq!(string.code_point_at(7), CodePoint::from_char('💩')); - } - - #[test] - fn wtf8_code_point_range_at() { - let mut string = Wtf8Buf::from_str("aé "); - string.push(CodePoint::from_u32(0xD83D).unwrap()); - string.push_char('💩'); - assert_eq!(string.code_point_range_at(0), (CodePoint::from_char('a'), 1)); - assert_eq!(string.code_point_range_at(1), (CodePoint::from_char('é'), 3)); - assert_eq!(string.code_point_range_at(3), (CodePoint::from_char(' '), 4)); - assert_eq!(string.code_point_range_at(4), (CodePoint::from_u32(0xD83D).unwrap(), 7)); - assert_eq!(string.code_point_range_at(7), (CodePoint::from_char('💩'), 11)); - } - - #[test] fn wtf8_code_points() { fn c(value: u32) -> CodePoint { CodePoint::from_u32(value).unwrap() } fn cp(string: &Wtf8Buf) -> Vec<Option<char>> { diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 2b5e3fb18eb..2c4b716cc6e 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -326,7 +326,6 @@ mod imp { // Due to rust-lang/rust#18804, make sure this is not generic! #[cfg(target_os = "linux")] unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { - use boxed; use mem; use ptr; use libc; @@ -360,7 +359,7 @@ mod imp { type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>; if DTORS.get().is_null() { let v: Box<List> = box Vec::new(); - DTORS.set(boxed::into_raw(v) as *mut u8); + DTORS.set(Box::into_raw(v) as *mut u8); } let list: &mut List = &mut *(DTORS.get() as *mut List); list.push((t, dtor)); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index da9cde8e3cd..dbb7d3233bc 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -404,6 +404,7 @@ pub fn spawn<F, T>(f: F) -> JoinHandle<T> where #[deprecated(since = "1.2.0", reason = "this unsafe API is unlikely to ever be stabilized \ in this form")] +#[allow(deprecated)] pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 1507226c3a1..f800b4863c6 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -46,7 +46,6 @@ #![feature(set_stdio)] #![feature(slice_extras)] #![feature(staged_api)] -#![feature(thunk)] extern crate getopts; extern crate serialize; @@ -82,7 +81,6 @@ use std::path::PathBuf; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; use std::thread; -use std::thunk::Thunk; use std::time::Duration; // to be used by rustc to compile tests in libtest @@ -155,7 +153,7 @@ pub enum TestFn { StaticTestFn(fn()), StaticBenchFn(fn(&mut Bencher)), StaticMetricFn(fn(&mut MetricMap)), - DynTestFn(Thunk<'static>), + DynTestFn(Box<FnBox() + Send>), DynMetricFn(Box<FnBox(&mut MetricMap)+Send>), DynBenchFn(Box<TDynBenchFn+'static>) } @@ -961,7 +959,7 @@ pub fn run_test(opts: &TestOpts, fn run_test_inner(desc: TestDesc, monitor_ch: Sender<MonitorMsg>, nocapture: bool, - testfn: Thunk<'static>) { + testfn: Box<FnBox() + Send>) { struct Sink(Arc<Mutex<Vec<u8>>>); impl Write for Sink { fn write(&mut self, data: &[u8]) -> io::Result<usize> { @@ -1229,7 +1227,6 @@ mod tests { TestDesc, TestDescAndFn, TestOpts, run_test, MetricMap, StaticTestName, DynTestName, DynTestFn, ShouldPanic}; - use std::thunk::Thunk; use std::sync::mpsc::channel; #[test] diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index 707493e8518..acb1c5cbd90 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -10,7 +10,6 @@ #![deny(warnings)] -#![feature(exit_status)] #![feature(iter_arith)] #![feature(path_relative_from)] #![feature(rustc_private)] @@ -21,6 +20,8 @@ extern crate rustc_back; use std::env; use std::error::Error; +use std::process; +use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering}; use subcommand::Subcommand; use term::Term; @@ -37,6 +38,8 @@ mod test; mod css; mod javascript; +static EXIT_STATUS: AtomicIsize = ATOMIC_ISIZE_INIT; + #[cfg(not(test))] // thanks #12327 fn main() { let mut term = Term::new(); @@ -70,4 +73,5 @@ fn main() { } } } + process::exit(EXIT_STATUS.load(Ordering::SeqCst) as i32); } diff --git a/src/rustbook/term.rs b/src/rustbook/term.rs index 060297beb75..cdd25e67c8f 100644 --- a/src/rustbook/term.rs +++ b/src/rustbook/term.rs @@ -11,9 +11,9 @@ //! An abstraction of the terminal. Eventually, provide color and //! verbosity support. For now, just a wrapper around stdout/stderr. -use std::env; use std::io; use std::io::prelude::*; +use std::sync::atomic::Ordering; pub struct Term { err: Box<Write + 'static> @@ -29,6 +29,6 @@ impl Term { pub fn err(&mut self, msg: &str) { // swallow any errors let _ = writeln!(&mut self.err, "{}", msg); - env::set_exit_status(101); + ::EXIT_STATUS.store(101, Ordering::SeqCst); } } diff --git a/src/test/run-pass/issue-11958.rs b/src/test/run-pass/issue-11958.rs index e0c43422c28..05de69cb966 100644 --- a/src/test/run-pass/issue-11958.rs +++ b/src/test/run-pass/issue-11958.rs @@ -8,19 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![forbid(warnings)] -#![feature(thunk)] - -// Pretty printing tests complain about `use std::predule::*` -#![allow(unused_imports)] // We shouldn't need to rebind a moved upvar as mut if it's already // marked as mut -use std::thunk::Thunk; - pub fn main() { let mut x = 1; let _thunk = Box::new(move|| { x = 2; }); |
