Auto merge of #27684 - alexcrichton:remove-deprecated, r=aturon

This commit removes all unstable and deprecated functions in the standard
library. A release was recently cut (1.3) which makes this a good time for some
spring cleaning of the deprecated functions.
This commit is contained in:
bors
2015-08-13 23:32:30 +00:00
125 changed files with 1681 additions and 15526 deletions

View File

@@ -211,31 +211,3 @@ fn test_len_utf16() {
assert!('\u{a66e}'.len_utf16() == 1);
assert!('\u{1f4a9}'.len_utf16() == 2);
}
#[allow(deprecated)]
#[test]
fn test_width() {
assert_eq!('\x00'.width(false),Some(0));
assert_eq!('\x00'.width(true),Some(0));
assert_eq!('\x0A'.width(false),None);
assert_eq!('\x0A'.width(true),None);
assert_eq!('w'.width(false),Some(1));
assert_eq!('w'.width(true),Some(1));
assert_eq!(''.width(false),Some(2));
assert_eq!(''.width(true),Some(2));
assert_eq!('\u{AD}'.width(false),Some(1));
assert_eq!('\u{AD}'.width(true),Some(1));
assert_eq!('\u{1160}'.width(false),Some(0));
assert_eq!('\u{1160}'.width(true),Some(0));
assert_eq!('\u{a1}'.width(false),Some(1));
assert_eq!('\u{a1}'.width(true),Some(2));
assert_eq!('\u{300}'.width(false),Some(0));
assert_eq!('\u{300}'.width(true),Some(0));
}

View File

@@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::cmp::{partial_min, partial_max};
use core::cmp::Ordering::{Less, Greater, Equal};
#[test]
@@ -42,72 +41,6 @@ fn test_ordering_order() {
assert_eq!(Greater.cmp(&Less), Greater);
}
#[test]
fn test_partial_min() {
use core::f64::NAN;
let data_integer = [
// a, b, result
(0, 0, Some(0)),
(1, 0, Some(0)),
(0, 1, Some(0)),
(-1, 0, Some(-1)),
(0, -1, Some(-1))
];
let data_float = [
// a, b, result
(0.0f64, 0.0f64, Some(0.0f64)),
(1.0f64, 0.0f64, Some(0.0f64)),
(0.0f64, 1.0f64, Some(0.0f64)),
(-1.0f64, 0.0f64, Some(-1.0f64)),
(0.0f64, -1.0f64, Some(-1.0f64)),
(NAN, NAN, None),
(NAN, 1.0f64, None),
(1.0f64, NAN, None)
];
for &(a, b, result) in &data_integer {
assert!(partial_min(a, b) == result);
}
for &(a, b, result) in &data_float {
assert!(partial_min(a, b) == result);
}
}
#[test]
fn test_partial_max() {
use core::f64::NAN;
let data_integer = [
// a, b, result
(0, 0, Some(0)),
(1, 0, Some(1)),
(0, 1, Some(1)),
(-1, 0, Some(0)),
(0, -1, Some(0))
];
let data_float = [
// a, b, result
(0.0f64, 0.0f64, Some(0.0f64)),
(1.0f64, 0.0f64, Some(1.0f64)),
(0.0f64, 1.0f64, Some(1.0f64)),
(-1.0f64, 0.0f64, Some(0.0f64)),
(0.0f64, -1.0f64, Some(0.0f64)),
(NAN, NAN, None),
(NAN, 1.0f64, None),
(1.0f64, NAN, None)
];
for &(a, b, result) in &data_integer {
assert!(partial_max(a, b) == result);
}
for &(a, b, result) in &data_float {
assert!(partial_max(a, b) == result);
}
}
#[test]
fn test_user_defined_eq() {
// Our type.

View File

@@ -36,7 +36,9 @@ impl Hasher for MyHasher {
#[test]
fn test_writer_hasher() {
fn hash<T: Hash>(t: &T) -> u64 {
::std::hash::hash::<_, MyHasher>(t)
let mut s = MyHasher { hash: 0 };
t.hash(&mut s);
s.finish()
}
assert_eq!(hash(&()), 0);
@@ -102,7 +104,9 @@ impl Hash for Custom {
#[test]
fn test_custom_state() {
fn hash<T: Hash>(t: &T) -> u64 {
::std::hash::hash::<_, CustomHasher>(t)
let mut c = CustomHasher { output: 0 };
t.hash(&mut c);
c.finish()
}
assert_eq!(hash(&Custom { hash: 5 }), 5);

View File

@@ -10,10 +10,8 @@
use core::iter::*;
use core::iter::order::*;
use core::iter::MinMaxResult::*;
use core::{i8, i16, isize};
use core::usize;
use core::cmp;
use test::Bencher;
@@ -451,27 +449,6 @@ fn test_inspect() {
assert_eq!(&xs[..], &ys[..]);
}
#[test]
fn test_unfoldr() {
fn count(st: &mut usize) -> Option<usize> {
if *st < 10 {
let ret = Some(*st);
*st += 1;
ret
} else {
None
}
}
let it = Unfold::new(0, count);
let mut i = 0;
for counted in it {
assert_eq!(counted, i);
i += 1;
}
assert_eq!(i, 10);
}
#[test]
fn test_cycle() {
let cycle_len = 3;
@@ -781,28 +758,6 @@ fn test_rposition_panic() {
}
#[cfg(test)]
fn check_randacc_iter<A, T>(a: T, len: usize) where
A: PartialEq,
T: Clone + RandomAccessIterator + Iterator<Item=A>,
{
let mut b = a.clone();
assert_eq!(len, b.indexable());
let mut n = 0;
for (i, elt) in a.enumerate() {
assert!(Some(elt) == b.idx(i));
n += 1;
}
assert_eq!(n, len);
assert!(None == b.idx(n));
// call recursively to check after picking off an element
if len > 0 {
b.next();
check_randacc_iter(b, len-1);
}
}
#[test]
fn test_double_ended_flat_map() {
let u = [0,1];
@@ -820,101 +775,6 @@ fn test_double_ended_flat_map() {
assert_eq!(it.next_back(), None);
}
#[test]
fn test_random_access_chain() {
let xs = [1, 2, 3, 4, 5];
let ys = [7, 9, 11];
let mut it = xs.iter().chain(&ys);
assert_eq!(it.idx(0).unwrap(), &1);
assert_eq!(it.idx(5).unwrap(), &7);
assert_eq!(it.idx(7).unwrap(), &11);
assert!(it.idx(8).is_none());
it.next();
it.next();
it.next_back();
assert_eq!(it.idx(0).unwrap(), &3);
assert_eq!(it.idx(4).unwrap(), &9);
assert!(it.idx(6).is_none());
check_randacc_iter(it, xs.len() + ys.len() - 3);
}
#[test]
fn test_random_access_enumerate() {
let xs = [1, 2, 3, 4, 5];
check_randacc_iter(xs.iter().enumerate(), xs.len());
}
#[test]
fn test_random_access_rev() {
let xs = [1, 2, 3, 4, 5];
check_randacc_iter(xs.iter().rev(), xs.len());
let mut it = xs.iter().rev();
it.next();
it.next_back();
it.next();
check_randacc_iter(it, xs.len() - 3);
}
#[test]
fn test_random_access_zip() {
let xs = [1, 2, 3, 4, 5];
let ys = [7, 9, 11];
check_randacc_iter(xs.iter().zip(&ys), cmp::min(xs.len(), ys.len()));
}
#[test]
fn test_random_access_take() {
let xs = [1, 2, 3, 4, 5];
let empty: &[isize] = &[];
check_randacc_iter(xs.iter().take(3), 3);
check_randacc_iter(xs.iter().take(20), xs.len());
check_randacc_iter(xs.iter().take(0), 0);
check_randacc_iter(empty.iter().take(2), 0);
}
#[test]
fn test_random_access_skip() {
let xs = [1, 2, 3, 4, 5];
let empty: &[isize] = &[];
check_randacc_iter(xs.iter().skip(2), xs.len() - 2);
check_randacc_iter(empty.iter().skip(2), 0);
}
#[test]
fn test_random_access_inspect() {
let xs = [1, 2, 3, 4, 5];
// test .map and .inspect that don't implement Clone
let mut it = xs.iter().inspect(|_| {});
assert_eq!(xs.len(), it.indexable());
for (i, elt) in xs.iter().enumerate() {
assert_eq!(Some(elt), it.idx(i));
}
}
#[test]
fn test_random_access_map() {
let xs = [1, 2, 3, 4, 5];
let mut it = xs.iter().cloned();
assert_eq!(xs.len(), it.indexable());
for (i, elt) in xs.iter().enumerate() {
assert_eq!(Some(*elt), it.idx(i));
}
}
#[test]
fn test_random_access_cycle() {
let xs = [1, 2, 3, 4, 5];
let empty: &[isize] = &[];
check_randacc_iter(xs.iter().cycle().take(27), 27);
check_randacc_iter(empty.iter().cycle(), 0);
}
#[test]
fn test_double_ended_range() {
assert_eq!((11..14).rev().collect::<Vec<_>>(), [13, 12, 11]);
@@ -984,13 +844,6 @@ fn test_range_step() {
assert_eq!((isize::MIN..isize::MAX).step_by(1).size_hint(), (usize::MAX, Some(usize::MAX)));
}
#[test]
fn test_reverse() {
let mut ys = [1, 2, 3, 4, 5];
ys.iter_mut().reverse_in_place();
assert!(ys == [5, 4, 3, 2, 1]);
}
#[test]
fn test_peekable_is_empty() {
let a = [1];
@@ -1000,45 +853,6 @@ fn test_peekable_is_empty() {
assert!( it.is_empty() );
}
#[test]
fn test_min_max() {
let v: [isize; 0] = [];
assert_eq!(v.iter().min_max(), NoElements);
let v = [1];
assert!(v.iter().min_max() == OneElement(&1));
let v = [1, 2, 3, 4, 5];
assert!(v.iter().min_max() == MinMax(&1, &5));
let v = [1, 2, 3, 4, 5, 6];
assert!(v.iter().min_max() == MinMax(&1, &6));
let v = [1, 1, 1, 1];
assert!(v.iter().min_max() == MinMax(&1, &1));
}
#[test]
fn test_min_max_result() {
let r: MinMaxResult<isize> = NoElements;
assert_eq!(r.into_option(), None);
let r = OneElement(1);
assert_eq!(r.into_option(), Some((1,1)));
let r = MinMax(1,2);
assert_eq!(r.into_option(), Some((1,2)));
}
#[test]
fn test_iterate() {
let mut it = iterate(1, |x| x * 2);
assert_eq!(it.next(), Some(1));
assert_eq!(it.next(), Some(2));
assert_eq!(it.next(), Some(4));
assert_eq!(it.next(), Some(8));
}
#[test]
fn test_repeat() {
let mut it = repeat(42);

View File

@@ -12,7 +12,6 @@
#![feature(borrow_state)]
#![feature(box_syntax)]
#![feature(cell_extras)]
#![feature(cmp_partial)]
#![feature(const_fn)]
#![feature(core)]
#![feature(core_float)]
@@ -21,18 +20,10 @@
#![feature(flt2dec)]
#![feature(dec2flt)]
#![feature(fmt_radix)]
#![feature(hash_default)]
#![feature(hasher_write)]
#![feature(iter_arith)]
#![feature(iter_arith)]
#![feature(iter_cmp)]
#![feature(iter_empty)]
#![feature(iter_idx)]
#![feature(iter_iterate)]
#![feature(iter_min_max)]
#![feature(iter_once)]
#![feature(iter_order)]
#![feature(iter_unfold)]
#![feature(libc)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]