diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index f8483a8ed9b40..94f8f615df38e 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -385,13 +385,6 @@ impl Deref for Arc { } impl Arc { - #[unstable(feature = "arc_make_unique", reason = "renamed to Arc::make_mut", - issue = "27718")] - #[rustc_deprecated(since = "1.4.0", reason = "renamed to Arc::make_mut")] - pub fn make_unique(this: &mut Self) -> &mut T { - Arc::make_mut(this) - } - /// Make a mutable reference into the given `Arc` by cloning the inner /// data if the `Arc` doesn't have one strong reference and no weak /// references. diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 404c7522403cd..8f00605d33b37 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -360,14 +360,6 @@ impl Rc { } impl Rc { - #[inline] - #[unstable(feature = "rc_make_unique", reason = "renamed to Rc::make_mut", - issue = "27718")] - #[rustc_deprecated(since = "1.4.0", reason = "renamed to Rc::make_mut")] - pub fn make_unique(&mut self) -> &mut T { - Rc::make_mut(self) - } - /// Make a mutable reference into the given `Rc` by cloning the inner /// data if the `Rc` doesn't have one strong reference and no weak /// references. diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index b8ca48ac75d1a..04cffeddc5f6a 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -230,26 +230,6 @@ impl BinaryHeap { BinaryHeap { data: Vec::with_capacity(capacity) } } - /// Creates a `BinaryHeap` from a vector. This is sometimes called - /// `heapifying` the vector. - /// - /// # Examples - /// - /// ``` - /// #![feature(binary_heap_extras)] - /// # #![allow(deprecated)] - /// - /// use std::collections::BinaryHeap; - /// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]); - /// ``` - #[unstable(feature = "binary_heap_extras", - reason = "needs to be audited", - issue = "28147")] - #[rustc_deprecated(since = "1.5.0", reason = "use BinaryHeap::from instead")] - pub fn from_vec(vec: Vec) -> BinaryHeap { - BinaryHeap::from(vec) - } - /// Returns an iterator visiting all values in the underlying vector, in /// arbitrary order. /// diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 08b0a39d9b006..de9c8a2feafb8 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -151,25 +151,14 @@ impl BTreeMap { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn new() -> BTreeMap { - // FIXME(Gankro): Tune this as a function of size_of? - BTreeMap::with_b(6) - } - - /// Makes a new empty BTreeMap with the given B. - /// - /// B cannot be less than 2. - #[unstable(feature = "btree_b", - reason = "probably want this to be on the type, eventually", - issue = "27795")] - #[rustc_deprecated(since = "1.4.0", reason = "niche API")] - pub fn with_b(b: usize) -> BTreeMap { - assert!(b > 1, "B must be greater than 1"); BTreeMap { length: 0, depth: 1, - root: Node::make_leaf_root(b), - b: b, + root: Node::make_leaf_root(6), + // FIXME(Gankro): Tune this as a function of size_of? + b: 6, } + } /// Clears the map, removing all values. @@ -185,11 +174,9 @@ impl BTreeMap { /// assert!(a.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[allow(deprecated)] pub fn clear(&mut self) { - let b = self.b; // avoid recursive destructors by manually traversing the tree - for _ in mem::replace(self, BTreeMap::with_b(b)) {} + for _ in mem::replace(self, BTreeMap::new()) {} } // Searching in a B-Tree is pretty straightforward. diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 8d741f9e34a14..a2c09c36795e4 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -98,18 +98,6 @@ impl BTreeSet { pub fn new() -> BTreeSet { BTreeSet { map: BTreeMap::new() } } - - /// Makes a new BTreeSet with the given B. - /// - /// B cannot be less than 2. - #[unstable(feature = "btree_b", - reason = "probably want this to be on the type, eventually", - issue = "27795")] - #[rustc_deprecated(since = "1.4.0", reason = "niche API")] - #[allow(deprecated)] - pub fn with_b(b: usize) -> BTreeSet { - BTreeSet { map: BTreeMap::with_b(b) } - } } impl BTreeSet { diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 6342ae5c816fd..9bb5ec808194c 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -110,9 +110,6 @@ pub use core::slice::{Iter, IterMut}; pub use core::slice::{SplitMut, ChunksMut, Split}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut}; -#[unstable(feature = "ref_slice", issue = "27774")] -#[allow(deprecated)] -pub use core::slice::{bytes, mut_ref_slice, ref_slice}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::slice::{from_raw_parts, from_raw_parts_mut}; diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index a3c6918293477..4757ada474f11 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1074,17 +1074,6 @@ impl String { let slice = self.vec.into_boxed_slice(); unsafe { mem::transmute::, Box>(slice) } } - - /// Converts the string into `Box`. - /// - /// Note that this will drop any excess capacity. - #[unstable(feature = "box_str2", - reason = "recently added, matches RFC", - issue = "27785")] - #[rustc_deprecated(since = "1.4.0", reason = "renamed to `into_boxed_str`")] - pub fn into_boxed_slice(self) -> Box { - self.into_boxed_str() - } } impl FromUtf8Error { diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 53597f566b8ae..0ca4ce2dddf42 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -1115,15 +1115,6 @@ impl VecDeque { self.pop_back() } - /// deprecated - #[unstable(feature = "deque_extras", - reason = "the naming of this function may be altered", - issue = "27788")] - #[rustc_deprecated(since = "1.5.0", reason = "renamed to swap_remove_back")] - pub fn swap_back_remove(&mut self, index: usize) -> Option { - self.swap_remove_back(index) - } - /// Removes an element from anywhere in the `VecDeque` and returns it, /// replacing it with the first element. /// @@ -1158,15 +1149,6 @@ impl VecDeque { self.pop_front() } - /// deprecated - #[unstable(feature = "deque_extras", - reason = "the naming of this function may be altered", - issue = "27788")] - #[rustc_deprecated(since = "1.5.0", reason = "renamed to swap_remove_front")] - pub fn swap_front_remove(&mut self, index: usize) -> Option { - self.swap_remove_front(index) - } - /// Inserts an element at `index` within the `VecDeque`. Whichever /// end is closer to the insertion point will be moved to make room, /// and all the affected elements will be moved to new positions. @@ -2178,7 +2160,7 @@ mod tests { tester.push_front(i); } for i in 0..len { - assert_eq!(tester.swap_back_remove(i), Some(len * 2 - 1 - i)); + assert_eq!(tester.swap_remove_back(i), Some(len * 2 - 1 - i)); } } else { for i in 0..len * 2 { @@ -2186,7 +2168,7 @@ mod tests { } for i in 0..len { let idx = tester.len() - 1 - i; - assert_eq!(tester.swap_front_remove(idx), Some(len * 2 - 1 - i)); + assert_eq!(tester.swap_remove_front(idx), Some(len * 2 - 1 - i)); } } assert!(tester.tail < tester.cap()); diff --git a/src/libcollectionstest/binary_heap.rs b/src/libcollectionstest/binary_heap.rs index 303a0ce811df6..cc4366e8ae463 100644 --- a/src/libcollectionstest/binary_heap.rs +++ b/src/libcollectionstest/binary_heap.rs @@ -14,7 +14,7 @@ use std::collections::BinaryHeap; fn test_iterator() { let data = vec![5, 9, 3]; let iterout = [9, 5, 3]; - let heap = BinaryHeap::from_vec(data); + let heap = BinaryHeap::from(data); let mut i = 0; for el in &heap { assert_eq!(*el, iterout[i]); @@ -26,7 +26,7 @@ fn test_iterator() { fn test_iterator_reverse() { let data = vec![5, 9, 3]; let iterout = vec![3, 5, 9]; - let pq = BinaryHeap::from_vec(data); + let pq = BinaryHeap::from(data); let v: Vec<_> = pq.iter().rev().cloned().collect(); assert_eq!(v, iterout); @@ -36,7 +36,7 @@ fn test_iterator_reverse() { fn test_move_iter() { let data = vec![5, 9, 3]; let iterout = vec![9, 5, 3]; - let pq = BinaryHeap::from_vec(data); + let pq = BinaryHeap::from(data); let v: Vec<_> = pq.into_iter().collect(); assert_eq!(v, iterout); @@ -45,7 +45,7 @@ fn test_move_iter() { #[test] fn test_move_iter_size_hint() { let data = vec![5, 9]; - let pq = BinaryHeap::from_vec(data); + let pq = BinaryHeap::from(data); let mut it = pq.into_iter(); @@ -63,7 +63,7 @@ fn test_move_iter_size_hint() { fn test_move_iter_reverse() { let data = vec![5, 9, 3]; let iterout = vec![3, 5, 9]; - let pq = BinaryHeap::from_vec(data); + let pq = BinaryHeap::from(data); let v: Vec<_> = pq.into_iter().rev().collect(); assert_eq!(v, iterout); @@ -74,7 +74,7 @@ fn test_peek_and_pop() { let data = vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]; let mut sorted = data.clone(); sorted.sort(); - let mut heap = BinaryHeap::from_vec(data); + let mut heap = BinaryHeap::from(data); while !heap.is_empty() { assert_eq!(heap.peek().unwrap(), sorted.last().unwrap()); assert_eq!(heap.pop().unwrap(), sorted.pop().unwrap()); @@ -83,7 +83,7 @@ fn test_peek_and_pop() { #[test] fn test_push() { - let mut heap = BinaryHeap::from_vec(vec![2, 4, 9]); + let mut heap = BinaryHeap::from(vec![2, 4, 9]); assert_eq!(heap.len(), 3); assert!(*heap.peek().unwrap() == 9); heap.push(11); @@ -105,7 +105,7 @@ fn test_push() { #[test] fn test_push_unique() { - let mut heap = BinaryHeap::>::from_vec(vec![box 2, box 4, box 9]); + let mut heap = BinaryHeap::>::from(vec![box 2, box 4, box 9]); assert_eq!(heap.len(), 3); assert!(*heap.peek().unwrap() == box 9); heap.push(box 11); @@ -127,7 +127,7 @@ fn test_push_unique() { #[test] fn test_push_pop() { - let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]); + let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]); assert_eq!(heap.len(), 5); assert_eq!(heap.push_pop(6), 6); assert_eq!(heap.len(), 5); @@ -141,7 +141,7 @@ fn test_push_pop() { #[test] fn test_replace() { - let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]); + let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]); assert_eq!(heap.len(), 5); assert_eq!(heap.replace(6).unwrap(), 5); assert_eq!(heap.len(), 5); @@ -154,7 +154,7 @@ fn test_replace() { } fn check_to_vec(mut data: Vec) { - let heap = BinaryHeap::from_vec(data.clone()); + let heap = BinaryHeap::from(data.clone()); let mut v = heap.clone().into_vec(); v.sort(); data.sort(); diff --git a/src/libcollectionstest/btree/map.rs b/src/libcollectionstest/btree/map.rs index 846353cc4e7c2..dfb72d78d4611 100644 --- a/src/libcollectionstest/btree/map.rs +++ b/src/libcollectionstest/btree/map.rs @@ -11,7 +11,6 @@ use std::collections::BTreeMap; use std::collections::Bound::{Excluded, Included, Unbounded, self}; use std::collections::btree_map::Entry::{Occupied, Vacant}; -use std::iter::range_inclusive; use std::rc::Rc; #[test] @@ -188,7 +187,7 @@ fn test_range() { for i in 0..size { for j in i..size { let mut kvs = map.range(Included(&i), Included(&j)).map(|(&k, &v)| (k, v)); - let mut pairs = range_inclusive(i, j).map(|i| (i, i)); + let mut pairs = (i..j+1).map(|i| (i, i)); for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) { assert_eq!(kv, pair); diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 80dcd48fbfaa9..f86c016921ecc 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -866,17 +866,6 @@ fn test_vec_default() { t!(Vec); } -#[test] -fn test_bytes_set_memory() { - use std::slice::bytes::MutableByteVector; - - let mut values = [1,2,3,4,5]; - values[0..5].set_memory(0xAB); - assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]); - values[2..4].set_memory(0xFF); - assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]); -} - #[test] #[should_panic] fn test_overflow_does_not_cause_segfault() { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 959b6a97c5ccb..f063c6b06767b 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -4750,87 +4750,3 @@ impl ExactSizeIterator for Once { pub fn once(value: T) -> Once { Once { inner: Some(value).into_iter() } } - -/// Functions for lexicographical ordering of sequences. -/// -/// Lexicographical ordering through `<`, `<=`, `>=`, `>` requires -/// that the elements implement both `PartialEq` and `PartialOrd`. -/// -/// If two sequences are equal up until the point where one ends, -/// the shorter sequence compares less. -#[rustc_deprecated(since = "1.4.0", reason = "use the equivalent methods on `Iterator` instead")] -#[unstable(feature = "iter_order_deprecated", reason = "needs review and revision", - issue = "27737")] -pub mod order { - use cmp; - use cmp::{Eq, Ord, PartialOrd, PartialEq}; - use option::Option; - use super::Iterator; - - /// Compare `a` and `b` for equality using `Eq` - pub fn equals(a: L, b: R) -> bool where - A: Eq, - L: Iterator, - R: Iterator, - { - a.eq(b) - } - - /// Order `a` and `b` lexicographically using `Ord` - pub fn cmp(a: L, b: R) -> cmp::Ordering where - A: Ord, - L: Iterator, - R: Iterator, - { - a.cmp(b) - } - - /// Order `a` and `b` lexicographically using `PartialOrd` - pub fn partial_cmp(a: L, b: R) -> Option where - L::Item: PartialOrd - { - a.partial_cmp(b) - } - - /// Compare `a` and `b` for equality (Using partial equality, `PartialEq`) - pub fn eq(a: L, b: R) -> bool where - L::Item: PartialEq, - { - a.eq(b) - } - - /// Compares `a` and `b` for nonequality (Using partial equality, `PartialEq`) - pub fn ne(a: L, b: R) -> bool where - L::Item: PartialEq, - { - a.ne(b) - } - - /// Returns `a` < `b` lexicographically (Using partial order, `PartialOrd`) - pub fn lt(a: L, b: R) -> bool where - L::Item: PartialOrd, - { - a.lt(b) - } - - /// Returns `a` <= `b` lexicographically (Using partial order, `PartialOrd`) - pub fn le(a: L, b: R) -> bool where - L::Item: PartialOrd, - { - a.le(b) - } - - /// Returns `a` > `b` lexicographically (Using partial order, `PartialOrd`) - pub fn gt(a: L, b: R) -> bool where - L::Item: PartialOrd, - { - a.gt(b) - } - - /// Returns `a` >= `b` lexicographically (Using partial order, `PartialOrd`) - pub fn ge(a: L, b: R) -> bool where - L::Item: PartialOrd, - { - a.ge(b) - } -} diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 86f2e3bcec396..454e2b02b1ca0 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -153,12 +153,6 @@ pub mod option; pub mod raw; pub mod result; -#[cfg(stage0)] -#[path = "simd_old.rs"] -pub mod simd; -#[cfg(not(stage0))] -pub mod simd; - pub mod slice; pub mod str; pub mod hash; diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 359d15640f978..8af1022acdf24 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -15,11 +15,9 @@ #![stable(feature = "rust1", since = "1.0.0")] -use prelude::v1::*; - use intrinsics; use mem; -use num::{Float, ParseFloatError}; +use num::Float; use num::FpCategory as Fp; #[stable(feature = "rust1", since = "1.0.0")] @@ -163,8 +161,6 @@ impl Float for f32 { #[inline] fn one() -> f32 { 1.0 } - from_str_radix_float_impl! { f32 } - /// Returns `true` if the number is NaN. #[inline] fn is_nan(self) -> bool { self != self } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 1a6acc5f4ab11..9486e4337bf58 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -15,12 +15,10 @@ #![stable(feature = "rust1", since = "1.0.0")] -use prelude::v1::*; - use intrinsics; use mem; use num::FpCategory as Fp; -use num::{Float, ParseFloatError}; +use num::Float; #[stable(feature = "rust1", since = "1.0.0")] #[allow(missing_docs)] @@ -163,8 +161,6 @@ impl Float for f64 { #[inline] fn one() -> f64 { 1.0 } - from_str_radix_float_impl! { f64 } - /// Returns `true` if the number is NaN. #[inline] fn is_nan(self) -> bool { self != self } diff --git a/src/libcore/num/float_macros.rs b/src/libcore/num/float_macros.rs index 88c3b756793a2..b3adef53dabee 100644 --- a/src/libcore/num/float_macros.rs +++ b/src/libcore/num/float_macros.rs @@ -18,144 +18,3 @@ macro_rules! assert_approx_eq { "{} is not approximately equal to {}", *a, *b); }) } - -macro_rules! from_str_radix_float_impl { - ($T:ty) => { - fn from_str_radix(src: &str, radix: u32) - -> Result<$T, ParseFloatError> { - use num::dec2flt::{pfe_empty, pfe_invalid}; - - // Special values - match src { - "inf" => return Ok(Float::infinity()), - "-inf" => return Ok(Float::neg_infinity()), - "NaN" => return Ok(Float::nan()), - _ => {}, - } - - let (is_positive, src) = match src.slice_shift_char() { - None => return Err(pfe_empty()), - Some(('-', "")) => return Err(pfe_empty()), - Some(('-', src)) => (false, src), - Some((_, _)) => (true, src), - }; - - // The significand to accumulate - let mut sig = if is_positive { 0.0 } else { -0.0 }; - // Necessary to detect overflow - let mut prev_sig = sig; - let mut cs = src.chars().enumerate(); - // Exponent prefix and exponent index offset - let mut exp_info = None::<(char, usize)>; - - // Parse the integer part of the significand - for (i, c) in cs.by_ref() { - match c.to_digit(radix) { - Some(digit) => { - // shift significand one digit left - sig = sig * (radix as $T); - - // add/subtract current digit depending on sign - if is_positive { - sig = sig + ((digit as isize) as $T); - } else { - sig = sig - ((digit as isize) as $T); - } - - // Detect overflow by comparing to last value, except - // if we've not seen any non-zero digits. - if prev_sig != 0.0 { - if is_positive && sig <= prev_sig - { return Ok(Float::infinity()); } - if !is_positive && sig >= prev_sig - { return Ok(Float::neg_infinity()); } - - // Detect overflow by reversing the shift-and-add process - if is_positive && (prev_sig != (sig - digit as $T) / radix as $T) - { return Ok(Float::infinity()); } - if !is_positive && (prev_sig != (sig + digit as $T) / radix as $T) - { return Ok(Float::neg_infinity()); } - } - prev_sig = sig; - }, - None => match c { - 'e' | 'E' | 'p' | 'P' => { - exp_info = Some((c, i + 1)); - break; // start of exponent - }, - '.' => { - break; // start of fractional part - }, - _ => { - return Err(pfe_invalid()) - }, - }, - } - } - - // If we are not yet at the exponent parse the fractional - // part of the significand - if exp_info.is_none() { - let mut power = 1.0; - for (i, c) in cs.by_ref() { - match c.to_digit(radix) { - Some(digit) => { - // Decrease power one order of magnitude - power = power / (radix as $T); - // add/subtract current digit depending on sign - sig = if is_positive { - sig + (digit as $T) * power - } else { - sig - (digit as $T) * power - }; - // Detect overflow by comparing to last value - if is_positive && sig < prev_sig - { return Ok(Float::infinity()); } - if !is_positive && sig > prev_sig - { return Ok(Float::neg_infinity()); } - prev_sig = sig; - }, - None => match c { - 'e' | 'E' | 'p' | 'P' => { - exp_info = Some((c, i + 1)); - break; // start of exponent - }, - _ => { - return Err(pfe_invalid()) - }, - }, - } - } - } - - // Parse and calculate the exponent - let exp = match exp_info { - Some((c, offset)) => { - let base = match c { - 'E' | 'e' if radix == 10 => 10.0, - 'P' | 'p' if radix == 16 => 2.0, - _ => return Err(pfe_invalid()), - }; - - // Parse the exponent as decimal integer - let src = &src[offset..]; - let (is_positive, exp) = match src.slice_shift_char() { - Some(('-', src)) => (false, src.parse::()), - Some(('+', src)) => (true, src.parse::()), - Some((_, _)) => (true, src.parse::()), - None => return Err(pfe_invalid()), - }; - - match (is_positive, exp) { - (true, Ok(exp)) => base.powi(exp as i32), - (false, Ok(exp)) => 1.0 / base.powi(exp as i32), - (_, Err(_)) => return Err(pfe_invalid()), - } - }, - None => 1.0, // no exponent - }; - - Ok(sig * exp) - } - } -} diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index e1e5c01adb705..4f3c12567095e 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1771,12 +1771,6 @@ pub trait Float: Sized { #[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")] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 209cebeaf1bc3..a1a434ba9199e 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -154,7 +154,6 @@ use mem; use ops::FnOnce; use result::Result::{Ok, Err}; use result::Result; -use slice; // Note that this is not a lang item per se, but it has a hidden dependency on // `Iterator`, which is one. The compiler assumes that the `next` method of @@ -269,42 +268,6 @@ impl Option { } } - /// Converts from `Option` to `&mut [T]` (without copying) - /// - /// # Examples - /// - /// ``` - /// #![feature(as_slice)] - /// # #![allow(deprecated)] - /// - /// let mut x = Some("Diamonds"); - /// { - /// let v = x.as_mut_slice(); - /// assert!(v == ["Diamonds"]); - /// v[0] = "Dirt"; - /// assert!(v == ["Dirt"]); - /// } - /// assert_eq!(x, Some("Dirt")); - /// ``` - #[inline] - #[unstable(feature = "as_slice", - reason = "waiting for mut conventions", - issue = "27776")] - #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")] - #[allow(deprecated)] - pub fn as_mut_slice(&mut self) -> &mut [T] { - match *self { - Some(ref mut x) => { - let result: &mut [T] = slice::mut_ref_slice(x); - result - } - None => { - let result: &mut [T] = &mut []; - result - } - } - } - ///////////////////////////////////////////////////////////////////////// // Getting to contained values ///////////////////////////////////////////////////////////////////////// @@ -690,22 +653,6 @@ impl Option { pub fn take(&mut self) -> Option { mem::replace(self, None) } - - /// Converts from `Option` to `&[T]` (without copying) - #[inline] - #[unstable(feature = "as_slice", reason = "unsure of the utility here", - issue = "27776")] - #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")] - #[allow(deprecated)] - pub fn as_slice(&self) -> &[T] { - match *self { - Some(ref x) => slice::ref_slice(x), - None => { - let result: &[_] = &[]; - result - } - } - } } impl<'a, T: Clone> Option<&'a T> { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 37c40f96b0f71..402855861186f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -240,7 +240,6 @@ use fmt; use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator}; use ops::FnOnce; use option::Option::{self, None, Some}; -use slice; /// `Result` is a type that represents either success (`Ok`) or failure (`Err`). /// @@ -406,58 +405,6 @@ impl Result { } } - /// Converts from `Result` to `&[T]` (without copying) - #[inline] - #[unstable(feature = "as_slice", reason = "unsure of the utility here", - issue = "27776")] - #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")] - #[allow(deprecated)] - pub fn as_slice(&self) -> &[T] { - match *self { - Ok(ref x) => slice::ref_slice(x), - Err(_) => { - // work around lack of implicit coercion from fixed-size array to slice - let emp: &[_] = &[]; - emp - } - } - } - - /// Converts from `Result` to `&mut [T]` (without copying) - /// - /// ``` - /// #![feature(as_slice)] - /// # #![allow(deprecated)] - /// - /// let mut x: Result<&str, u32> = Ok("Gold"); - /// { - /// let v = x.as_mut_slice(); - /// assert!(v == ["Gold"]); - /// v[0] = "Silver"; - /// assert!(v == ["Silver"]); - /// } - /// assert_eq!(x, Ok("Silver")); - /// - /// let mut x: Result<&str, u32> = Err(45); - /// assert!(x.as_mut_slice().is_empty()); - /// ``` - #[inline] - #[unstable(feature = "as_slice", - reason = "waiting for mut conventions", - issue = "27776")] - #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")] - #[allow(deprecated)] - pub fn as_mut_slice(&mut self) -> &mut [T] { - match *self { - Ok(ref mut x) => slice::mut_ref_slice(x), - Err(_) => { - // work around lack of implicit coercion from fixed-size array to slice - let emp: &mut [_] = &mut []; - emp - } - } - } - ///////////////////////////////////////////////////////////////////////// // Transforming contained values ///////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs deleted file mode 100644 index 697f96ddefbf8..0000000000000 --- a/src/libcore/simd.rs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2013 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. - -//! SIMD vectors. -//! -//! These types can be used for accessing basic SIMD operations. Currently -//! comparison operators are not implemented. To use SSE3+, you must enable -//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more -//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are -//! provided beyond this module. -//! -//! # Stability Note -//! -//! These are all experimental. The interface may change entirely, without -//! warning. - -#![unstable(feature = "core_simd", - reason = "needs an RFC to flesh out the design", - issue = "27731")] -#![rustc_deprecated(since = "1.3.0", - reason = "use the external `simd` crate instead")] - -#![allow(non_camel_case_types)] -#![allow(missing_docs)] -#![allow(deprecated)] - -use ops::{Add, Sub, Mul, Div, Shl, Shr, BitAnd, BitOr, BitXor}; - -// FIXME(stage0): the contents of macro can be inlined. -// ABIs are verified as valid as soon as they are parsed, i.e. before -// `cfg` stripping. The `platform-intrinsic` ABI is new, so stage0 -// doesn't know about it, but it still errors out when it hits it -// (despite this being in a `cfg(not(stage0))` module). -macro_rules! argh { - () => { - extern "platform-intrinsic" { - fn simd_add(x: T, y: T) -> T; - fn simd_sub(x: T, y: T) -> T; - fn simd_mul(x: T, y: T) -> T; - fn simd_div(x: T, y: T) -> T; - fn simd_shl(x: T, y: T) -> T; - fn simd_shr(x: T, y: T) -> T; - fn simd_and(x: T, y: T) -> T; - fn simd_or(x: T, y: T) -> T; - fn simd_xor(x: T, y: T) -> T; - } - } -} -argh!(); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i8x16(pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i16x8(pub i16, pub i16, pub i16, pub i16, - pub i16, pub i16, pub i16, pub i16); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i32x4(pub i32, pub i32, pub i32, pub i32); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i64x2(pub i64, pub i64); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u8x16(pub u8, pub u8, pub u8, pub u8, - pub u8, pub u8, pub u8, pub u8, - pub u8, pub u8, pub u8, pub u8, - pub u8, pub u8, pub u8, pub u8); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u16x8(pub u16, pub u16, pub u16, pub u16, - pub u16, pub u16, pub u16, pub u16); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u64x2(pub u64, pub u64); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct f32x4(pub f32, pub f32, pub f32, pub f32); - -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct f64x2(pub f64, pub f64); - -macro_rules! impl_traits { - ($($trayt: ident, $method: ident, $func: ident: $($ty: ty),*;)*) => { - $($( - impl $trayt<$ty> for $ty { - type Output = Self; - fn $method(self, other: Self) -> Self { - unsafe { - $func(self, other) - } - } - } - )*)* - } -} - -impl_traits! { - Add, add, simd_add: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2; - Sub, sub, simd_sub: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2; - Mul, mul, simd_mul: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2; - - Div, div, simd_div: f32x4, f64x2; - - Shl, shl, simd_shl: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2; - Shr, shr, simd_shr: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2; - BitAnd, bitand, simd_and: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2; - BitOr, bitor, simd_or: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2; - BitXor, bitxor, simd_xor: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2; -} diff --git a/src/libcore/simd_old.rs b/src/libcore/simd_old.rs deleted file mode 100644 index 7ecd08bea3574..0000000000000 --- a/src/libcore/simd_old.rs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2013 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. - -//! SIMD vectors. -//! -//! These types can be used for accessing basic SIMD operations. Each of them -//! implements the standard arithmetic operator traits (Add, Sub, Mul, Div, -//! Rem, Shl, Shr) through compiler magic, rather than explicitly. Currently -//! comparison operators are not implemented. To use SSE3+, you must enable -//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more -//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are -//! provided beyond this module. -//! -//! ```rust -//! # #![feature(core_simd)] -//! fn main() { -//! use std::simd::f32x4; -//! let a = f32x4(40.0, 41.0, 42.0, 43.0); -//! let b = f32x4(1.0, 1.1, 3.4, 9.8); -//! println!("{:?}", a + b); -//! } -//! ``` -//! -//! # Stability Note -//! -//! These are all experimental. The interface may change entirely, without -//! warning. - -#![unstable(feature = "core_simd", - reason = "needs an RFC to flesh out the design")] - -#![allow(non_camel_case_types)] -#![allow(missing_docs)] - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i8x16(pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i16x8(pub i16, pub i16, pub i16, pub i16, - pub i16, pub i16, pub i16, pub i16); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i32x4(pub i32, pub i32, pub i32, pub i32); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct i64x2(pub i64, pub i64); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u8x16(pub u8, pub u8, pub u8, pub u8, - pub u8, pub u8, pub u8, pub u8, - pub u8, pub u8, pub u8, pub u8, - pub u8, pub u8, pub u8, pub u8); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u16x8(pub u16, pub u16, pub u16, pub u16, - pub u16, pub u16, pub u16, pub u16); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct u64x2(pub u64, pub u64); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct f32x4(pub f32, pub f32, pub f32, pub f32); - -#[simd] -#[derive(Copy, Clone, Debug)] -#[repr(C)] -pub struct f64x2(pub f64, pub f64); diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 70175086147b7..b17fac4d77162 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1380,24 +1380,6 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {} // Free functions // -/// Converts a reference to A into a slice of length 1 (without copying). -#[unstable(feature = "ref_slice", issue = "27774")] -#[rustc_deprecated(since = "1.5.0", reason = "unclear whether belongs in libstd")] -pub fn ref_slice(s: &A) -> &[A] { - unsafe { - from_raw_parts(s, 1) - } -} - -/// Converts a reference to A into a slice of length 1 (without copying). -#[unstable(feature = "ref_slice", issue = "27774")] -#[rustc_deprecated(since = "1.5.0", reason = "unclear whether belongs in libstd")] -pub fn mut_ref_slice(s: &mut A) -> &mut [A] { - unsafe { - from_raw_parts_mut(s, 1) - } -} - /// Forms a slice from a pointer and a length. /// /// The `len` argument is the number of **elements**, not the number of bytes. diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 9def44191db05..ba308314e9e8f 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -829,18 +829,6 @@ fn test_range() { (isize::MAX as usize + 2, Some(isize::MAX as usize + 2))); } -#[test] -fn test_range_inclusive() { - assert!(range_inclusive(0, 5).collect::>() == - vec![0, 1, 2, 3, 4, 5]); - assert!(range_inclusive(0, 5).rev().collect::>() == - vec![5, 4, 3, 2, 1, 0]); - assert_eq!(range_inclusive(200, -5).count(), 0); - assert_eq!(range_inclusive(200, -5).rev().count(), 0); - assert_eq!(range_inclusive(200, 200).collect::>(), [200]); - assert_eq!(range_inclusive(200, 200).rev().collect::>(), [200]); -} - #[test] fn test_range_step() { assert_eq!((0..20).step_by(5).collect::>(), [0, 5, 10, 15]); diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 20da4a86bf545..88f1835d2cce4 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -43,6 +43,7 @@ #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] +#![feature(clone_from_slice)] extern crate core; extern crate test; diff --git a/src/libcoretest/num/flt2dec/mod.rs b/src/libcoretest/num/flt2dec/mod.rs index 309bf6d819218..65b233ee92f41 100644 --- a/src/libcoretest/num/flt2dec/mod.rs +++ b/src/libcoretest/num/flt2dec/mod.rs @@ -10,7 +10,6 @@ use std::prelude::v1::*; use std::{str, mem, i16, f32, f64, fmt}; -use std::slice::bytes; use std::__rand as rand; use rand::{Rand, XorShiftRng}; use rand::distributions::{IndependentSample, Range}; @@ -101,7 +100,7 @@ fn check_exact(mut f: F, v: T, vstr: &str, expected: &[u8], expectedk: i16 // check significant digits for i in 1..cut.unwrap_or(expected.len() - 1) { - bytes::copy_memory(&expected[..i], &mut expected_); + expected_.clone_from_slice(&expected[..i]); let mut expectedk_ = expectedk; if expected[i] >= b'5' { // check if this is a rounding-to-even case. @@ -148,7 +147,7 @@ fn check_exact(mut f: F, v: T, vstr: &str, expected: &[u8], expectedk: i16 // check infinite zero digits if let Some(cut) = cut { for i in cut..expected.len()-1 { - bytes::copy_memory(&expected[..cut], &mut expected_); + expected_.clone_from_slice(&expected[..cut]); for c in &mut expected_[cut..i] { *c = b'0'; } try_exact!(f(&decoded) => &mut buf, &expected_[..i], expectedk; diff --git a/src/libcoretest/num/mod.rs b/src/libcoretest/num/mod.rs index 738761f3911b6..09f2e3265034b 100644 --- a/src/libcoretest/num/mod.rs +++ b/src/libcoretest/num/mod.rs @@ -54,35 +54,6 @@ mod tests { use core::option::Option::{Some, None}; use core::num::Float; - #[test] - fn from_str_issue7588() { - let u : Option = u8::from_str_radix("1000", 10).ok(); - assert_eq!(u, None); - let s : Option = i16::from_str_radix("80000", 10).ok(); - assert_eq!(s, None); - let s = "10000000000000000000000000000000000000000"; - let f : Option = f32::from_str_radix(s, 10).ok(); - assert_eq!(f, Some(Float::infinity())); - let fe : Option = f32::from_str_radix("1e40", 10).ok(); - assert_eq!(fe, Some(Float::infinity())); - } - - #[test] - fn test_from_str_radix_float() { - let x1 : Option = f64::from_str_radix("-123.456", 10).ok(); - assert_eq!(x1, Some(-123.456)); - let x2 : Option = f32::from_str_radix("123.456", 10).ok(); - assert_eq!(x2, Some(123.456)); - let x3 : Option = f32::from_str_radix("-0.0", 10).ok(); - assert_eq!(x3, Some(-0.0)); - let x4 : Option = f32::from_str_radix("0.0", 10).ok(); - assert_eq!(x4, Some(0.0)); - let x4 : Option = f32::from_str_radix("1.0", 10).ok(); - assert_eq!(x4, Some(1.0)); - let x5 : Option = f32::from_str_radix("-1.0", 10).ok(); - assert_eq!(x5, Some(-1.0)); - } - #[test] fn test_int_from_str_overflow() { let mut i8_val: i8 = 127; diff --git a/src/librand/chacha.rs b/src/librand/chacha.rs index e2c157f98a6a4..cd099c69005f3 100644 --- a/src/librand/chacha.rs +++ b/src/librand/chacha.rs @@ -208,7 +208,6 @@ impl Rand for ChaChaRng { mod tests { use std::prelude::v1::*; - use core::iter::order; use {Rng, SeedableRng}; use super::ChaChaRng; @@ -217,8 +216,8 @@ mod tests { let s = ::test::rng().gen_iter::().take(8).collect::>(); let mut ra: ChaChaRng = SeedableRng::from_seed(&*s); let mut rb: ChaChaRng = SeedableRng::from_seed(&*s); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] @@ -226,8 +225,8 @@ mod tests { let seed: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7]; let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let mut rb: ChaChaRng = SeedableRng::from_seed(seed); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 1f56a82eba86e..dd99bc93ef379 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -544,7 +544,6 @@ impl Rand for Isaac64Rng { mod tests { use std::prelude::v1::*; - use core::iter::order; use {Rng, SeedableRng}; use super::{IsaacRng, Isaac64Rng}; @@ -553,16 +552,16 @@ mod tests { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]); let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_64_rand_seeded() { let s = ::test::rng().gen_iter::().take(256).collect::>(); let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]); let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] @@ -570,16 +569,16 @@ mod tests { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: IsaacRng = SeedableRng::from_seed(seed); let mut rb: IsaacRng = SeedableRng::from_seed(seed); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] fn test_rng_64_seeded() { let seed: &[_] = &[1, 23, 456, 7890, 12345]; let mut ra: Isaac64Rng = SeedableRng::from_seed(seed); let mut rb: Isaac64Rng = SeedableRng::from_seed(seed); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index 8ef94eb16f25d..db5e0213726d9 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -122,7 +122,6 @@ impl Default for ReseedWithDefault { mod tests { use std::prelude::v1::*; - use core::iter::order; use super::{ReseedingRng, ReseedWithDefault}; use {SeedableRng, Rng}; @@ -167,8 +166,8 @@ mod tests { fn test_rng_seeded() { let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2)); - assert!(order::equals(ra.gen_ascii_chars().take(100), - rb.gen_ascii_chars().take(100))); + assert!(ra.gen_ascii_chars().take(100) + .eq(rb.gen_ascii_chars().take(100))); } #[test] diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index e440b1171863c..8bde24d2b0c42 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -48,8 +48,8 @@ pub mod char; #[allow(deprecated)] pub mod str { pub use u_str::{UnicodeStr, SplitWhitespace}; - pub use u_str::{utf8_char_width, is_utf16, Utf16Items, Utf16Item}; - pub use u_str::{utf16_items, Utf16Encoder}; + pub use u_str::{utf8_char_width, is_utf16}; + pub use u_str::{Utf16Encoder}; } // For use in libcollections, not re-exported in libstd. diff --git a/src/librustc_unicode/u_str.rs b/src/librustc_unicode/u_str.rs index 4d9f5d5fdd459..f65c05672f68b 100644 --- a/src/librustc_unicode/u_str.rs +++ b/src/librustc_unicode/u_str.rs @@ -13,10 +13,8 @@ //! This module provides functionality to `str` that requires the Unicode //! methods provided by the unicode parts of the CharExt trait. -use char::{DecodeUtf16, decode_utf16}; use core::char; -use core::iter::{Cloned, Filter}; -use core::slice; +use core::iter::Filter; use core::str::Split; /// An iterator over the non-whitespace substrings of a string, @@ -127,97 +125,6 @@ pub fn is_utf16(v: &[u16]) -> bool { } } -/// An iterator that decodes UTF-16 encoded codepoints from a vector -/// of `u16`s. -#[rustc_deprecated(since = "1.4.0", reason = "renamed to `char::DecodeUtf16`")] -#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")] -#[allow(deprecated)] -#[derive(Clone)] -pub struct Utf16Items<'a> { - decoder: DecodeUtf16>>, -} - -/// The possibilities for values decoded from a `u16` stream. -#[rustc_deprecated(since = "1.4.0", - reason = "`char::DecodeUtf16` uses `Result` instead")] -#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")] -#[allow(deprecated)] -#[derive(Copy, PartialEq, Eq, Clone, Debug)] -pub enum Utf16Item { - /// A valid codepoint. - ScalarValue(char), - /// An invalid surrogate without its pair. - LoneSurrogate(u16), -} - -#[allow(deprecated)] -impl Utf16Item { - /// Convert `self` to a `char`, taking `LoneSurrogate`s to the - /// replacement character (U+FFFD). - #[inline] - pub fn to_char_lossy(&self) -> char { - match *self { - Utf16Item::ScalarValue(c) => c, - Utf16Item::LoneSurrogate(_) => '\u{FFFD}', - } - } -} - -#[rustc_deprecated(since = "1.4.0", reason = "use `char::DecodeUtf16` instead")] -#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")] -#[allow(deprecated)] -impl<'a> Iterator for Utf16Items<'a> { - type Item = Utf16Item; - - fn next(&mut self) -> Option { - self.decoder.next().map(|result| { - match result { - Ok(c) => Utf16Item::ScalarValue(c), - Err(s) => Utf16Item::LoneSurrogate(s), - } - }) - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - self.decoder.size_hint() - } -} - -/// Create an iterator over the UTF-16 encoded codepoints in `v`, -/// returning invalid surrogates as `LoneSurrogate`s. -/// -/// # Examples -/// -/// ``` -/// #![feature(unicode, decode_utf16)] -/// # #![allow(deprecated)] -/// -/// extern crate rustc_unicode; -/// -/// use rustc_unicode::str::Utf16Item::{ScalarValue, LoneSurrogate}; -/// -/// fn main() { -/// // 𝄞music -/// let v = [0xD834, 0xDD1E, 0x006d, 0x0075, -/// 0x0073, 0xDD1E, 0x0069, 0x0063, -/// 0xD834]; -/// -/// assert_eq!(rustc_unicode::str::utf16_items(&v).collect::>(), -/// vec![ScalarValue('𝄞'), -/// ScalarValue('m'), ScalarValue('u'), ScalarValue('s'), -/// LoneSurrogate(0xDD1E), -/// ScalarValue('i'), ScalarValue('c'), -/// LoneSurrogate(0xD834)]); -/// } -/// ``` -#[rustc_deprecated(since = "1.4.0", reason = "renamed to `char::decode_utf16`")] -#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")] -#[allow(deprecated)] -pub fn utf16_items<'a>(v: &'a [u16]) -> Utf16Items<'a> { - Utf16Items { decoder: decode_utf16(v.iter().cloned()) } -} - /// Iterator adaptor for encoding `char`s to UTF-16. #[derive(Clone)] pub struct Utf16Encoder { diff --git a/src/libstd/collections/hash/bench.rs b/src/libstd/collections/hash/bench.rs index ac21ae0f0aa14..9fae9af2d54d4 100644 --- a/src/libstd/collections/hash/bench.rs +++ b/src/libstd/collections/hash/bench.rs @@ -14,7 +14,6 @@ extern crate test; use prelude::v1::*; use self::test::Bencher; -use iter::range_inclusive; #[bench] fn new_drop(b : &mut Bencher) { @@ -43,7 +42,7 @@ fn grow_by_insertion(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in 1..1001 { m.insert(i, i); } @@ -61,12 +60,12 @@ fn find_existing(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in 1..1001 { m.insert(i, i); } b.iter(|| { - for i in range_inclusive(1, 1000) { + for i in 1..1001 { m.contains_key(&i); } }); @@ -78,12 +77,12 @@ fn find_nonexisting(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in 1..1001 { m.insert(i, i); } b.iter(|| { - for i in range_inclusive(1001, 2000) { + for i in 1001..2001 { m.contains_key(&i); } }); @@ -95,7 +94,7 @@ fn hashmap_as_queue(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in 1..1001 { m.insert(i, i); } @@ -114,7 +113,7 @@ fn get_remove_insert(b: &mut Bencher) { let mut m = HashMap::new(); - for i in range_inclusive(1, 1000) { + for i in 1..1001 { m.insert(i, i); } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 77c4149f9926e..38c080febf196 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1681,7 +1681,6 @@ mod test_map { use super::HashMap; use super::Entry::{Occupied, Vacant}; - use iter::range_inclusive; use cell::RefCell; use rand::{thread_rng, Rng}; @@ -1877,42 +1876,42 @@ mod test_map { for _ in 0..10 { assert!(m.is_empty()); - for i in range_inclusive(1, 1000) { + for i in 1..1001 { assert!(m.insert(i, i).is_none()); - for j in range_inclusive(1, i) { + for j in 1..i+1 { let r = m.get(&j); assert_eq!(r, Some(&j)); } - for j in range_inclusive(i+1, 1000) { + for j in i+1..1001 { let r = m.get(&j); assert_eq!(r, None); } } - for i in range_inclusive(1001, 2000) { + for i in 1001..2001 { assert!(!m.contains_key(&i)); } // remove forwards - for i in range_inclusive(1, 1000) { + for i in 1..1001 { assert!(m.remove(&i).is_some()); - for j in range_inclusive(1, i) { + for j in 1..i+1 { assert!(!m.contains_key(&j)); } - for j in range_inclusive(i+1, 1000) { + for j in i+1..1001 { assert!(m.contains_key(&j)); } } - for i in range_inclusive(1, 1000) { + for i in 1..1001 { assert!(!m.contains_key(&i)); } - for i in range_inclusive(1, 1000) { + for i in 1..1001 { assert!(m.insert(i, i).is_none()); } @@ -1920,11 +1919,11 @@ mod test_map { for i in (1..1001).rev() { assert!(m.remove(&i).is_some()); - for j in range_inclusive(i, 1000) { + for j in i..1001 { assert!(!m.contains_key(&j)); } - for j in range_inclusive(1, i-1) { + for j in 1..i { assert!(m.contains_key(&j)); } } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 40fb450bea195..318ff410cbad4 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -206,18 +206,6 @@ impl CString { CString { inner: v.into_boxed_slice() } } - /// Retakes ownership of a CString that was transferred to C. - /// - /// The only appropriate argument is a pointer obtained by calling - /// `into_raw`. The length of the string will be recalculated - /// using the pointer. - #[unstable(feature = "cstr_memory2", reason = "recently added", - issue = "27769")] - #[rustc_deprecated(since = "1.4.0", reason = "renamed to from_raw")] - pub unsafe fn from_ptr(ptr: *const c_char) -> CString { - CString::from_raw(ptr as *mut _) - } - /// Retakes ownership of a CString that was transferred to C. /// /// The only appropriate argument is a pointer obtained by calling @@ -230,21 +218,6 @@ impl CString { CString { inner: mem::transmute(slice) } } - /// Transfers ownership of the string to a C caller. - /// - /// The pointer must be returned to Rust and reconstituted using - /// `from_raw` to be properly deallocated. Specifically, one - /// should *not* use the standard C `free` function to deallocate - /// this string. - /// - /// Failure to call `from_raw` will lead to a memory leak. - #[unstable(feature = "cstr_memory2", reason = "recently added", - issue = "27769")] - #[rustc_deprecated(since = "1.4.0", reason = "renamed to into_raw")] - pub fn into_ptr(self) -> *const c_char { - self.into_raw() as *const _ - } - /// Transfers ownership of the string to a C caller. /// /// The pointer must be returned to Rust and reconstituted using diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index bfad224835932..25a05efd02666 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1178,85 +1178,6 @@ impl Iterator for WalkDir { } } -/// Utility methods for paths. -#[unstable(feature = "path_ext_deprecated", - reason = "The precise set of methods exposed on this trait may \ - change and some methods may be removed. For stable code, \ - see the std::fs::metadata function.", - issue = "27725")] -#[rustc_deprecated(since = "1.5.0", reason = "replaced with inherent methods")] -pub trait PathExt { - /// Gets information on the file, directory, etc at this path. - /// - /// Consult the `fs::metadata` documentation for more info. - /// - /// This call preserves identical runtime/error semantics with - /// `fs::metadata`. - fn metadata(&self) -> io::Result; - - /// Gets information on the file, directory, etc at this path. - /// - /// Consult the `fs::symlink_metadata` documentation for more info. - /// - /// This call preserves identical runtime/error semantics with - /// `fs::symlink_metadata`. - fn symlink_metadata(&self) -> io::Result; - - /// Returns the canonical form of a path, normalizing all components and - /// eliminate all symlinks. - /// - /// This call preserves identical runtime/error semantics with - /// `fs::canonicalize`. - fn canonicalize(&self) -> io::Result; - - /// Reads the symlink at this path. - /// - /// For more information see `fs::read_link`. - fn read_link(&self) -> io::Result; - - /// Reads the directory at this path. - /// - /// For more information see `fs::read_dir`. - fn read_dir(&self) -> io::Result; - - /// Boolean value indicator whether the underlying file exists on the local - /// filesystem. Returns false in exactly the cases where `fs::metadata` - /// fails. - fn exists(&self) -> bool; - - /// Whether the underlying implementation (be it a file path, or something - /// else) points at a "regular file" on the FS. Will return false for paths - /// to non-existent locations or directories or other non-regular files - /// (named pipes, etc). Follows links when making this determination. - fn is_file(&self) -> bool; - - /// Whether the underlying implementation (be it a file path, or something - /// else) is pointing at a directory in the underlying FS. Will return - /// false for paths to non-existent locations or if the item is not a - /// directory (eg files, named pipes, etc). Follows links when making this - /// determination. - fn is_dir(&self) -> bool; -} - -#[allow(deprecated)] -#[unstable(feature = "path_ext_deprecated", issue = "27725")] -impl PathExt for Path { - fn metadata(&self) -> io::Result { metadata(self) } - fn symlink_metadata(&self) -> io::Result { symlink_metadata(self) } - fn canonicalize(&self) -> io::Result { canonicalize(self) } - fn read_link(&self) -> io::Result { read_link(self) } - fn read_dir(&self) -> io::Result { read_dir(self) } - fn exists(&self) -> bool { metadata(self).is_ok() } - - fn is_file(&self) -> bool { - metadata(self).map(|s| s.is_file()).unwrap_or(false) - } - - fn is_dir(&self) -> bool { - metadata(self).map(|s| s.is_dir()).unwrap_or(false) - } -} - /// Changes the permissions found on a file or a directory. /// /// # Examples diff --git a/src/libstd/io/prelude.rs b/src/libstd/io/prelude.rs index f588ec60589e9..8772d0f5b099b 100644 --- a/src/libstd/io/prelude.rs +++ b/src/libstd/io/prelude.rs @@ -22,6 +22,3 @@ #[stable(feature = "rust1", since = "1.0.0")] pub use super::{Read, Write, BufRead, Seek}; -#[allow(deprecated)] -#[unstable(feature = "path_ext_deprecated", issue = "27725")] -pub use fs::PathExt; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8e6c32ff2fce2..c8b8caee84ee6 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -233,7 +233,6 @@ #![feature(const_fn)] #![feature(core_float)] #![feature(core_intrinsics)] -#![feature(core_simd)] #![feature(decode_utf16)] #![feature(drop_in_place)] #![feature(dropck_parametricity)] @@ -255,6 +254,7 @@ #![feature(rand)] #![feature(range_inclusive)] #![feature(raw)] +#![feature(repr_simd)] #![feature(reflect_marker)] #![feature(shared)] #![feature(slice_bytes)] @@ -334,9 +334,6 @@ pub use core::ptr; #[stable(feature = "rust1", since = "1.0.0")] pub use core::raw; #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] -pub use core::simd; -#[stable(feature = "rust1", since = "1.0.0")] pub use core::result; #[stable(feature = "rust1", since = "1.0.0")] pub use core::option; diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index c87becd741eb1..30bee80fbf658 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -18,7 +18,7 @@ use core::num; use intrinsics; use libc::c_int; -use num::{FpCategory, ParseFloatError}; +use num::FpCategory; #[stable(feature = "rust1", since = "1.0.0")] pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON}; @@ -126,16 +126,6 @@ mod cmath { #[cfg(not(test))] #[lang = "f32"] impl f32 { - /// Parses a float as with a given radix - #[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")] - #[allow(deprecated)] - pub fn from_str_radix(s: &str, radix: u32) -> Result { - num::Float::from_str_radix(s, radix) - } - /// Returns `true` if this value is `NaN` and false otherwise. /// /// ``` @@ -1712,11 +1702,9 @@ mod tests { #[test] fn test_ldexp() { - // We have to use from_str until base-2 exponents - // are supported in floating-point literals - let f1: f32 = f32::from_str_radix("1p-123", 16).unwrap(); - let f2: f32 = f32::from_str_radix("1p-111", 16).unwrap(); - let f3: f32 = f32::from_str_radix("1.Cp-12", 16).unwrap(); + let f1 = 2.0f32.powi(-123); + let f2 = 2.0f32.powi(-111); + let f3 = 1.75 * 2.0f32.powi(-12); assert_eq!(f32::ldexp(1f32, -123), f1); assert_eq!(f32::ldexp(1f32, -111), f2); assert_eq!(f32::ldexp(1.75f32, -12), f3); @@ -1734,11 +1722,9 @@ mod tests { #[test] fn test_frexp() { - // We have to use from_str until base-2 exponents - // are supported in floating-point literals - let f1: f32 = f32::from_str_radix("1p-123", 16).unwrap(); - let f2: f32 = f32::from_str_radix("1p-111", 16).unwrap(); - let f3: f32 = f32::from_str_radix("1.Cp-123", 16).unwrap(); + let f1 = 2.0f32.powi(-123); + let f2 = 2.0f32.powi(-111); + let f3 = 1.75 * 2.0f32.powi(-123); let (x1, exp1) = f1.frexp(); let (x2, exp2) = f2.frexp(); let (x3, exp3) = f3.frexp(); diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 6b9c753443b3c..d444b2594453c 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -18,7 +18,7 @@ use core::num; use intrinsics; use libc::c_int; -use num::{FpCategory, ParseFloatError}; +use num::FpCategory; #[stable(feature = "rust1", since = "1.0.0")] pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON}; @@ -83,16 +83,6 @@ mod cmath { #[cfg(not(test))] #[lang = "f64"] impl f64 { - /// Parses a float as with a given radix - #[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")] - #[allow(deprecated)] - pub fn from_str_radix(s: &str, radix: u32) -> Result { - num::Float::from_str_radix(s, radix) - } - /// Returns `true` if this value is `NaN` and false otherwise. /// /// ``` @@ -1569,11 +1559,9 @@ mod tests { #[test] fn test_ldexp() { - // We have to use from_str until base-2 exponents - // are supported in floating-point literals - let f1: f64 = f64::from_str_radix("1p-123", 16).unwrap(); - let f2: f64 = f64::from_str_radix("1p-111", 16).unwrap(); - let f3: f64 = f64::from_str_radix("1.Cp-12", 16).unwrap(); + let f1 = 2.0f64.powi(-123); + let f2 = 2.0f64.powi(-111); + let f3 = 1.75 * 2.0f64.powi(-12); assert_eq!(f64::ldexp(1f64, -123), f1); assert_eq!(f64::ldexp(1f64, -111), f2); assert_eq!(f64::ldexp(1.75f64, -12), f3); @@ -1591,11 +1579,9 @@ mod tests { #[test] fn test_frexp() { - // We have to use from_str until base-2 exponents - // are supported in floating-point literals - let f1: f64 = f64::from_str_radix("1p-123", 16).unwrap(); - let f2: f64 = f64::from_str_radix("1p-111", 16).unwrap(); - let f3: f64 = f64::from_str_radix("1.Cp-123", 16).unwrap(); + let f1 = 2.0f64.powi(-123); + let f2 = 2.0f64.powi(-111); + let f3 = 1.75 * 2.0f64.powi(-123); let (x1, exp1) = f1.frexp(); let (x2, exp2) = f2.frexp(); let (x3, exp3) = f3.frexp(); diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 7ef504fba81e0..5e0368f35cc74 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -16,7 +16,10 @@ use os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort}; use os::raw::{c_char, c_short, c_ulonglong}; use libc::{wchar_t, size_t, c_void}; use ptr; -use simd; + +#[cfg_attr(not(stage0), repr(simd))] +#[repr(C)] +struct u64x2(u64, u64); pub use self::GET_FILEEX_INFO_LEVELS::*; pub use self::FILE_INFO_BY_HANDLE_CLASS::*; @@ -783,7 +786,7 @@ pub struct FLOATING_SAVE_AREA { #[cfg(target_arch = "x86_64")] #[repr(C)] pub struct CONTEXT { - _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte + _align_hack: [u64x2; 0], // FIXME align on 16-byte pub P1Home: DWORDLONG, pub P2Home: DWORDLONG, pub P3Home: DWORDLONG, @@ -843,7 +846,7 @@ pub struct CONTEXT { #[cfg(target_arch = "x86_64")] #[repr(C)] pub struct M128A { - _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte + _align_hack: [u64x2; 0], // FIXME align on 16-byte pub Low: c_ulonglong, pub High: c_longlong } @@ -851,7 +854,7 @@ pub struct M128A { #[cfg(target_arch = "x86_64")] #[repr(C)] pub struct FLOATING_SAVE_AREA { - _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte + _align_hack: [u64x2; 0], // FIXME align on 16-byte _Dummy: [u8; 512] // FIXME: Fill this out } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs deleted file mode 100644 index 21ac23253c86a..0000000000000 --- a/src/test/bench/shootout-mandelbrot.rs +++ /dev/null @@ -1,209 +0,0 @@ -// The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ -// -// contributed by the Rust Project Developers - -// Copyright (c) 2012-2014 The Rust Project Developers -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// - Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// -// - Neither the name of "The Computer Language Benchmarks Game" nor -// the name of "The Computer Language Shootout Benchmarks" nor the -// names of its contributors may be used to endorse or promote -// products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -#![feature(core_simd, core)] - -// ignore-pretty very bad with line comments - -use std::env; -use std::io::prelude::*; -use std::io; -use std::simd::f64x2; -use std::sync::Arc; -use std::thread; - -const ITER: usize = 50; -const LIMIT: f64 = 2.0; -const WORKERS: usize = 16; - -fn mandelbrot(w: usize, mut out: W) -> io::Result<()> { - assert_eq!(WORKERS % 2, 0); - - // Ensure w and h are multiples of 8. - let w = (w + 7) / 8 * 8; - let h = w; - - let chunk_size = h / WORKERS; - - // Account for remainders in workload division, e.g. 1000 / 16 = 62.5 - let last_chunk_size = if h % WORKERS != 0 { - chunk_size + h % WORKERS - } else { - chunk_size - }; - - // precalc values - let inverse_w_doubled = 2.0 / w as f64; - let inverse_h_doubled = 2.0 / h as f64; - let v_inverses = f64x2(inverse_w_doubled, inverse_h_doubled); - let v_consts = f64x2(1.5, 1.0); - - // A lot of this code assumes this (so do other lang benchmarks) - assert_eq!(w, h); - let mut precalc_r = Vec::with_capacity(w); - let mut precalc_i = Vec::with_capacity(h); - - let precalc_futures = (0..WORKERS).map(|i| { - thread::spawn(move|| { - let mut rs = Vec::with_capacity(w / WORKERS); - let mut is = Vec::with_capacity(w / WORKERS); - - let start = i * chunk_size; - let end = if i == (WORKERS - 1) { - start + last_chunk_size - } else { - (i + 1) * chunk_size - }; - - // This assumes w == h - for x in start..end { - let xf = x as f64; - let xy = f64x2(xf, xf); - - let f64x2(r, i) = xy * v_inverses - v_consts; - rs.push(r); - is.push(i); - } - - (rs, is) - }) - }).collect::>(); - - for res in precalc_futures { - let (rs, is) = res.join().unwrap(); - precalc_r.extend(rs); - precalc_i.extend(is); - } - - assert_eq!(precalc_r.len(), w); - assert_eq!(precalc_i.len(), h); - - let arc_init_r = Arc::new(precalc_r); - let arc_init_i = Arc::new(precalc_i); - - let data = (0..WORKERS).map(|i| { - let vec_init_r = arc_init_r.clone(); - let vec_init_i = arc_init_i.clone(); - - thread::spawn(move|| { - let mut res: Vec = Vec::with_capacity((chunk_size * w) / 8); - let init_r_slice = vec_init_r; - - let start = i * chunk_size; - let end = if i == (WORKERS - 1) { - start + last_chunk_size - } else { - (i + 1) * chunk_size - }; - - for &init_i in &vec_init_i[start..end] { - write_line(init_i, &init_r_slice, &mut res); - } - - res - }) - }).collect::>(); - - try!(writeln!(&mut out, "P4\n{} {}", w, h)); - for res in data { - try!(out.write_all(&res.join().unwrap())); - } - out.flush() -} - -fn write_line(init_i: f64, vec_init_r: &[f64], res: &mut Vec) { - let v_init_i : f64x2 = f64x2(init_i, init_i); - let v_2 : f64x2 = f64x2(2.0, 2.0); - const LIMIT_SQUARED: f64 = LIMIT * LIMIT; - - for chunk_init_r in vec_init_r.chunks(8) { - let mut cur_byte = 0xff; - let mut i = 0; - - while i < 8 { - let v_init_r = f64x2(chunk_init_r[i], chunk_init_r[i + 1]); - let mut cur_r = v_init_r; - let mut cur_i = v_init_i; - let mut r_sq = v_init_r * v_init_r; - let mut i_sq = v_init_i * v_init_i; - - let mut b = 0; - for _ in 0..ITER { - let r = cur_r; - let i = cur_i; - - cur_i = v_2 * r * i + v_init_i; - cur_r = r_sq - i_sq + v_init_r; - - let f64x2(bit1, bit2) = r_sq + i_sq; - - if bit1 > LIMIT_SQUARED { - b |= 2; - if b == 3 { break; } - } - - if bit2 > LIMIT_SQUARED { - b |= 1; - if b == 3 { break; } - } - - r_sq = cur_r * cur_r; - i_sq = cur_i * cur_i; - } - - cur_byte = (cur_byte << 2) + b; - i += 2; - } - - res.push(cur_byte^!0); - } -} - -fn main() { - let mut args = env::args(); - let res = if args.len() < 2 { - println!("Test mode: do not dump the image because it's not utf8, \ - which interferes with the test runner."); - mandelbrot(1000, io::sink()) - } else { - mandelbrot(args.nth(1).unwrap().parse().unwrap(), io::stdout()) - }; - res.unwrap(); -} diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs deleted file mode 100644 index a6c77eaf7c630..0000000000000 --- a/src/test/bench/shootout-spectralnorm.rs +++ /dev/null @@ -1,123 +0,0 @@ -// The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ -// -// contributed by the Rust Project Developers - -// Copyright (c) 2012-2014 The Rust Project Developers -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// - Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// -// - Neither the name of "The Computer Language Benchmarks Game" nor -// the name of "The Computer Language Shootout Benchmarks" nor the -// names of its contributors may be used to endorse or promote -// products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -// OF THE POSSIBILITY OF SUCH DAMAGE. - -// no-pretty-expanded FIXME #15189 - -#![allow(non_snake_case)] -#![feature(unboxed_closures, iter_arith, core_simd, scoped)] - -use std::thread; -use std::env; -use std::simd::f64x2; - -fn main() { - let mut args = env::args(); - let answer = spectralnorm(if env::var_os("RUST_BENCH").is_some() { - 5500 - } else if args.len() < 2 { - 2000 - } else { - args.nth(1).unwrap().parse().unwrap() - }); - println!("{:.9}", answer); -} - -fn spectralnorm(n: usize) -> f64 { - assert!(n % 2 == 0, "only even lengths are accepted"); - let mut u = vec![1.0; n]; - let mut v = u.clone(); - let mut tmp = v.clone(); - for _ in 0..10 { - mult_AtAv(&u, &mut v, &mut tmp); - mult_AtAv(&v, &mut u, &mut tmp); - } - (dot(&u, &v) / dot(&v, &v)).sqrt() -} - -fn mult_AtAv(v: &[f64], out: &mut [f64], tmp: &mut [f64]) { - mult_Av(v, tmp); - mult_Atv(tmp, out); -} - -fn mult_Av(v: &[f64], out: &mut [f64]) { - parallel(out, |start, out| mult(v, out, start, |i, j| A(i, j))); -} - -fn mult_Atv(v: &[f64], out: &mut [f64]) { - parallel(out, |start, out| mult(v, out, start, |i, j| A(j, i))); -} - -fn mult(v: &[f64], out: &mut [f64], start: usize, a: F) - where F: Fn(usize, usize) -> f64 { - for (i, slot) in out.iter_mut().enumerate().map(|(i, s)| (i + start, s)) { - let mut sum = f64x2(0.0, 0.0); - for (j, chunk) in v.chunks(2).enumerate().map(|(j, s)| (2 * j, s)) { - let top = f64x2(chunk[0], chunk[1]); - let bot = f64x2(a(i, j), a(i, j + 1)); - sum = sum + top / bot; - } - let f64x2(a, b) = sum; - *slot = a + b; - } -} - -fn A(i: usize, j: usize) -> f64 { - ((i + j) * (i + j + 1) / 2 + i + 1) as f64 -} - -fn dot(v: &[f64], u: &[f64]) -> f64 { - v.iter().zip(u).map(|(a, b)| *a * *b).sum() -} - - -// Executes a closure in parallel over the given mutable slice. The closure `f` -// is run in parallel and yielded the starting index within `v` as well as a -// sub-slice of `v`. -fn parallel<'a,T, F>(v: &mut [T], ref f: F) - where T: Send + Sync + 'a, - F: Fn(usize, &mut [T]) + Sync + 'a { - // FIXME: pick a more appropriate parallel factor - // FIXME: replace with thread::scoped when it exists again - let parallelism = 4; - let size = v.len() / parallelism + 1; - v.chunks_mut(size).enumerate().map(|(i, chunk)| { - f(i * size, chunk) - }).collect::>(); -} diff --git a/src/test/compile-fail/feature-gate-simd-ffi.rs b/src/test/compile-fail/feature-gate-simd-ffi.rs index f7bd2fcbceb4f..31c055f229c3e 100644 --- a/src/test/compile-fail/feature-gate-simd-ffi.rs +++ b/src/test/compile-fail/feature-gate-simd-ffi.rs @@ -8,17 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(repr_simd, core_simd)] -#![allow(dead_code, deprecated)] +#![feature(repr_simd)] +#![allow(dead_code)] -use std::simd::f32x4; - -#[repr(simd)] #[derive(Copy, Clone)] #[repr(C)] struct LocalSimd(u8, u8); +#[repr(simd)] +#[derive(Copy, Clone)] +#[repr(C)] +struct LocalSimd(u8, u8); extern { - fn foo() -> f32x4; //~ ERROR use of SIMD type - fn bar(x: f32x4); //~ ERROR use of SIMD type - fn baz() -> LocalSimd; //~ ERROR use of SIMD type fn qux(x: LocalSimd); //~ ERROR use of SIMD type } diff --git a/src/test/debuginfo/simd.rs b/src/test/debuginfo/simd.rs index 24eb407612c3e..620e1a73b4d64 100644 --- a/src/test/debuginfo/simd.rs +++ b/src/test/debuginfo/simd.rs @@ -43,9 +43,28 @@ #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] -#![feature(core_simd)] +#![feature(repr_simd)] -use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2}; +#[repr(simd)] +struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8); +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +struct i64x2(i64, i64); +#[repr(simd)] +struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8); +#[repr(simd)] +struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16); +#[repr(simd)] +struct u32x4(u32, u32, u32, u32); +#[repr(simd)] +struct u64x2(u64, u64); +#[repr(simd)] +struct f32x4(f32, f32, f32, f32); +#[repr(simd)] +struct f64x2(f64, f64); fn main() { diff --git a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs index 405a3549cf18c..562cfbe7a148a 100644 --- a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs +++ b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs @@ -12,8 +12,7 @@ // type is `&mut [u8]`, passes in a pointer to the lvalue and not a // temporary. Issue #19147. - -#![feature(slice_bytes)] +#![feature(clone_from_slice)] use std::slice; @@ -23,7 +22,7 @@ trait MyWriter { impl<'a> MyWriter for &'a mut [u8] { fn my_write(&mut self, buf: &[u8]) -> Result<(), ()> { - slice::bytes::copy_memory(buf, *self); + self.clone_from_slice(buf); let write_len = buf.len(); unsafe { diff --git a/src/test/run-pass/simd-issue-10604.rs b/src/test/run-pass/simd-issue-10604.rs deleted file mode 100644 index c3eef0f9c3217..0000000000000 --- a/src/test/run-pass/simd-issue-10604.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013-2014 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. - -// pretty-expanded FIXME #23616 - -#![feature(core_simd)] - -pub fn main() { - let _o = None::; -} diff --git a/src/test/run-pass/sync-send-iterators-in-libcore.rs b/src/test/run-pass/sync-send-iterators-in-libcore.rs index c4d070f8bfed2..931789948159d 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcore.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcore.rs @@ -14,11 +14,10 @@ #![feature(iter_empty)] #![feature(iter_once)] #![feature(iter_unfold)] -#![feature(range_inclusive)] #![feature(step_by)] #![feature(str_escape)] -use std::iter::{empty, once, range_inclusive, repeat}; +use std::iter::{empty, once, repeat}; fn is_sync(_: T) where T: Sync {} fn is_send(_: T) where T: Send {} @@ -98,7 +97,6 @@ fn main() { inspect(|_| ())); is_sync_send!((1..).step_by(2)); - is_sync_send!(range_inclusive(1, 1)); is_sync_send!((1..2).step_by(2)); is_sync_send!((1..2)); is_sync_send!((1..)); diff --git a/src/test/run-pass/while-let.rs b/src/test/run-pass/while-let.rs index efccff75a49dd..9ffba2c7999f1 100644 --- a/src/test/run-pass/while-let.rs +++ b/src/test/run-pass/while-let.rs @@ -14,7 +14,7 @@ use std::collections::BinaryHeap; fn make_pq() -> BinaryHeap { - BinaryHeap::from_vec(vec![1,2,3]) + BinaryHeap::from(vec![1,2,3]) } pub fn main() {