Rollup merge of #22567 - Gankro:unstable, r=alexcrichton

* Adds features and allows
* Removes unused muts, unused imports, dead code
* Migrates some deprecated code to new io/env
* Changes std::num::uint/int to be re-exports of std::num::usize/isize

libcollections, liballoc, and libcoretest no longer warn during testing.

libstd warns much less, though there's some dangly bits that weren't obvious fixes. In particular, how to only supress deprecated warnings in specific submodules of std.
This commit is contained in:
Manish Goregaokar 2015-02-22 01:53:16 +05:30
commit 59ab2daad3
20 changed files with 157 additions and 194 deletions

View File

@ -73,6 +73,7 @@
#![feature(unboxed_closures)]
#![feature(unsafe_no_drop_flag)]
#![feature(core)]
#![cfg_attr(test, feature(test, alloc, rustc_private))]
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
feature(libc))]

View File

@ -170,42 +170,42 @@ mod u32 {
use test::Bencher;
use core::fmt::radix;
use std::rand::{weak_rng, Rng};
use std::old_io::util::NullWriter;
use std::io::{Write, sink};
#[bench]
fn format_bin(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:b}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:b}", rng.gen::<u32>()) })
}
#[bench]
fn format_oct(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:o}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:o}", rng.gen::<u32>()) })
}
#[bench]
fn format_dec(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{}", rng.gen::<u32>()) })
}
#[bench]
fn format_hex(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:x}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:x}", rng.gen::<u32>()) })
}
#[bench]
fn format_show(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:?}", rng.gen::<u32>()) })
b.iter(|| { write!(&mut sink(), "{:?}", rng.gen::<u32>()) })
}
#[bench]
fn format_base_36(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", radix(rng.gen::<u32>(), 36)) })
b.iter(|| { write!(&mut sink(), "{}", radix(rng.gen::<u32>(), 36)) })
}
}
@ -213,41 +213,41 @@ mod i32 {
use test::Bencher;
use core::fmt::radix;
use std::rand::{weak_rng, Rng};
use std::old_io::util::NullWriter;
use std::io::{Write, sink};
#[bench]
fn format_bin(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:b}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:b}", rng.gen::<i32>()) })
}
#[bench]
fn format_oct(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:o}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:o}", rng.gen::<i32>()) })
}
#[bench]
fn format_dec(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{}", rng.gen::<i32>()) })
}
#[bench]
fn format_hex(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:x}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:x}", rng.gen::<i32>()) })
}
#[bench]
fn format_show(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{:?}", rng.gen::<i32>()) })
b.iter(|| { write!(&mut sink(), "{:?}", rng.gen::<i32>()) })
}
#[bench]
fn format_base_36(b: &mut Bencher) {
let mut rng = weak_rng();
b.iter(|| { write!(&mut NullWriter, "{}", radix(rng.gen::<i32>(), 36)) })
b.iter(|| { write!(&mut sink(), "{}", radix(rng.gen::<i32>(), 36)) })
}
}

View File

@ -12,6 +12,15 @@
#![feature(int_uint)]
#![feature(unboxed_closures)]
#![feature(unsafe_destructor)]
#![feature(core)]
#![feature(test)]
#![feature(rand)]
#![feature(unicode)]
#![feature(std_misc)]
#![feature(libc)]
#![feature(hash)]
#![feature(io)]
#![feature(collections)]
#![allow(deprecated)] // rand
extern crate core;

View File

@ -32,6 +32,8 @@
#![deprecated(reason = "use the crates.io `rand` library instead",
since = "1.0.0-alpha")]
#![cfg_attr(test, feature(test, rand))]
#![allow(deprecated)]
#[macro_use]

View File

@ -32,6 +32,8 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![cfg_attr(test, feature(test))]
extern crate serialize;
#[macro_use] extern crate log;

View File

@ -88,7 +88,6 @@ impl DefaultResizePolicy {
#[test]
fn test_resize_policy() {
use prelude::v1::*;
let rp = DefaultResizePolicy;
for n in 0..1000 {
assert!(rp.min_capacity(rp.usable_capacity(n)) <= n);
@ -2256,6 +2255,7 @@ mod test_map {
#[test]
fn test_entry_take_doesnt_corrupt() {
#![allow(deprecated)] //rand
// Test for #19292
fn check(m: &HashMap<isize, ()>) {
for k in m.keys() {

View File

@ -744,6 +744,8 @@ pub fn set_permissions<P: AsPath + ?Sized>(path: &P, perm: Permissions)
#[cfg(test)]
mod tests {
#![allow(deprecated)] //rand
use prelude::v1::*;
use io::prelude::*;
@ -1035,7 +1037,7 @@ mod tests {
let msg = msg_str.as_bytes();
check!(w.write(msg));
}
let mut files = check!(fs::read_dir(dir));
let files = check!(fs::read_dir(dir));
let mut mem = [0u8; 4];
for f in files {
let f = f.unwrap().path();
@ -1065,7 +1067,7 @@ mod tests {
check!(fs::create_dir_all(dir2));
check!(File::create(&dir2.join("14")));
let mut files = check!(fs::walk_dir(dir));
let files = check!(fs::walk_dir(dir));
let mut cur = [0u8; 2];
for f in files {
let f = f.unwrap().path();

View File

@ -497,7 +497,6 @@ mod tests {
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8]);
writer.write(&[9, 10, 11]).unwrap();
let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
assert_eq!(*writer.get_ref(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
writer.flush().unwrap();
@ -593,7 +592,7 @@ mod tests {
#[test]
fn test_lines() {
let in_buf = b"a\nb\nc";
let mut reader = BufReader::with_capacity(2, in_buf);
let reader = BufReader::with_capacity(2, in_buf);
let mut it = reader.lines();
assert_eq!(it.next(), Some(Ok("a".to_string())));
assert_eq!(it.next(), Some(Ok("b".to_string())));
@ -618,14 +617,14 @@ mod tests {
#[test]
fn read_char_buffered() {
let buf = [195u8, 159u8];
let mut reader = BufReader::with_capacity(1, &buf[..]);
let reader = BufReader::with_capacity(1, &buf[..]);
assert_eq!(reader.chars().next(), Some(Ok('ß')));
}
#[test]
fn test_chars() {
let buf = [195u8, 159u8, b'a'];
let mut reader = BufReader::with_capacity(1, &buf[..]);
let reader = BufReader::with_capacity(1, &buf[..]);
let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß')));
assert_eq!(it.next(), Some(Ok('a')));

View File

@ -869,12 +869,12 @@ mod tests {
#[test]
fn split() {
let mut buf = Cursor::new(b"12");
let buf = Cursor::new(b"12");
let mut s = buf.split(b'3');
assert_eq!(s.next(), Some(Ok(vec![b'1', b'2'])));
assert_eq!(s.next(), None);
let mut buf = Cursor::new(b"1233");
let buf = Cursor::new(b"1233");
let mut s = buf.split(b'3');
assert_eq!(s.next(), Some(Ok(vec![b'1', b'2'])));
assert_eq!(s.next(), Some(Ok(vec![])));
@ -902,12 +902,12 @@ mod tests {
#[test]
fn lines() {
let mut buf = Cursor::new(b"12");
let buf = Cursor::new(b"12");
let mut s = buf.lines();
assert_eq!(s.next(), Some(Ok("12".to_string())));
assert_eq!(s.next(), None);
let mut buf = Cursor::new(b"12\n\n");
let buf = Cursor::new(b"12\n\n");
let mut s = buf.lines();
assert_eq!(s.next(), Some(Ok("12".to_string())));
assert_eq!(s.next(), Some(Ok(String::new())));

View File

@ -109,7 +109,6 @@
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(hash)]
#![feature(int_uint)]
#![feature(lang_items)]
#![feature(libc)]
@ -123,7 +122,7 @@
#![feature(unsafe_destructor)]
#![feature(unsafe_no_drop_flag)]
#![feature(macro_reexport)]
#![cfg_attr(test, feature(test))]
#![cfg_attr(test, feature(test, rustc_private, env))]
// Don't link to std. We are std.
#![feature(no_std)]
@ -219,15 +218,15 @@ mod int_macros;
#[macro_use]
mod uint_macros;
#[path = "num/int.rs"] pub mod int;
#[path = "num/isize.rs"] pub mod isize;
pub use isize as int;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;
#[path = "num/uint.rs"] pub mod uint;
#[path = "num/usize.rs"] pub mod usize;
pub use usize as uint;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;

View File

@ -456,12 +456,6 @@ mod tests {
}
}
pub fn socket_name(addr: SocketAddr) {
}
pub fn peer_name(addr: SocketAddr) {
}
#[test]
fn socket_and_peer_name_ip4() {
each_ip(&mut |addr| {

View File

@ -33,7 +33,7 @@ fn base_port() -> u16 {
let cwd = env::current_dir().unwrap();
let dirs = ["32-opt", "32-nopt", "64-opt", "64-nopt", "64-opt-vg",
"all-opt", "snap3", "dist"];
dirs.iter().enumerate().find(|&(i, dir)| {
dirs.iter().enumerate().find(|&(_, dir)| {
cwd.as_str().unwrap().contains(dir)
}).map(|p| p.0).unwrap_or(0) as u16 * 1000 + 19600
}

View File

@ -1,22 +0,0 @@
// Copyright 2012-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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Deprecated: replaced by `isize`.
//!
//! The rollout of the new type will gradually take place over the
//! alpha cycle along with the development of clearer conventions
//! around integer types.
#![unstable(feature = "std_misc")]
#![deprecated(since = "1.0.0", reason = "replaced by isize")]
pub use core::int::{BITS, BYTES, MIN, MAX};
int_module! { int }

View File

@ -11,7 +11,7 @@
//! Numeric traits and functions for generic mathematics
//!
//! These are implemented for the primitive numeric types in `std::{u8, u16,
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64}`.
//! u32, u64, usize, i8, i16, i32, i64, isize, f32, f64}`.
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]
@ -146,12 +146,12 @@ pub trait Float
#[deprecated(since = "1.0.0",
reason = "use `std::f32::MANTISSA_DIGITS` or \
`std::f64::MANTISSA_DIGITS` as appropriate")]
fn mantissa_digits(unused_self: Option<Self>) -> uint;
fn mantissa_digits(unused_self: Option<Self>) -> usize;
/// Deprecated: use `std::f32::DIGITS` or `std::f64::DIGITS` instead.
#[unstable(feature = "std_misc")]
#[deprecated(since = "1.0.0",
reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")]
fn digits(unused_self: Option<Self>) -> uint;
fn digits(unused_self: Option<Self>) -> usize;
/// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead.
#[unstable(feature = "std_misc")]
#[deprecated(since = "1.0.0",
@ -161,22 +161,22 @@ pub trait Float
#[unstable(feature = "std_misc")]
#[deprecated(since = "1.0.0",
reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")]
fn min_exp(unused_self: Option<Self>) -> int;
fn min_exp(unused_self: Option<Self>) -> isize;
/// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead.
#[unstable(feature = "std_misc")]
#[deprecated(since = "1.0.0",
reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")]
fn max_exp(unused_self: Option<Self>) -> int;
fn max_exp(unused_self: Option<Self>) -> isize;
/// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead.
#[unstable(feature = "std_misc")]
#[deprecated(since = "1.0.0",
reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")]
fn min_10_exp(unused_self: Option<Self>) -> int;
fn min_10_exp(unused_self: Option<Self>) -> isize;
/// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead.
#[unstable(feature = "std_misc")]
#[deprecated(since = "1.0.0",
reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")]
fn max_10_exp(unused_self: Option<Self>) -> int;
fn max_10_exp(unused_self: Option<Self>) -> isize;
/// Returns the smallest finite value that this type can represent.
///
@ -698,7 +698,7 @@ pub trait Float
/// ```
#[unstable(feature = "std_misc",
reason = "pending integer conventions")]
fn ldexp(x: Self, exp: int) -> Self;
fn ldexp(x: Self, exp: isize) -> Self;
/// Breaks the number into a normalized fraction and a base-2 exponent,
/// satisfying:
///
@ -720,7 +720,7 @@ pub trait Float
/// ```
#[unstable(feature = "std_misc",
reason = "pending integer conventions")]
fn frexp(self) -> (Self, int);
fn frexp(self) -> (Self, isize);
/// Returns the next representable floating-point value in the direction of
/// `other`.
///
@ -1112,12 +1112,12 @@ mod tests {
use i16;
use i32;
use i64;
use int;
use isize;
use u8;
use u16;
use u32;
use u64;
use uint;
use usize;
macro_rules! test_cast_20 {
($_20:expr) => ({
@ -1179,25 +1179,25 @@ mod tests {
#[test]
fn test_cast_range_int_min() {
assert_eq!(int::MIN.to_int(), Some(int::MIN as int));
assert_eq!(int::MIN.to_i8(), None);
assert_eq!(int::MIN.to_i16(), None);
// int::MIN.to_i32() is word-size specific
assert_eq!(int::MIN.to_i64(), Some(int::MIN as i64));
assert_eq!(int::MIN.to_uint(), None);
assert_eq!(int::MIN.to_u8(), None);
assert_eq!(int::MIN.to_u16(), None);
assert_eq!(int::MIN.to_u32(), None);
assert_eq!(int::MIN.to_u64(), None);
assert_eq!(isize::MIN.to_int(), Some(isize::MIN as isize));
assert_eq!(isize::MIN.to_i8(), None);
assert_eq!(isize::MIN.to_i16(), None);
// isize::MIN.to_i32() is word-size specific
assert_eq!(isize::MIN.to_i64(), Some(isize::MIN as i64));
assert_eq!(isize::MIN.to_uint(), None);
assert_eq!(isize::MIN.to_u8(), None);
assert_eq!(isize::MIN.to_u16(), None);
assert_eq!(isize::MIN.to_u32(), None);
assert_eq!(isize::MIN.to_u64(), None);
#[cfg(target_pointer_width = "32")]
fn check_word_size() {
assert_eq!(int::MIN.to_i32(), Some(int::MIN as i32));
assert_eq!(isize::MIN.to_i32(), Some(isize::MIN as i32));
}
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(int::MIN.to_i32(), None);
assert_eq!(isize::MIN.to_i32(), None);
}
check_word_size();
@ -1205,7 +1205,7 @@ mod tests {
#[test]
fn test_cast_range_i8_min() {
assert_eq!(i8::MIN.to_int(), Some(i8::MIN as int));
assert_eq!(i8::MIN.to_int(), Some(i8::MIN as isize));
assert_eq!(i8::MIN.to_i8(), Some(i8::MIN as i8));
assert_eq!(i8::MIN.to_i16(), Some(i8::MIN as i16));
assert_eq!(i8::MIN.to_i32(), Some(i8::MIN as i32));
@ -1219,7 +1219,7 @@ mod tests {
#[test]
fn test_cast_range_i16_min() {
assert_eq!(i16::MIN.to_int(), Some(i16::MIN as int));
assert_eq!(i16::MIN.to_int(), Some(i16::MIN as isize));
assert_eq!(i16::MIN.to_i8(), None);
assert_eq!(i16::MIN.to_i16(), Some(i16::MIN as i16));
assert_eq!(i16::MIN.to_i32(), Some(i16::MIN as i32));
@ -1233,7 +1233,7 @@ mod tests {
#[test]
fn test_cast_range_i32_min() {
assert_eq!(i32::MIN.to_int(), Some(i32::MIN as int));
assert_eq!(i32::MIN.to_int(), Some(i32::MIN as isize));
assert_eq!(i32::MIN.to_i8(), None);
assert_eq!(i32::MIN.to_i16(), None);
assert_eq!(i32::MIN.to_i32(), Some(i32::MIN as i32));
@ -1265,7 +1265,7 @@ mod tests {
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(i64::MIN.to_int(), Some(i64::MIN as int));
assert_eq!(i64::MIN.to_int(), Some(i64::MIN as isize));
}
check_word_size();
@ -1273,26 +1273,26 @@ mod tests {
#[test]
fn test_cast_range_int_max() {
assert_eq!(int::MAX.to_int(), Some(int::MAX as int));
assert_eq!(int::MAX.to_i8(), None);
assert_eq!(int::MAX.to_i16(), None);
// int::MAX.to_i32() is word-size specific
assert_eq!(int::MAX.to_i64(), Some(int::MAX as i64));
assert_eq!(int::MAX.to_u8(), None);
assert_eq!(int::MAX.to_u16(), None);
// int::MAX.to_u32() is word-size specific
assert_eq!(int::MAX.to_u64(), Some(int::MAX as u64));
assert_eq!(isize::MAX.to_int(), Some(isize::MAX as isize));
assert_eq!(isize::MAX.to_i8(), None);
assert_eq!(isize::MAX.to_i16(), None);
// isize::MAX.to_i32() is word-size specific
assert_eq!(isize::MAX.to_i64(), Some(isize::MAX as i64));
assert_eq!(isize::MAX.to_u8(), None);
assert_eq!(isize::MAX.to_u16(), None);
// isize::MAX.to_u32() is word-size specific
assert_eq!(isize::MAX.to_u64(), Some(isize::MAX as u64));
#[cfg(target_pointer_width = "32")]
fn check_word_size() {
assert_eq!(int::MAX.to_i32(), Some(int::MAX as i32));
assert_eq!(int::MAX.to_u32(), Some(int::MAX as u32));
assert_eq!(isize::MAX.to_i32(), Some(isize::MAX as i32));
assert_eq!(isize::MAX.to_u32(), Some(isize::MAX as u32));
}
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(int::MAX.to_i32(), None);
assert_eq!(int::MAX.to_u32(), None);
assert_eq!(isize::MAX.to_i32(), None);
assert_eq!(isize::MAX.to_u32(), None);
}
check_word_size();
@ -1300,12 +1300,12 @@ mod tests {
#[test]
fn test_cast_range_i8_max() {
assert_eq!(i8::MAX.to_int(), Some(i8::MAX as int));
assert_eq!(i8::MAX.to_int(), Some(i8::MAX as isize));
assert_eq!(i8::MAX.to_i8(), Some(i8::MAX as i8));
assert_eq!(i8::MAX.to_i16(), Some(i8::MAX as i16));
assert_eq!(i8::MAX.to_i32(), Some(i8::MAX as i32));
assert_eq!(i8::MAX.to_i64(), Some(i8::MAX as i64));
assert_eq!(i8::MAX.to_uint(), Some(i8::MAX as uint));
assert_eq!(i8::MAX.to_uint(), Some(i8::MAX as usize));
assert_eq!(i8::MAX.to_u8(), Some(i8::MAX as u8));
assert_eq!(i8::MAX.to_u16(), Some(i8::MAX as u16));
assert_eq!(i8::MAX.to_u32(), Some(i8::MAX as u32));
@ -1314,12 +1314,12 @@ mod tests {
#[test]
fn test_cast_range_i16_max() {
assert_eq!(i16::MAX.to_int(), Some(i16::MAX as int));
assert_eq!(i16::MAX.to_int(), Some(i16::MAX as isize));
assert_eq!(i16::MAX.to_i8(), None);
assert_eq!(i16::MAX.to_i16(), Some(i16::MAX as i16));
assert_eq!(i16::MAX.to_i32(), Some(i16::MAX as i32));
assert_eq!(i16::MAX.to_i64(), Some(i16::MAX as i64));
assert_eq!(i16::MAX.to_uint(), Some(i16::MAX as uint));
assert_eq!(i16::MAX.to_uint(), Some(i16::MAX as usize));
assert_eq!(i16::MAX.to_u8(), None);
assert_eq!(i16::MAX.to_u16(), Some(i16::MAX as u16));
assert_eq!(i16::MAX.to_u32(), Some(i16::MAX as u32));
@ -1328,12 +1328,12 @@ mod tests {
#[test]
fn test_cast_range_i32_max() {
assert_eq!(i32::MAX.to_int(), Some(i32::MAX as int));
assert_eq!(i32::MAX.to_int(), Some(i32::MAX as isize));
assert_eq!(i32::MAX.to_i8(), None);
assert_eq!(i32::MAX.to_i16(), None);
assert_eq!(i32::MAX.to_i32(), Some(i32::MAX as i32));
assert_eq!(i32::MAX.to_i64(), Some(i32::MAX as i64));
assert_eq!(i32::MAX.to_uint(), Some(i32::MAX as uint));
assert_eq!(i32::MAX.to_uint(), Some(i32::MAX as usize));
assert_eq!(i32::MAX.to_u8(), None);
assert_eq!(i32::MAX.to_u16(), None);
assert_eq!(i32::MAX.to_u32(), Some(i32::MAX as u32));
@ -1361,8 +1361,8 @@ mod tests {
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(i64::MAX.to_int(), Some(i64::MAX as int));
assert_eq!(i64::MAX.to_uint(), Some(i64::MAX as uint));
assert_eq!(i64::MAX.to_int(), Some(i64::MAX as isize));
assert_eq!(i64::MAX.to_uint(), Some(i64::MAX as usize));
}
check_word_size();
@ -1370,26 +1370,26 @@ mod tests {
#[test]
fn test_cast_range_uint_min() {
assert_eq!(uint::MIN.to_int(), Some(uint::MIN as int));
assert_eq!(uint::MIN.to_i8(), Some(uint::MIN as i8));
assert_eq!(uint::MIN.to_i16(), Some(uint::MIN as i16));
assert_eq!(uint::MIN.to_i32(), Some(uint::MIN as i32));
assert_eq!(uint::MIN.to_i64(), Some(uint::MIN as i64));
assert_eq!(uint::MIN.to_uint(), Some(uint::MIN as uint));
assert_eq!(uint::MIN.to_u8(), Some(uint::MIN as u8));
assert_eq!(uint::MIN.to_u16(), Some(uint::MIN as u16));
assert_eq!(uint::MIN.to_u32(), Some(uint::MIN as u32));
assert_eq!(uint::MIN.to_u64(), Some(uint::MIN as u64));
assert_eq!(usize::MIN.to_int(), Some(usize::MIN as isize));
assert_eq!(usize::MIN.to_i8(), Some(usize::MIN as i8));
assert_eq!(usize::MIN.to_i16(), Some(usize::MIN as i16));
assert_eq!(usize::MIN.to_i32(), Some(usize::MIN as i32));
assert_eq!(usize::MIN.to_i64(), Some(usize::MIN as i64));
assert_eq!(usize::MIN.to_uint(), Some(usize::MIN as usize));
assert_eq!(usize::MIN.to_u8(), Some(usize::MIN as u8));
assert_eq!(usize::MIN.to_u16(), Some(usize::MIN as u16));
assert_eq!(usize::MIN.to_u32(), Some(usize::MIN as u32));
assert_eq!(usize::MIN.to_u64(), Some(usize::MIN as u64));
}
#[test]
fn test_cast_range_u8_min() {
assert_eq!(u8::MIN.to_int(), Some(u8::MIN as int));
assert_eq!(u8::MIN.to_int(), Some(u8::MIN as isize));
assert_eq!(u8::MIN.to_i8(), Some(u8::MIN as i8));
assert_eq!(u8::MIN.to_i16(), Some(u8::MIN as i16));
assert_eq!(u8::MIN.to_i32(), Some(u8::MIN as i32));
assert_eq!(u8::MIN.to_i64(), Some(u8::MIN as i64));
assert_eq!(u8::MIN.to_uint(), Some(u8::MIN as uint));
assert_eq!(u8::MIN.to_uint(), Some(u8::MIN as usize));
assert_eq!(u8::MIN.to_u8(), Some(u8::MIN as u8));
assert_eq!(u8::MIN.to_u16(), Some(u8::MIN as u16));
assert_eq!(u8::MIN.to_u32(), Some(u8::MIN as u32));
@ -1398,12 +1398,12 @@ mod tests {
#[test]
fn test_cast_range_u16_min() {
assert_eq!(u16::MIN.to_int(), Some(u16::MIN as int));
assert_eq!(u16::MIN.to_int(), Some(u16::MIN as isize));
assert_eq!(u16::MIN.to_i8(), Some(u16::MIN as i8));
assert_eq!(u16::MIN.to_i16(), Some(u16::MIN as i16));
assert_eq!(u16::MIN.to_i32(), Some(u16::MIN as i32));
assert_eq!(u16::MIN.to_i64(), Some(u16::MIN as i64));
assert_eq!(u16::MIN.to_uint(), Some(u16::MIN as uint));
assert_eq!(u16::MIN.to_uint(), Some(u16::MIN as usize));
assert_eq!(u16::MIN.to_u8(), Some(u16::MIN as u8));
assert_eq!(u16::MIN.to_u16(), Some(u16::MIN as u16));
assert_eq!(u16::MIN.to_u32(), Some(u16::MIN as u32));
@ -1412,12 +1412,12 @@ mod tests {
#[test]
fn test_cast_range_u32_min() {
assert_eq!(u32::MIN.to_int(), Some(u32::MIN as int));
assert_eq!(u32::MIN.to_int(), Some(u32::MIN as isize));
assert_eq!(u32::MIN.to_i8(), Some(u32::MIN as i8));
assert_eq!(u32::MIN.to_i16(), Some(u32::MIN as i16));
assert_eq!(u32::MIN.to_i32(), Some(u32::MIN as i32));
assert_eq!(u32::MIN.to_i64(), Some(u32::MIN as i64));
assert_eq!(u32::MIN.to_uint(), Some(u32::MIN as uint));
assert_eq!(u32::MIN.to_uint(), Some(u32::MIN as usize));
assert_eq!(u32::MIN.to_u8(), Some(u32::MIN as u8));
assert_eq!(u32::MIN.to_u16(), Some(u32::MIN as u16));
assert_eq!(u32::MIN.to_u32(), Some(u32::MIN as u32));
@ -1426,12 +1426,12 @@ mod tests {
#[test]
fn test_cast_range_u64_min() {
assert_eq!(u64::MIN.to_int(), Some(u64::MIN as int));
assert_eq!(u64::MIN.to_int(), Some(u64::MIN as isize));
assert_eq!(u64::MIN.to_i8(), Some(u64::MIN as i8));
assert_eq!(u64::MIN.to_i16(), Some(u64::MIN as i16));
assert_eq!(u64::MIN.to_i32(), Some(u64::MIN as i32));
assert_eq!(u64::MIN.to_i64(), Some(u64::MIN as i64));
assert_eq!(u64::MIN.to_uint(), Some(u64::MIN as uint));
assert_eq!(u64::MIN.to_uint(), Some(u64::MIN as usize));
assert_eq!(u64::MIN.to_u8(), Some(u64::MIN as u8));
assert_eq!(u64::MIN.to_u16(), Some(u64::MIN as u16));
assert_eq!(u64::MIN.to_u32(), Some(u64::MIN as u32));
@ -1440,26 +1440,26 @@ mod tests {
#[test]
fn test_cast_range_uint_max() {
assert_eq!(uint::MAX.to_int(), None);
assert_eq!(uint::MAX.to_i8(), None);
assert_eq!(uint::MAX.to_i16(), None);
assert_eq!(uint::MAX.to_i32(), None);
// uint::MAX.to_i64() is word-size specific
assert_eq!(uint::MAX.to_u8(), None);
assert_eq!(uint::MAX.to_u16(), None);
// uint::MAX.to_u32() is word-size specific
assert_eq!(uint::MAX.to_u64(), Some(uint::MAX as u64));
assert_eq!(usize::MAX.to_int(), None);
assert_eq!(usize::MAX.to_i8(), None);
assert_eq!(usize::MAX.to_i16(), None);
assert_eq!(usize::MAX.to_i32(), None);
// usize::MAX.to_i64() is word-size specific
assert_eq!(usize::MAX.to_u8(), None);
assert_eq!(usize::MAX.to_u16(), None);
// usize::MAX.to_u32() is word-size specific
assert_eq!(usize::MAX.to_u64(), Some(usize::MAX as u64));
#[cfg(target_pointer_width = "32")]
fn check_word_size() {
assert_eq!(uint::MAX.to_u32(), Some(uint::MAX as u32));
assert_eq!(uint::MAX.to_i64(), Some(uint::MAX as i64));
assert_eq!(usize::MAX.to_u32(), Some(usize::MAX as u32));
assert_eq!(usize::MAX.to_i64(), Some(usize::MAX as i64));
}
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(uint::MAX.to_u32(), None);
assert_eq!(uint::MAX.to_i64(), None);
assert_eq!(usize::MAX.to_u32(), None);
assert_eq!(usize::MAX.to_i64(), None);
}
check_word_size();
@ -1467,12 +1467,12 @@ mod tests {
#[test]
fn test_cast_range_u8_max() {
assert_eq!(u8::MAX.to_int(), Some(u8::MAX as int));
assert_eq!(u8::MAX.to_int(), Some(u8::MAX as isize));
assert_eq!(u8::MAX.to_i8(), None);
assert_eq!(u8::MAX.to_i16(), Some(u8::MAX as i16));
assert_eq!(u8::MAX.to_i32(), Some(u8::MAX as i32));
assert_eq!(u8::MAX.to_i64(), Some(u8::MAX as i64));
assert_eq!(u8::MAX.to_uint(), Some(u8::MAX as uint));
assert_eq!(u8::MAX.to_uint(), Some(u8::MAX as usize));
assert_eq!(u8::MAX.to_u8(), Some(u8::MAX as u8));
assert_eq!(u8::MAX.to_u16(), Some(u8::MAX as u16));
assert_eq!(u8::MAX.to_u32(), Some(u8::MAX as u32));
@ -1481,12 +1481,12 @@ mod tests {
#[test]
fn test_cast_range_u16_max() {
assert_eq!(u16::MAX.to_int(), Some(u16::MAX as int));
assert_eq!(u16::MAX.to_int(), Some(u16::MAX as isize));
assert_eq!(u16::MAX.to_i8(), None);
assert_eq!(u16::MAX.to_i16(), None);
assert_eq!(u16::MAX.to_i32(), Some(u16::MAX as i32));
assert_eq!(u16::MAX.to_i64(), Some(u16::MAX as i64));
assert_eq!(u16::MAX.to_uint(), Some(u16::MAX as uint));
assert_eq!(u16::MAX.to_uint(), Some(u16::MAX as usize));
assert_eq!(u16::MAX.to_u8(), None);
assert_eq!(u16::MAX.to_u16(), Some(u16::MAX as u16));
assert_eq!(u16::MAX.to_u32(), Some(u16::MAX as u32));
@ -1500,7 +1500,7 @@ mod tests {
assert_eq!(u32::MAX.to_i16(), None);
assert_eq!(u32::MAX.to_i32(), None);
assert_eq!(u32::MAX.to_i64(), Some(u32::MAX as i64));
assert_eq!(u32::MAX.to_uint(), Some(u32::MAX as uint));
assert_eq!(u32::MAX.to_uint(), Some(u32::MAX as usize));
assert_eq!(u32::MAX.to_u8(), None);
assert_eq!(u32::MAX.to_u16(), None);
assert_eq!(u32::MAX.to_u32(), Some(u32::MAX as u32));
@ -1513,7 +1513,7 @@ mod tests {
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(u32::MAX.to_int(), Some(u32::MAX as int));
assert_eq!(u32::MAX.to_int(), Some(u32::MAX as isize));
}
check_word_size();
@ -1539,7 +1539,7 @@ mod tests {
#[cfg(target_pointer_width = "64")]
fn check_word_size() {
assert_eq!(u64::MAX.to_uint(), Some(u64::MAX as uint));
assert_eq!(u64::MAX.to_uint(), Some(u64::MAX as usize));
}
check_word_size();
@ -1547,7 +1547,7 @@ mod tests {
#[test]
fn test_saturating_add_uint() {
use uint::MAX;
use usize::MAX;
assert_eq!(3_usize.saturating_add(5_usize), 8_usize);
assert_eq!(3_usize.saturating_add(MAX-1), MAX);
assert_eq!(MAX.saturating_add(MAX), MAX);
@ -1556,7 +1556,7 @@ mod tests {
#[test]
fn test_saturating_sub_uint() {
use uint::MAX;
use usize::MAX;
assert_eq!(5_usize.saturating_sub(3_usize), 2_usize);
assert_eq!(3_usize.saturating_sub(5_usize), 0_usize);
assert_eq!(0_usize.saturating_sub(1_usize), 0_usize);
@ -1565,7 +1565,7 @@ mod tests {
#[test]
fn test_saturating_add_int() {
use int::{MIN,MAX};
use isize::{MIN,MAX};
assert_eq!(3.saturating_add(5), 8);
assert_eq!(3.saturating_add(MAX-1), MAX);
assert_eq!(MAX.saturating_add(MAX), MAX);
@ -1577,7 +1577,7 @@ mod tests {
#[test]
fn test_saturating_sub_int() {
use int::{MIN,MAX};
use isize::{MIN,MAX};
assert_eq!(3.saturating_sub(5), -2);
assert_eq!(MIN.saturating_sub(1), MIN);
assert_eq!((-2).saturating_sub(MAX), MIN);
@ -1589,13 +1589,13 @@ mod tests {
#[test]
fn test_checked_add() {
let five_less = uint::MAX - 5;
assert_eq!(five_less.checked_add(0), Some(uint::MAX - 5));
assert_eq!(five_less.checked_add(1), Some(uint::MAX - 4));
assert_eq!(five_less.checked_add(2), Some(uint::MAX - 3));
assert_eq!(five_less.checked_add(3), Some(uint::MAX - 2));
assert_eq!(five_less.checked_add(4), Some(uint::MAX - 1));
assert_eq!(five_less.checked_add(5), Some(uint::MAX));
let five_less = usize::MAX - 5;
assert_eq!(five_less.checked_add(0), Some(usize::MAX - 5));
assert_eq!(five_less.checked_add(1), Some(usize::MAX - 4));
assert_eq!(five_less.checked_add(2), Some(usize::MAX - 3));
assert_eq!(five_less.checked_add(3), Some(usize::MAX - 2));
assert_eq!(five_less.checked_add(4), Some(usize::MAX - 1));
assert_eq!(five_less.checked_add(5), Some(usize::MAX));
assert_eq!(five_less.checked_add(6), None);
assert_eq!(five_less.checked_add(7), None);
}
@ -1614,7 +1614,7 @@ mod tests {
#[test]
fn test_checked_mul() {
let third = uint::MAX / 3;
let third = usize::MAX / 3;
assert_eq!(third.checked_mul(0), Some(0));
assert_eq!(third.checked_mul(1), Some(third));
assert_eq!(third.checked_mul(2), Some(third * 2));
@ -1641,7 +1641,7 @@ mod tests {
test_is_power_of_two!{ test_is_power_of_two_u16, u16 }
test_is_power_of_two!{ test_is_power_of_two_u32, u32 }
test_is_power_of_two!{ test_is_power_of_two_u64, u64 }
test_is_power_of_two!{ test_is_power_of_two_uint, uint }
test_is_power_of_two!{ test_is_power_of_two_uint, usize }
macro_rules! test_next_power_of_two {
($test_name:ident, $T:ident) => (
@ -1661,7 +1661,7 @@ mod tests {
test_next_power_of_two! { test_next_power_of_two_u16, u16 }
test_next_power_of_two! { test_next_power_of_two_u32, u32 }
test_next_power_of_two! { test_next_power_of_two_u64, u64 }
test_next_power_of_two! { test_next_power_of_two_uint, uint }
test_next_power_of_two! { test_next_power_of_two_uint, usize }
macro_rules! test_checked_next_power_of_two {
($test_name:ident, $T:ident) => (
@ -1684,10 +1684,10 @@ mod tests {
test_checked_next_power_of_two! { test_checked_next_power_of_two_u16, u16 }
test_checked_next_power_of_two! { test_checked_next_power_of_two_u32, u32 }
test_checked_next_power_of_two! { test_checked_next_power_of_two_u64, u64 }
test_checked_next_power_of_two! { test_checked_next_power_of_two_uint, uint }
test_checked_next_power_of_two! { test_checked_next_power_of_two_uint, usize }
#[derive(PartialEq, Debug)]
struct Value { x: int }
struct Value { x: isize }
impl ToPrimitive for Value {
fn to_i64(&self) -> Option<i64> { self.x.to_i64() }
@ -1695,8 +1695,8 @@ mod tests {
}
impl FromPrimitive for Value {
fn from_i64(n: i64) -> Option<Value> { Some(Value { x: n as int }) }
fn from_u64(n: u64) -> Option<Value> { Some(Value { x: n as int }) }
fn from_i64(n: i64) -> Option<Value> { Some(Value { x: n as isize }) }
fn from_u64(n: u64) -> Option<Value> { Some(Value { x: n as isize }) }
}
#[test]
@ -1734,7 +1734,7 @@ mod tests {
#[test]
fn test_pow() {
fn naive_pow<T: Int>(base: T, exp: uint) -> T {
fn naive_pow<T: Int>(base: T, exp: usize) -> T {
let one: T = Int::one();
(0..exp).fold(one, |acc, _| acc * base)
}

View File

@ -1,22 +0,0 @@
// Copyright 2012-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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Deprecated: replaced by `usize`.
//!
//! The rollout of the new type will gradually take place over the
//! alpha cycle along with the development of clearer conventions
//! around integer types.
#![unstable(feature = "std_misc")]
#![deprecated(since = "1.0.0", reason = "replaced by usize")]
pub use core::uint::{BITS, BYTES, MIN, MAX};
uint_module! { uint }

View File

@ -240,6 +240,8 @@
#![unstable(feature = "old_io")]
#![deny(unused_must_use)]
#![allow(deprecated)] // seriously this is all deprecated
#![allow(unused_imports)]
pub use self::SeekStyle::*;
pub use self::FileMode::*;

View File

@ -60,6 +60,8 @@
//! ```
#![unstable(feature = "old_path")]
#![allow(deprecated)] // seriously this is all deprecated
#![allow(unused_imports)]
use core::marker::Sized;
use ffi::CString;

View File

@ -1324,7 +1324,6 @@ impl<T: AsOsStr + ?Sized> AsPath for T {
#[cfg(test)]
mod tests {
use super::*;
use ffi::OsStr;
use core::prelude::*;
use string::{ToString, String};
use vec::Vec;

View File

@ -489,18 +489,14 @@ impl Child {
mod tests {
use io::ErrorKind;
use io::prelude::*;
use prelude::v1::{Ok, Err, range, drop, Some, None, Vec};
use prelude::v1::{Ok, Err, drop, Some, Vec};
use prelude::v1::{String, Clone};
use prelude::v1::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath};
use path::Path;
use old_path;
use old_io::fs::PathExtensions;
use rt::running_on_valgrind;
use str;
use super::{Child, Command, Output, ExitStatus, Stdio};
use sync::mpsc::channel;
use thread;
use time::Duration;
use super::{Command, Output, Stdio};
// FIXME(#10380) these tests should not all be ignored on android.

View File

@ -702,7 +702,7 @@ mod test {
use boxed::BoxAny;
use result;
use std::old_io::{ChanReader, ChanWriter};
use super::{Thread, Builder};
use super::{Builder};
use thread;
use thunk::Thunk;
use time::Duration;
@ -767,7 +767,7 @@ mod test {
#[test]
#[should_fail]
fn test_scoped_implicit_panic() {
thread::scoped(|| panic!());
let _ = thread::scoped(|| panic!());
}
#[test]