diff options
Diffstat (limited to 'src/libstd')
67 files changed, 547 insertions, 548 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index f9558b85825..76d7570bfed 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -505,7 +505,7 @@ impl<K: Hash + Eq, V> HashMap<K, V, RandomState> { /// /// ``` /// use std::collections::HashMap; - /// let mut map: HashMap<&str, int> = HashMap::new(); + /// let mut map: HashMap<&str, isize> = HashMap::new(); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -519,7 +519,7 @@ impl<K: Hash + Eq, V> HashMap<K, V, RandomState> { /// /// ``` /// use std::collections::HashMap; - /// let mut map: HashMap<&str, int> = HashMap::with_capacity(10); + /// let mut map: HashMap<&str, isize> = HashMap::with_capacity(10); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -596,7 +596,7 @@ impl<K, V, S> HashMap<K, V, S> /// /// ``` /// use std::collections::HashMap; - /// let map: HashMap<int, int> = HashMap::with_capacity(100); + /// let map: HashMap<isize, isize> = HashMap::with_capacity(100); /// assert!(map.capacity() >= 100); /// ``` #[inline] @@ -617,7 +617,7 @@ impl<K, V, S> HashMap<K, V, S> /// /// ``` /// use std::collections::HashMap; - /// let mut map: HashMap<&str, int> = HashMap::new(); + /// let mut map: HashMap<&str, isize> = HashMap::new(); /// map.reserve(10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -725,7 +725,7 @@ impl<K, V, S> HashMap<K, V, S> /// ``` /// use std::collections::HashMap; /// - /// let mut map: HashMap<int, int> = HashMap::with_capacity(100); + /// let mut map: HashMap<isize, isize> = HashMap::with_capacity(100); /// map.insert(1, 2); /// map.insert(3, 4); /// assert!(map.capacity() >= 100); @@ -797,9 +797,9 @@ impl<K, V, S> HashMap<K, V, S> } } - let robin_ib = bucket.index() as int - bucket.distance() as int; + let robin_ib = bucket.index() as isize - bucket.distance() as isize; - if (ib as int) < robin_ib { + if (ib as isize) < robin_ib { // Found a luckier bucket than me. Better steal his spot. return robin_hood(bucket, robin_ib as usize, hash, k, v); } @@ -924,7 +924,7 @@ impl<K, V, S> HashMap<K, V, S> /// map.insert("c", 3); /// /// // Not possible with .iter() - /// let vec: Vec<(&str, int)> = map.into_iter().collect(); + /// let vec: Vec<(&str, isize)> = map.into_iter().collect(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn into_iter(self) -> IntoIter<K, V> { @@ -1188,9 +1188,9 @@ fn search_entry_hashed<'a, K: Eq, V>(table: &'a mut RawTable<K,V>, hash: SafeHas } } - let robin_ib = bucket.index() as int - bucket.distance() as int; + let robin_ib = bucket.index() as isize - bucket.distance() as isize; - if (ib as int) < robin_ib { + if (ib as isize) < robin_ib { // Found a luckier bucket than me. Better steal his spot. return Vacant(VacantEntry { hash: hash, @@ -1648,7 +1648,7 @@ mod test_map { assert_eq!(*m.get(&2).unwrap(), 4); } - thread_local! { static DROP_VECTOR: RefCell<Vec<int>> = RefCell::new(Vec::new()) } + thread_local! { static DROP_VECTOR: RefCell<Vec<isize>> = RefCell::new(Vec::new()) } #[derive(Hash, PartialEq, Eq)] struct Dropable { @@ -1805,7 +1805,7 @@ mod test_map { #[test] fn test_empty_pop() { - let mut m: HashMap<int, bool> = HashMap::new(); + let mut m: HashMap<isize, bool> = HashMap::new(); assert_eq!(m.remove(&0), None); } diff --git a/src/libstd/fs/tempdir.rs b/src/libstd/fs/tempdir.rs index a9717e36323..8cc1dde98a0 100644 --- a/src/libstd/fs/tempdir.rs +++ b/src/libstd/fs/tempdir.rs @@ -34,7 +34,7 @@ const NUM_RETRIES: u32 = 1 << 31; // be enough to dissuade an attacker from trying to preemptively create names // of that length, but not so huge that we unnecessarily drain the random number // generator of entropy. -const NUM_RAND_CHARS: uint = 12; +const NUM_RAND_CHARS: usize = 12; impl TempDir { /// Attempts to make a temporary directory inside of `tmpdir` whose name diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 2a1294f23b2..34d442e2fb5 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -98,7 +98,7 @@ impl<R: Read> BufRead for BufReader<R> { self.buf.fill_buf() } - fn consume(&mut self, amt: uint) { + fn consume(&mut self, amt: usize) { self.buf.consume(amt) } } @@ -427,7 +427,7 @@ impl<S: Read + Write> BufStream<S> { #[stable(feature = "rust1", since = "1.0.0")] impl<S: Read + Write> BufRead for BufStream<S> { fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() } - fn consume(&mut self, amt: uint) { self.inner.consume(amt) } + fn consume(&mut self, amt: usize) { self.inner.consume(amt) } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index cca6bb747d4..5890a750f6e 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -123,7 +123,6 @@ #![feature(unsafe_destructor)] #![feature(unsafe_no_drop_flag)] #![feature(macro_reexport)] -#![feature(int_uint)] #![feature(unique)] #![feature(convert)] #![feature(allow_internal_unstable)] diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index a4f06f14d49..dc1d53b8a39 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -91,27 +91,27 @@ impl Float for f32 { #[allow(deprecated)] #[inline] - fn mantissa_digits(unused_self: Option<f32>) -> uint { + fn mantissa_digits(unused_self: Option<f32>) -> usize { num::Float::mantissa_digits(unused_self) } #[allow(deprecated)] #[inline] - fn digits(unused_self: Option<f32>) -> uint { num::Float::digits(unused_self) } + fn digits(unused_self: Option<f32>) -> usize { num::Float::digits(unused_self) } #[allow(deprecated)] #[inline] fn epsilon() -> f32 { num::Float::epsilon() } #[allow(deprecated)] #[inline] - fn min_exp(unused_self: Option<f32>) -> int { num::Float::min_exp(unused_self) } + fn min_exp(unused_self: Option<f32>) -> isize { num::Float::min_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_exp(unused_self: Option<f32>) -> int { num::Float::max_exp(unused_self) } + fn max_exp(unused_self: Option<f32>) -> isize { num::Float::max_exp(unused_self) } #[allow(deprecated)] #[inline] - fn min_10_exp(unused_self: Option<f32>) -> int { num::Float::min_10_exp(unused_self) } + fn min_10_exp(unused_self: Option<f32>) -> isize { num::Float::min_10_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_10_exp(unused_self: Option<f32>) -> int { num::Float::max_10_exp(unused_self) } + fn max_10_exp(unused_self: Option<f32>) -> isize { num::Float::max_10_exp(unused_self) } #[allow(deprecated)] #[inline] fn min_value() -> f32 { num::Float::min_value() } @@ -201,11 +201,11 @@ impl Float for f32 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` #[inline] - fn frexp(self) -> (f32, int) { + fn frexp(self) -> (f32, isize) { unsafe { let mut exp = 0; let x = cmath::frexpf(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -476,7 +476,7 @@ impl f32 { `std::f64::MANTISSA_DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn mantissa_digits(unused_self: Option<f32>) -> uint { + pub fn mantissa_digits(unused_self: Option<f32>) -> usize { num::Float::mantissa_digits(unused_self) } @@ -486,7 +486,7 @@ impl f32 { reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn digits(unused_self: Option<f32>) -> uint { num::Float::digits(unused_self) } + pub fn digits(unused_self: Option<f32>) -> usize { num::Float::digits(unused_self) } /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead. #[unstable(feature = "std_misc")] @@ -502,7 +502,7 @@ impl f32 { reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_exp(unused_self: Option<f32>) -> int { num::Float::min_exp(unused_self) } + pub fn min_exp(unused_self: Option<f32>) -> isize { num::Float::min_exp(unused_self) } /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead. #[unstable(feature = "std_misc")] @@ -510,7 +510,7 @@ impl f32 { reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_exp(unused_self: Option<f32>) -> int { num::Float::max_exp(unused_self) } + pub fn max_exp(unused_self: Option<f32>) -> isize { num::Float::max_exp(unused_self) } /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -518,7 +518,7 @@ impl f32 { reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_10_exp(unused_self: Option<f32>) -> int { num::Float::min_10_exp(unused_self) } + pub fn min_10_exp(unused_self: Option<f32>) -> isize { num::Float::min_10_exp(unused_self) } /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -526,7 +526,7 @@ impl f32 { reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_10_exp(unused_self: Option<f32>) -> int { num::Float::max_10_exp(unused_self) } + pub fn max_10_exp(unused_self: Option<f32>) -> isize { num::Float::max_10_exp(unused_self) } /// Returns the smallest finite value that this type can represent. /// @@ -1126,7 +1126,7 @@ impl f32 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn ldexp(x: f32, exp: int) -> f32 { + pub fn ldexp(x: f32, exp: isize) -> f32 { unsafe { cmath::ldexpf(x, exp as c_int) } } @@ -1153,11 +1153,11 @@ impl f32 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn frexp(self) -> (f32, int) { + pub fn frexp(self) -> (f32, isize) { unsafe { let mut exp = 0; let x = cmath::frexpf(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -1681,7 +1681,7 @@ pub fn to_str_radix_special(num: f32, rdx: u32) -> (String, bool) { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exact(num: f32, dig: uint) -> String { +pub fn to_str_exact(num: f32, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r @@ -1696,7 +1696,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_digits(num: f32, dig: uint) -> String { +pub fn to_str_digits(num: f32, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r @@ -1712,7 +1712,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { +pub fn to_str_exp_exact(num: f32, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r @@ -1728,7 +1728,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { +pub fn to_str_exp_digits(num: f32, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 9306804d1f7..41ce9a2598c 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -101,27 +101,27 @@ impl Float for f64 { #[allow(deprecated)] #[inline] - fn mantissa_digits(unused_self: Option<f64>) -> uint { + fn mantissa_digits(unused_self: Option<f64>) -> usize { num::Float::mantissa_digits(unused_self) } #[allow(deprecated)] #[inline] - fn digits(unused_self: Option<f64>) -> uint { num::Float::digits(unused_self) } + fn digits(unused_self: Option<f64>) -> usize { num::Float::digits(unused_self) } #[allow(deprecated)] #[inline] fn epsilon() -> f64 { num::Float::epsilon() } #[allow(deprecated)] #[inline] - fn min_exp(unused_self: Option<f64>) -> int { num::Float::min_exp(unused_self) } + fn min_exp(unused_self: Option<f64>) -> isize { num::Float::min_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_exp(unused_self: Option<f64>) -> int { num::Float::max_exp(unused_self) } + fn max_exp(unused_self: Option<f64>) -> isize { num::Float::max_exp(unused_self) } #[allow(deprecated)] #[inline] - fn min_10_exp(unused_self: Option<f64>) -> int { num::Float::min_10_exp(unused_self) } + fn min_10_exp(unused_self: Option<f64>) -> isize { num::Float::min_10_exp(unused_self) } #[allow(deprecated)] #[inline] - fn max_10_exp(unused_self: Option<f64>) -> int { num::Float::max_10_exp(unused_self) } + fn max_10_exp(unused_self: Option<f64>) -> isize { num::Float::max_10_exp(unused_self) } #[allow(deprecated)] #[inline] fn min_value() -> f64 { num::Float::min_value() } @@ -210,11 +210,11 @@ impl Float for f64 { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` #[inline] - fn frexp(self) -> (f64, int) { + fn frexp(self) -> (f64, isize) { unsafe { let mut exp = 0; let x = cmath::frexp(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -485,7 +485,7 @@ impl f64 { `std::f64::MANTISSA_DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn mantissa_digits(unused_self: Option<f64>) -> uint { + pub fn mantissa_digits(unused_self: Option<f64>) -> usize { num::Float::mantissa_digits(unused_self) } @@ -495,7 +495,7 @@ impl f64 { reason = "use `std::f32::DIGITS` or `std::f64::DIGITS` as appropriate")] #[allow(deprecated)] #[inline] - pub fn digits(unused_self: Option<f64>) -> uint { num::Float::digits(unused_self) } + pub fn digits(unused_self: Option<f64>) -> usize { num::Float::digits(unused_self) } /// Deprecated: use `std::f32::EPSILON` or `std::f64::EPSILON` instead. #[unstable(feature = "std_misc")] @@ -511,7 +511,7 @@ impl f64 { reason = "use `std::f32::MIN_EXP` or `std::f64::MIN_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_exp(unused_self: Option<f64>) -> int { num::Float::min_exp(unused_self) } + pub fn min_exp(unused_self: Option<f64>) -> isize { num::Float::min_exp(unused_self) } /// Deprecated: use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` instead. #[unstable(feature = "std_misc")] @@ -519,7 +519,7 @@ impl f64 { reason = "use `std::f32::MAX_EXP` or `std::f64::MAX_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_exp(unused_self: Option<f64>) -> int { num::Float::max_exp(unused_self) } + pub fn max_exp(unused_self: Option<f64>) -> isize { num::Float::max_exp(unused_self) } /// Deprecated: use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -527,7 +527,7 @@ impl f64 { reason = "use `std::f32::MIN_10_EXP` or `std::f64::MIN_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn min_10_exp(unused_self: Option<f64>) -> int { num::Float::min_10_exp(unused_self) } + pub fn min_10_exp(unused_self: Option<f64>) -> isize { num::Float::min_10_exp(unused_self) } /// Deprecated: use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` instead. #[unstable(feature = "std_misc")] @@ -535,7 +535,7 @@ impl f64 { reason = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate")] #[allow(deprecated)] #[inline] - pub fn max_10_exp(unused_self: Option<f64>) -> int { num::Float::max_10_exp(unused_self) } + pub fn max_10_exp(unused_self: Option<f64>) -> isize { num::Float::max_10_exp(unused_self) } /// Returns the smallest finite value that this type can represent. /// @@ -1134,7 +1134,7 @@ impl f64 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn ldexp(x: f64, exp: int) -> f64 { + pub fn ldexp(x: f64, exp: isize) -> f64 { unsafe { cmath::ldexp(x, exp as c_int) } } @@ -1161,11 +1161,11 @@ impl f64 { #[unstable(feature = "std_misc", reason = "pending integer conventions")] #[inline] - pub fn frexp(self) -> (f64, int) { + pub fn frexp(self) -> (f64, isize) { unsafe { let mut exp = 0; let x = cmath::frexp(self, &mut exp); - (x, exp as int) + (x, exp as isize) } } @@ -1687,7 +1687,7 @@ pub fn to_str_radix_special(num: f64, rdx: u32) -> (String, bool) { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exact(num: f64, dig: uint) -> String { +pub fn to_str_exact(num: f64, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r @@ -1702,7 +1702,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String { /// * digits - The number of significant digits #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_digits(num: f64, dig: uint) -> String { +pub fn to_str_digits(num: f64, dig: usize) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r @@ -1718,7 +1718,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { +pub fn to_str_exp_exact(num: f64, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r @@ -1734,7 +1734,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { /// * upper - Use `E` instead of `e` for the exponent sign #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { +pub fn to_str_exp_digits(num: f64, dig: usize, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 66826b359e6..1c1aaeb6d53 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -49,10 +49,10 @@ pub enum SignificantDigits { /// At most the given number of digits will be printed, truncating any /// trailing zeroes. - DigMax(uint), + DigMax(usize), /// Precisely the given number of digits will be printed. - DigExact(uint) + DigExact(usize) } /// How to emit the sign of a number. @@ -87,7 +87,7 @@ pub enum SignFormat { /// # Panics /// /// - Panics if `radix` < 2 or `radix` > 36. -fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F) where +fn int_to_str_bytes_common<T, F>(num: T, radix: usize, sign: SignFormat, mut f: F) where T: Int, F: FnMut(u8), { @@ -216,7 +216,7 @@ pub fn float_to_str_bytes_common<T: Float>( let neg = num < _0 || (negative_zero && _1 / num == Float::neg_infinity()); let mut buf = Vec::new(); - let radix_gen: T = num::cast(radix as int).unwrap(); + let radix_gen: T = num::cast(radix as isize).unwrap(); let (num, exp) = match exp_format { ExpNone => (num, 0), @@ -328,28 +328,28 @@ pub fn float_to_str_bytes_common<T: Float>( let extra_digit = ascii2value(buf.pop().unwrap()); if extra_digit >= radix / 2 { // -> need to round - let mut i: int = buf.len() as int - 1; + let mut i: isize = buf.len() as isize - 1; loop { // If reached left end of number, have to // insert additional digit: if i < 0 - || buf[i as uint] == b'-' - || buf[i as uint] == b'+' { - buf.insert((i + 1) as uint, value2ascii(1)); + || buf[i as usize] == b'-' + || buf[i as usize] == b'+' { + buf.insert((i + 1) as usize, value2ascii(1)); break; } // Skip the '.' - if buf[i as uint] == b'.' { i -= 1; continue; } + if buf[i as usize] == b'.' { i -= 1; continue; } // Either increment the digit, // or set to 0 if max and carry the 1. - let current_digit = ascii2value(buf[i as uint]); + let current_digit = ascii2value(buf[i as usize]); if current_digit < (radix - 1) { - buf[i as uint] = value2ascii(current_digit+1); + buf[i as usize] = value2ascii(current_digit+1); break; } else { - buf[i as uint] = value2ascii(0); + buf[i as usize] = value2ascii(0); i -= 1; } } @@ -461,85 +461,85 @@ mod bench { #![allow(deprecated)] // rand extern crate test; - mod uint { + mod usize { use super::test::Bencher; use rand::{weak_rng, Rng}; use std::fmt; #[inline] - fn to_string(x: uint, base: u8) { + fn to_string(x: usize, base: u8) { format!("{}", fmt::radix(x, base)); } #[bench] fn to_str_bin(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 2); }) + b.iter(|| { to_string(rng.gen::<usize>(), 2); }) } #[bench] fn to_str_oct(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 8); }) + b.iter(|| { to_string(rng.gen::<usize>(), 8); }) } #[bench] fn to_str_dec(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 10); }) + b.iter(|| { to_string(rng.gen::<usize>(), 10); }) } #[bench] fn to_str_hex(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 16); }) + b.iter(|| { to_string(rng.gen::<usize>(), 16); }) } #[bench] fn to_str_base_36(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<uint>(), 36); }) + b.iter(|| { to_string(rng.gen::<usize>(), 36); }) } } - mod int { + mod isize { use super::test::Bencher; use rand::{weak_rng, Rng}; use std::fmt; #[inline] - fn to_string(x: int, base: u8) { + fn to_string(x: isize, base: u8) { format!("{}", fmt::radix(x, base)); } #[bench] fn to_str_bin(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 2); }) + b.iter(|| { to_string(rng.gen::<isize>(), 2); }) } #[bench] fn to_str_oct(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 8); }) + b.iter(|| { to_string(rng.gen::<isize>(), 8); }) } #[bench] fn to_str_dec(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 10); }) + b.iter(|| { to_string(rng.gen::<isize>(), 10); }) } #[bench] fn to_str_hex(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 16); }) + b.iter(|| { to_string(rng.gen::<isize>(), 16); }) } #[bench] fn to_str_base_36(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { to_string(rng.gen::<int>(), 36); }) + b.iter(|| { to_string(rng.gen::<isize>(), 36); }) } } diff --git a/src/libstd/old_io/buffered.rs b/src/libstd/old_io/buffered.rs index 9a9d421dfe1..085ec78b565 100644 --- a/src/libstd/old_io/buffered.rs +++ b/src/libstd/old_io/buffered.rs @@ -49,8 +49,8 @@ use vec::Vec; pub struct BufferedReader<R> { inner: R, buf: Vec<u8>, - pos: uint, - cap: uint, + pos: usize, + cap: usize, } #[stable(feature = "rust1", since = "1.0.0")] @@ -63,7 +63,7 @@ impl<R> fmt::Debug for BufferedReader<R> where R: fmt::Debug { impl<R: Reader> BufferedReader<R> { /// Creates a new `BufferedReader` with the specified buffer capacity - pub fn with_capacity(cap: uint, inner: R) -> BufferedReader<R> { + pub fn with_capacity(cap: usize, inner: R) -> BufferedReader<R> { BufferedReader { inner: inner, // We can't use the same trick here as we do for BufferedWriter, @@ -104,14 +104,14 @@ impl<R: Reader> Buffer for BufferedReader<R> { Ok(&self.buf[self.pos..self.cap]) } - fn consume(&mut self, amt: uint) { + fn consume(&mut self, amt: usize) { self.pos += amt; assert!(self.pos <= self.cap); } } impl<R: Reader> Reader for BufferedReader<R> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { if self.pos == self.cap && buf.len() >= self.buf.len() { return self.inner.read(buf); } @@ -151,7 +151,7 @@ impl<R: Reader> Reader for BufferedReader<R> { pub struct BufferedWriter<W: Writer> { inner: Option<W>, buf: Vec<u8>, - pos: uint + pos: usize } #[stable(feature = "rust1", since = "1.0.0")] @@ -164,7 +164,7 @@ impl<W: Writer> fmt::Debug for BufferedWriter<W> where W: fmt::Debug { impl<W: Writer> BufferedWriter<W> { /// Creates a new `BufferedWriter` with the specified buffer capacity - pub fn with_capacity(cap: uint, inner: W) -> BufferedWriter<W> { + pub fn with_capacity(cap: usize, inner: W) -> BufferedWriter<W> { // It's *much* faster to create an uninitialized buffer than it is to // fill everything in with 0. This buffer is entirely an implementation // detail and is never exposed, so we're safe to not initialize @@ -309,7 +309,7 @@ impl<W: Writer> InternalBufferedWriter<W> { } impl<W: Reader + Writer> Reader for InternalBufferedWriter<W> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.get_mut().inner.as_mut().unwrap().read(buf) } } @@ -362,7 +362,7 @@ impl<S: Writer> fmt::Debug for BufferedStream<S> where S: fmt::Debug { impl<S: Stream> BufferedStream<S> { /// Creates a new buffered stream with explicitly listed capacities for the /// reader/writer buffer. - pub fn with_capacities(reader_cap: uint, writer_cap: uint, inner: S) + pub fn with_capacities(reader_cap: usize, writer_cap: usize, inner: S) -> BufferedStream<S> { let writer = BufferedWriter::with_capacity(writer_cap, inner); let internal_writer = InternalBufferedWriter(writer); @@ -407,11 +407,11 @@ impl<S: Stream> BufferedStream<S> { impl<S: Stream> Buffer for BufferedStream<S> { fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> { self.inner.fill_buf() } - fn consume(&mut self, amt: uint) { self.inner.consume(amt) } + fn consume(&mut self, amt: usize) { self.inner.consume(amt) } } impl<S: Stream> Reader for BufferedStream<S> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.read(buf) } } @@ -442,7 +442,7 @@ mod test { pub struct NullStream; impl Reader for NullStream { - fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<usize> { Err(old_io::standard_error(old_io::EndOfFile)) } } @@ -453,11 +453,11 @@ mod test { /// A dummy reader intended at testing short-reads propagation. pub struct ShortReader { - lengths: Vec<uint>, + lengths: Vec<usize>, } impl Reader for ShortReader { - fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<usize> { if self.lengths.is_empty() { Err(old_io::standard_error(old_io::EndOfFile)) } else { @@ -565,7 +565,7 @@ mod test { } impl old_io::Reader for S { - fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<usize> { Err(old_io::standard_error(old_io::EndOfFile)) } } diff --git a/src/libstd/old_io/comm_adapters.rs b/src/libstd/old_io/comm_adapters.rs index cd8252540da..35bc58fecd2 100644 --- a/src/libstd/old_io/comm_adapters.rs +++ b/src/libstd/old_io/comm_adapters.rs @@ -39,7 +39,7 @@ use vec::Vec; /// ``` pub struct ChanReader { buf: Vec<u8>, // A buffer of bytes received but not consumed. - pos: uint, // How many of the buffered bytes have already be consumed. + pos: usize, // How many of the buffered bytes have already be consumed. rx: Receiver<Vec<u8>>, // The Receiver to pull data from. closed: bool, // Whether the channel this Receiver connects to has been closed. } @@ -77,14 +77,14 @@ impl Buffer for ChanReader { } } - fn consume(&mut self, amt: uint) { + fn consume(&mut self, amt: usize) { self.pos += amt; assert!(self.pos <= self.buf.len()); } } impl Reader for ChanReader { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let mut num_read = 0; loop { let count = match self.fill_buf().ok() { diff --git a/src/libstd/old_io/extensions.rs b/src/libstd/old_io/extensions.rs index 5b1b9471b07..441f0a7536e 100644 --- a/src/libstd/old_io/extensions.rs +++ b/src/libstd/old_io/extensions.rs @@ -81,7 +81,7 @@ impl<'r, R: Reader> Iterator for Bytes<'r, R> { /// * `f`: A callback that receives the value. /// /// This function returns the value returned by the callback, for convenience. -pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where +pub fn u64_to_le_bytes<T, F>(n: u64, size: usize, f: F) -> T where F: FnOnce(&[u8]) -> T, { use mem::transmute; @@ -122,7 +122,7 @@ pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where /// * `f`: A callback that receives the value. /// /// This function returns the value returned by the callback, for convenience. -pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where +pub fn u64_to_be_bytes<T, F>(n: u64, size: usize, f: F) -> T where F: FnOnce(&[u8]) -> T, { use mem::transmute; @@ -158,7 +158,7 @@ pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where /// less, or task panic occurs. If this is less than 8, then only /// that many bytes are parsed. For example, if `size` is 4, then a /// 32-bit value is parsed. -pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { +pub fn u64_from_be_bytes(data: &[u8], start: usize, size: usize) -> u64 { use ptr::{copy_nonoverlapping}; assert!(size <= 8); @@ -169,9 +169,9 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { let mut buf = [0; 8]; unsafe { - let ptr = data.as_ptr().offset(start as int); + let ptr = data.as_ptr().offset(start as isize); let out = buf.as_mut_ptr(); - copy_nonoverlapping(out.offset((8 - size) as int), ptr, size); + copy_nonoverlapping(out.offset((8 - size) as isize), ptr, size); (*(out as *const u64)).to_be() } } @@ -183,11 +183,11 @@ mod test { use old_io::{MemReader, BytesReader}; struct InitialZeroByteReader { - count: int, + count: isize, } impl Reader for InitialZeroByteReader { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { if self.count == 0 { self.count = 1; Ok(0) @@ -201,7 +201,7 @@ mod test { struct EofReader; impl Reader for EofReader { - fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<usize> { Err(old_io::standard_error(old_io::EndOfFile)) } } @@ -209,17 +209,17 @@ mod test { struct ErroringReader; impl Reader for ErroringReader { - fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<usize> { Err(old_io::standard_error(old_io::InvalidInput)) } } struct PartialReader { - count: int, + count: isize, } impl Reader for PartialReader { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { if self.count == 0 { self.count = 1; buf[0] = 10; @@ -234,11 +234,11 @@ mod test { } struct ErroringLaterReader { - count: int, + count: isize, } impl Reader for ErroringLaterReader { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { if self.count == 0 { self.count = 1; buf[0] = 10; @@ -250,11 +250,11 @@ mod test { } struct ThreeChunkReader { - count: int, + count: isize, } impl Reader for ThreeChunkReader { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { if self.count == 0 { self.count = 1; buf[0] = 10; diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs index 40a7cce81dd..9ce8e53f6e9 100644 --- a/src/libstd/old_io/fs.rs +++ b/src/libstd/old_io/fs.rs @@ -88,7 +88,7 @@ use sys_common; pub struct File { fd: fs_imp::FileDesc, path: Path, - last_nread: int, + last_nread: isize, } impl sys_common::AsInner<fs_imp::FileDesc> for File { @@ -472,14 +472,14 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { #[deprecated(since = "1.0.0", reason = "replaced with std::fs::set_permissions")] #[unstable(feature = "old_io")] pub fn chmod(path: &Path, mode: old_io::FilePermission) -> IoResult<()> { - fs_imp::chmod(path, mode.bits() as uint) + fs_imp::chmod(path, mode.bits() as usize) .update_err("couldn't chmod path", |e| format!("{}; path={}; mode={:?}", e, path.display(), mode)) } /// Change the user and group owners of a file at the specified path. #[unstable(feature = "old_fs")] -pub fn chown(path: &Path, uid: int, gid: int) -> IoResult<()> { +pub fn chown(path: &Path, uid: isize, gid: isize) -> IoResult<()> { fs_imp::chown(path, uid, gid) .update_err("couldn't chown path", |e| format!("{}; path={}; uid={}; gid={}", e, path.display(), uid, gid)) @@ -541,7 +541,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> { /// new directory at the provided `path`, or if the directory already exists. #[unstable(feature = "old_fs")] pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> { - fs_imp::mkdir(path, mode.bits() as uint) + fs_imp::mkdir(path, mode.bits() as usize) .update_err("couldn't create directory", |e| format!("{}; path={}; mode={}", e, path.display(), mode)) } @@ -773,7 +773,7 @@ pub fn change_file_times(path: &Path, atime: u64, mtime: u64) -> IoResult<()> { } impl Reader for File { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { fn update_err<T>(result: IoResult<T>, file: &File) -> IoResult<T> { result.update_err("couldn't read file", |e| format!("{}; path={}", @@ -784,10 +784,10 @@ impl Reader for File { match result { Ok(read) => { - self.last_nread = read as int; + self.last_nread = read as isize; match read { 0 => update_err(Err(standard_error(old_io::EndOfFile)), self), - _ => Ok(read as uint) + _ => Ok(read as usize) } }, Err(e) => Err(e) @@ -1227,8 +1227,8 @@ mod test { let stem = f.filestem_str().unwrap(); let root = stem.as_bytes()[0] - b'0'; let name = stem.as_bytes()[1] - b'0'; - assert!(cur[root as uint] < name); - cur[root as uint] = name; + assert!(cur[root as usize] < name); + cur[root as usize] = name; } check!(rmdir_recursive(dir)); diff --git a/src/libstd/old_io/mem.rs b/src/libstd/old_io/mem.rs index d877a60b079..b84515c62f6 100644 --- a/src/libstd/old_io/mem.rs +++ b/src/libstd/old_io/mem.rs @@ -20,9 +20,9 @@ use old_io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult}; use slice; use vec::Vec; -const BUF_CAPACITY: uint = 128; +const BUF_CAPACITY: usize = 128; -fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> { +fn combine(seek: SeekStyle, cur: usize, end: usize, offset: i64) -> IoResult<u64> { // compute offset as signed and clamp to prevent overflow let pos = match seek { old_io::SeekSet => 0, @@ -82,7 +82,7 @@ impl MemWriter { /// Create a new `MemWriter`, allocating at least `n` bytes for /// the internal buffer. #[inline] - pub fn with_capacity(n: uint) -> MemWriter { + pub fn with_capacity(n: usize) -> MemWriter { MemWriter::from_vec(Vec::with_capacity(n)) } /// Create a new `MemWriter` that will append to an existing `Vec`. @@ -125,7 +125,7 @@ impl Writer for MemWriter { /// ``` pub struct MemReader { buf: Vec<u8>, - pos: uint + pos: usize } impl MemReader { @@ -160,7 +160,7 @@ impl MemReader { impl Reader for MemReader { #[inline] - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { if self.eof() { return Err(old_io::standard_error(old_io::EndOfFile)) } let write_len = min(buf.len(), self.buf.len() - self.pos); @@ -184,7 +184,7 @@ impl Seek for MemReader { #[inline] fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { let new = try!(combine(style, self.pos, self.buf.len(), pos)); - self.pos = new as uint; + self.pos = new as usize; Ok(()) } } @@ -200,12 +200,12 @@ impl Buffer for MemReader { } #[inline] - fn consume(&mut self, amt: uint) { self.pos += amt; } + fn consume(&mut self, amt: usize) { self.pos += amt; } } impl<'a> Reader for &'a [u8] { #[inline] - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { if self.is_empty() { return Err(old_io::standard_error(old_io::EndOfFile)); } let write_len = min(buf.len(), self.len()); @@ -232,7 +232,7 @@ impl<'a> Buffer for &'a [u8] { } #[inline] - fn consume(&mut self, amt: uint) { + fn consume(&mut self, amt: usize) { *self = &self[amt..]; } } @@ -259,7 +259,7 @@ impl<'a> Buffer for &'a [u8] { /// ``` pub struct BufWriter<'a> { buf: &'a mut [u8], - pos: uint + pos: usize } impl<'a> BufWriter<'a> { @@ -309,7 +309,7 @@ impl<'a> Seek for BufWriter<'a> { #[inline] fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { let new = try!(combine(style, self.pos, self.buf.len(), pos)); - self.pos = min(new as uint, self.buf.len()); + self.pos = min(new as usize, self.buf.len()); Ok(()) } } @@ -330,7 +330,7 @@ impl<'a> Seek for BufWriter<'a> { /// ``` pub struct BufReader<'a> { buf: &'a [u8], - pos: uint + pos: usize } impl<'a> BufReader<'a> { @@ -352,7 +352,7 @@ impl<'a> BufReader<'a> { impl<'a> Reader for BufReader<'a> { #[inline] - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { if self.eof() { return Err(old_io::standard_error(old_io::EndOfFile)) } let write_len = min(buf.len(), self.buf.len() - self.pos); @@ -376,7 +376,7 @@ impl<'a> Seek for BufReader<'a> { #[inline] fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { let new = try!(combine(style, self.pos, self.buf.len(), pos)); - self.pos = new as uint; + self.pos = new as usize; Ok(()) } } @@ -392,7 +392,7 @@ impl<'a> Buffer for BufReader<'a> { } #[inline] - fn consume(&mut self, amt: uint) { self.pos += amt; } + fn consume(&mut self, amt: usize) { self.pos += amt; } } #[cfg(test)] @@ -663,7 +663,7 @@ mod test { assert_eq!(buf, b); } - fn do_bench_mem_writer(b: &mut Bencher, times: uint, len: uint) { + fn do_bench_mem_writer(b: &mut Bencher, times: usize, len: usize) { let src: Vec<u8> = repeat(5).take(len).collect(); b.bytes = (times * len) as u64; diff --git a/src/libstd/old_io/mod.rs b/src/libstd/old_io/mod.rs index ac908c529dc..1bbd602b18a 100644 --- a/src/libstd/old_io/mod.rs +++ b/src/libstd/old_io/mod.rs @@ -326,7 +326,7 @@ pub mod test; /// The default buffer size for various I/O operations // libuv recommends 64k buffers to maximize throughput // https://groups.google.com/forum/#!topic/libuv/oQO1HJAIDdA -const DEFAULT_BUF_SIZE: uint = 1024 * 64; +const DEFAULT_BUF_SIZE: usize = 1024 * 64; /// A convenient typedef of the return value of any I/O action. pub type IoResult<T> = Result<T, IoError>; @@ -441,7 +441,7 @@ pub enum IoErrorKind { /// /// The payload contained as part of this variant is the number of bytes /// which are known to have been successfully written. - ShortWrite(uint), + ShortWrite(usize), /// The Reader returned 0 bytes from `read()` too many times. NoProgress, } @@ -483,7 +483,7 @@ impl<T> UpdateIoError for IoResult<T> { } } -static NO_PROGRESS_LIMIT: uint = 1000; +static NO_PROGRESS_LIMIT: usize = 1000; /// A trait for objects which are byte-oriented streams. Readers are defined by /// one method, `read`. This function will block until data is available, @@ -511,7 +511,7 @@ pub trait Reader { /// /// When implementing this method on a new Reader, you are strongly encouraged /// not to return 0 if you can avoid it. - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>; + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize>; // Convenient helper methods based on the above methods @@ -526,7 +526,7 @@ pub trait Reader { /// /// If an error occurs at any point, that error is returned, and no further /// bytes are read. - fn read_at_least(&mut self, min: uint, buf: &mut [u8]) -> IoResult<uint> { + fn read_at_least(&mut self, min: usize, buf: &mut [u8]) -> IoResult<usize> { if min > buf.len() { return Err(IoError { detail: Some(String::from_str("the buffer is too short")), @@ -570,7 +570,7 @@ pub trait Reader { /// /// If an error occurs during this I/O operation, then it is returned /// as `Err(IoError)`. See `read()` for more details. - fn push(&mut self, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> { + fn push(&mut self, len: usize, buf: &mut Vec<u8>) -> IoResult<usize> { let start_len = buf.len(); buf.reserve(len); @@ -594,7 +594,7 @@ pub trait Reader { /// /// If an error occurs at any point, that error is returned, and no further /// bytes are read. - fn push_at_least(&mut self, min: uint, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> { + fn push_at_least(&mut self, min: usize, len: usize, buf: &mut Vec<u8>) -> IoResult<usize> { if min > len { return Err(IoError { detail: Some(String::from_str("the buffer is too short")), @@ -629,7 +629,7 @@ pub trait Reader { /// have already been consumed from the underlying reader, and they are lost /// (not returned as part of the error). If this is unacceptable, then it is /// recommended to use the `push_at_least` or `read` methods. - fn read_exact(&mut self, len: uint) -> IoResult<Vec<u8>> { + fn read_exact(&mut self, len: usize) -> IoResult<Vec<u8>> { let mut buf = Vec::with_capacity(len); match self.push_at_least(len, len, &mut buf) { Ok(_) => Ok(buf), @@ -679,7 +679,7 @@ pub trait Reader { /// Reads `n` little-endian unsigned integer bytes. /// /// `n` must be between 1 and 8, inclusive. - fn read_le_uint_n(&mut self, nbytes: uint) -> IoResult<u64> { + fn read_le_uint_n(&mut self, nbytes: usize) -> IoResult<u64> { assert!(nbytes > 0 && nbytes <= 8); let mut val = 0; @@ -696,14 +696,14 @@ pub trait Reader { /// Reads `n` little-endian signed integer bytes. /// /// `n` must be between 1 and 8, inclusive. - fn read_le_int_n(&mut self, nbytes: uint) -> IoResult<i64> { + fn read_le_int_n(&mut self, nbytes: usize) -> IoResult<i64> { self.read_le_uint_n(nbytes).map(|i| extend_sign(i, nbytes)) } /// Reads `n` big-endian unsigned integer bytes. /// /// `n` must be between 1 and 8, inclusive. - fn read_be_uint_n(&mut self, nbytes: uint) -> IoResult<u64> { + fn read_be_uint_n(&mut self, nbytes: usize) -> IoResult<u64> { assert!(nbytes > 0 && nbytes <= 8); let mut val = 0; @@ -718,36 +718,36 @@ pub trait Reader { /// Reads `n` big-endian signed integer bytes. /// /// `n` must be between 1 and 8, inclusive. - fn read_be_int_n(&mut self, nbytes: uint) -> IoResult<i64> { + fn read_be_int_n(&mut self, nbytes: usize) -> IoResult<i64> { self.read_be_uint_n(nbytes).map(|i| extend_sign(i, nbytes)) } /// Reads a little-endian unsigned integer. /// /// The number of bytes returned is system-dependent. - fn read_le_uint(&mut self) -> IoResult<uint> { - self.read_le_uint_n(usize::BYTES as usize).map(|i| i as uint) + fn read_le_uint(&mut self) -> IoResult<usize> { + self.read_le_uint_n(usize::BYTES as usize).map(|i| i as usize) } /// Reads a little-endian integer. /// /// The number of bytes returned is system-dependent. - fn read_le_int(&mut self) -> IoResult<int> { - self.read_le_int_n(isize::BYTES as usize).map(|i| i as int) + fn read_le_int(&mut self) -> IoResult<isize> { + self.read_le_int_n(isize::BYTES as usize).map(|i| i as isize) } /// Reads a big-endian unsigned integer. /// /// The number of bytes returned is system-dependent. - fn read_be_uint(&mut self) -> IoResult<uint> { - self.read_be_uint_n(usize::BYTES as usize).map(|i| i as uint) + fn read_be_uint(&mut self) -> IoResult<usize> { + self.read_be_uint_n(usize::BYTES as usize).map(|i| i as usize) } /// Reads a big-endian integer. /// /// The number of bytes returned is system-dependent. - fn read_be_int(&mut self) -> IoResult<int> { - self.read_be_int_n(isize::BYTES as usize).map(|i| i as int) + fn read_be_int(&mut self) -> IoResult<isize> { + self.read_be_int_n(isize::BYTES as usize).map(|i| i as isize) } /// Reads a big-endian `u64`. @@ -919,14 +919,14 @@ impl<T: Reader> BytesReader for T { } impl<'a> Reader for Box<Reader+'a> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let reader: &mut Reader = &mut **self; reader.read(buf) } } impl<'a> Reader for &'a mut (Reader+'a) { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { (*self).read(buf) } + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { (*self).read(buf) } } /// Returns a slice of `v` between `start` and `end`. @@ -940,13 +940,13 @@ impl<'a> Reader for &'a mut (Reader+'a) { /// `start` > `end`. // Private function here because we aren't sure if we want to expose this as // API yet. If so, it should be a method on Vec. -unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] { +unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: usize, end: usize) -> &'a mut [T] { use slice; assert!(start <= end); assert!(end <= v.capacity()); slice::from_raw_parts_mut( - v.as_mut_ptr().offset(start as int), + v.as_mut_ptr().offset(start as isize), end - start ) } @@ -980,15 +980,15 @@ pub struct RefReader<'a, R:'a> { } impl<'a, R: Reader> Reader for RefReader<'a, R> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.inner.read(buf) } + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.read(buf) } } impl<'a, R: Buffer> Buffer for RefReader<'a, R> { fn fill_buf(&mut self) -> IoResult<&[u8]> { self.inner.fill_buf() } - fn consume(&mut self, amt: uint) { self.inner.consume(amt) } + fn consume(&mut self, amt: usize) { self.inner.consume(amt) } } -fn extend_sign(val: u64, nbytes: uint) -> i64 { +fn extend_sign(val: u64, nbytes: usize) -> i64 { let shift = (8 - nbytes) * 8; (val << shift) as i64 >> shift } @@ -1095,39 +1095,39 @@ pub trait Writer { self.write_all(&buf[..n]) } - /// Write the result of passing n through `int::to_str_bytes`. + /// Write the result of passing n through `isize::to_str_bytes`. #[inline] - fn write_int(&mut self, n: int) -> IoResult<()> { + fn write_int(&mut self, n: isize) -> IoResult<()> { write!(self, "{}", n) } - /// Write the result of passing n through `uint::to_str_bytes`. + /// Write the result of passing n through `usize::to_str_bytes`. #[inline] - fn write_uint(&mut self, n: uint) -> IoResult<()> { + fn write_uint(&mut self, n: usize) -> IoResult<()> { write!(self, "{}", n) } - /// Write a little-endian uint (number of bytes depends on system). + /// Write a little-endian usize (number of bytes depends on system). #[inline] - fn write_le_uint(&mut self, n: uint) -> IoResult<()> { + fn write_le_uint(&mut self, n: usize) -> IoResult<()> { extensions::u64_to_le_bytes(n as u64, usize::BYTES as usize, |v| self.write_all(v)) } - /// Write a little-endian int (number of bytes depends on system). + /// Write a little-endian isize (number of bytes depends on system). #[inline] - fn write_le_int(&mut self, n: int) -> IoResult<()> { + fn write_le_int(&mut self, n: isize) -> IoResult<()> { extensions::u64_to_le_bytes(n as u64, isize::BYTES as usize, |v| self.write_all(v)) } - /// Write a big-endian uint (number of bytes depends on system). + /// Write a big-endian usize (number of bytes depends on system). #[inline] - fn write_be_uint(&mut self, n: uint) -> IoResult<()> { + fn write_be_uint(&mut self, n: usize) -> IoResult<()> { extensions::u64_to_be_bytes(n as u64, usize::BYTES as usize, |v| self.write_all(v)) } - /// Write a big-endian int (number of bytes depends on system). + /// Write a big-endian isize (number of bytes depends on system). #[inline] - fn write_be_int(&mut self, n: int) -> IoResult<()> { + fn write_be_int(&mut self, n: isize) -> IoResult<()> { extensions::u64_to_be_bytes(n as u64, isize::BYTES as usize, |v| self.write_all(v)) } @@ -1409,7 +1409,7 @@ pub trait Buffer: Reader { /// Tells this buffer that `amt` bytes have been consumed from the buffer, /// so they should no longer be returned in calls to `read`. - fn consume(&mut self, amt: uint); + fn consume(&mut self, amt: usize); /// Reads the next line of input, interpreted as a sequence of UTF-8 /// encoded Unicode codepoints. If a newline is encountered, then the @@ -1870,8 +1870,8 @@ mod tests { #[derive(Clone, PartialEq, Debug)] enum BadReaderBehavior { - GoodBehavior(uint), - BadBehavior(uint) + GoodBehavior(usize), + BadBehavior(usize) } struct BadReader<T> { @@ -1886,7 +1886,7 @@ mod tests { } impl<T: Reader> Reader for BadReader<T> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let BadReader { ref mut behavior, ref mut r } = *self; loop { if behavior.is_empty() { diff --git a/src/libstd/old_io/net/addrinfo.rs b/src/libstd/old_io/net/addrinfo.rs index 2b7506b5c34..0413a89ac4f 100644 --- a/src/libstd/old_io/net/addrinfo.rs +++ b/src/libstd/old_io/net/addrinfo.rs @@ -63,19 +63,19 @@ pub enum Protocol { /// `man -s 3 getaddrinfo` #[derive(Copy, Debug)] pub struct Hint { - pub family: uint, + pub family: usize, pub socktype: Option<SocketType>, pub protocol: Option<Protocol>, - pub flags: uint, + pub flags: usize, } #[derive(Copy, Debug)] pub struct Info { pub address: SocketAddr, - pub family: uint, + pub family: usize, pub socktype: Option<SocketType>, pub protocol: Option<Protocol>, - pub flags: uint, + pub flags: usize, } /// Easy name resolution. Given a hostname, returns the list of IP addresses for diff --git a/src/libstd/old_io/net/ip.rs b/src/libstd/old_io/net/ip.rs index f7953ac51b8..ba3578f7425 100644 --- a/src/libstd/old_io/net/ip.rs +++ b/src/libstd/old_io/net/ip.rs @@ -82,7 +82,7 @@ impl fmt::Display for SocketAddr { struct Parser<'a> { // parsing as ASCII, so can use byte array s: &'a [u8], - pos: uint, + pos: usize, } impl<'a> Parser<'a> { @@ -256,7 +256,7 @@ impl<'a> Parser<'a> { Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7]) } - fn read_groups(p: &mut Parser, groups: &mut [u16; 8], limit: uint) -> (uint, bool) { + fn read_groups(p: &mut Parser, groups: &mut [u16; 8], limit: usize) -> (usize, bool) { let mut i = 0; while i < limit { if i < limit - 1 { diff --git a/src/libstd/old_io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs index f9e5ae71e12..2f3cf3d84d0 100644 --- a/src/libstd/old_io/net/pipe.rs +++ b/src/libstd/old_io/net/pipe.rs @@ -150,7 +150,7 @@ impl Clone for UnixStream { } impl Reader for UnixStream { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.read(buf) } } diff --git a/src/libstd/old_io/net/tcp.rs b/src/libstd/old_io/net/tcp.rs index 75f786f0bb1..d55d9ca11d1 100644 --- a/src/libstd/old_io/net/tcp.rs +++ b/src/libstd/old_io/net/tcp.rs @@ -122,7 +122,7 @@ impl TcpStream { /// this connection. Otherwise, the keepalive timeout will be set to the /// specified time, in seconds. #[unstable(feature = "io")] - pub fn set_keepalive(&mut self, delay_in_seconds: Option<uint>) -> IoResult<()> { + pub fn set_keepalive(&mut self, delay_in_seconds: Option<usize>) -> IoResult<()> { self.inner.set_keepalive(delay_in_seconds) } @@ -257,7 +257,7 @@ impl Clone for TcpStream { } impl Reader for TcpStream { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.read(buf) } } @@ -789,12 +789,12 @@ mod test { #[test] fn multiple_connect_interleaved_greedy_schedule_ip4() { let addr = next_test_ip4(); - static MAX: int = 10; + static MAX: isize = 10; let acceptor = TcpListener::bind(addr).listen(); let _t = thread::spawn(move|| { let mut acceptor = acceptor; - for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) { + for (i, stream) in acceptor.incoming().enumerate().take(MAX as usize) { // Start another task to handle the connection let _t = thread::spawn(move|| { let mut stream = stream; @@ -808,7 +808,7 @@ mod test { connect(0, addr); - fn connect(i: int, addr: SocketAddr) { + fn connect(i: isize, addr: SocketAddr) { if i == MAX { return } let _t = thread::spawn(move|| { @@ -825,12 +825,12 @@ mod test { #[test] fn multiple_connect_interleaved_greedy_schedule_ip6() { let addr = next_test_ip6(); - static MAX: int = 10; + static MAX: isize = 10; let acceptor = TcpListener::bind(addr).listen(); let _t = thread::spawn(move|| { let mut acceptor = acceptor; - for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) { + for (i, stream) in acceptor.incoming().enumerate().take(MAX as usize) { // Start another task to handle the connection let _t = thread::spawn(move|| { let mut stream = stream; @@ -844,7 +844,7 @@ mod test { connect(0, addr); - fn connect(i: int, addr: SocketAddr) { + fn connect(i: isize, addr: SocketAddr) { if i == MAX { return } let _t = thread::spawn(move|| { @@ -860,13 +860,13 @@ mod test { #[test] fn multiple_connect_interleaved_lazy_schedule_ip4() { - static MAX: int = 10; + static MAX: isize = 10; let addr = next_test_ip4(); let acceptor = TcpListener::bind(addr).listen(); let _t = thread::spawn(move|| { let mut acceptor = acceptor; - for stream in acceptor.incoming().take(MAX as uint) { + for stream in acceptor.incoming().take(MAX as usize) { // Start another task to handle the connection let _t = thread::spawn(move|| { let mut stream = stream; @@ -880,7 +880,7 @@ mod test { connect(0, addr); - fn connect(i: int, addr: SocketAddr) { + fn connect(i: isize, addr: SocketAddr) { if i == MAX { return } let _t = thread::spawn(move|| { @@ -896,13 +896,13 @@ mod test { #[test] fn multiple_connect_interleaved_lazy_schedule_ip6() { - static MAX: int = 10; + static MAX: isize = 10; let addr = next_test_ip6(); let acceptor = TcpListener::bind(addr).listen(); let _t = thread::spawn(move|| { let mut acceptor = acceptor; - for stream in acceptor.incoming().take(MAX as uint) { + for stream in acceptor.incoming().take(MAX as usize) { // Start another task to handle the connection let _t = thread::spawn(move|| { let mut stream = stream; @@ -916,7 +916,7 @@ mod test { connect(0, addr); - fn connect(i: int, addr: SocketAddr) { + fn connect(i: isize, addr: SocketAddr) { if i == MAX { return } let _t = thread::spawn(move|| { diff --git a/src/libstd/old_io/net/udp.rs b/src/libstd/old_io/net/udp.rs index 3aa811974b3..196447d71ef 100644 --- a/src/libstd/old_io/net/udp.rs +++ b/src/libstd/old_io/net/udp.rs @@ -73,7 +73,7 @@ impl UdpSocket { /// Receives data from the socket. On success, returns the number of bytes /// read and the address from whence the data came. - pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)> { + pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(usize, SocketAddr)> { self.inner.recv_from(buf) } @@ -113,13 +113,13 @@ impl UdpSocket { /// Sets the multicast TTL #[unstable(feature = "io")] - pub fn set_multicast_ttl(&mut self, ttl: int) -> IoResult<()> { + pub fn set_multicast_ttl(&mut self, ttl: isize) -> IoResult<()> { self.inner.multicast_time_to_live(ttl) } /// Sets this socket's TTL #[unstable(feature = "io")] - pub fn set_ttl(&mut self, ttl: int) -> IoResult<()> { + pub fn set_ttl(&mut self, ttl: isize) -> IoResult<()> { self.inner.time_to_live(ttl) } diff --git a/src/libstd/old_io/pipe.rs b/src/libstd/old_io/pipe.rs index 0b555e2f0ff..26f24600479 100644 --- a/src/libstd/old_io/pipe.rs +++ b/src/libstd/old_io/pipe.rs @@ -100,7 +100,7 @@ impl Clone for PipeStream { } impl Reader for PipeStream { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.read(buf) } } diff --git a/src/libstd/old_io/process.rs b/src/libstd/old_io/process.rs index d7ede451fb8..45bf5a58ec2 100644 --- a/src/libstd/old_io/process.rs +++ b/src/libstd/old_io/process.rs @@ -41,16 +41,16 @@ use thread; /// Signal a process to exit, without forcibly killing it. Corresponds to /// SIGTERM on unix platforms. -#[cfg(windows)] pub const PleaseExitSignal: int = 15; +#[cfg(windows)] pub const PleaseExitSignal: isize = 15; /// Signal a process to exit immediately, forcibly killing it. Corresponds to /// SIGKILL on unix platforms. -#[cfg(windows)] pub const MustDieSignal: int = 9; +#[cfg(windows)] pub const MustDieSignal: isize = 9; /// Signal a process to exit, without forcibly killing it. Corresponds to /// SIGTERM on unix platforms. -#[cfg(not(windows))] pub const PleaseExitSignal: int = libc::SIGTERM as int; +#[cfg(not(windows))] pub const PleaseExitSignal: isize = libc::SIGTERM as isize; /// Signal a process to exit immediately, forcibly killing it. Corresponds to /// SIGKILL on unix platforms. -#[cfg(not(windows))] pub const MustDieSignal: int = libc::SIGKILL as int; +#[cfg(not(windows))] pub const MustDieSignal: isize = libc::SIGKILL as isize; /// Representation of a running or exited child process. /// @@ -80,7 +80,7 @@ pub struct Process { exit_code: Option<ProcessExit>, /// Manually delivered signal - exit_signal: Option<int>, + exit_signal: Option<isize>, /// Deadline after which wait() will return deadline: u64, @@ -186,8 +186,8 @@ pub struct Command { stdin: StdioContainer, stdout: StdioContainer, stderr: StdioContainer, - uid: Option<uint>, - gid: Option<uint>, + uid: Option<usize>, + gid: Option<usize>, detach: bool, } @@ -321,14 +321,14 @@ impl Command { /// the child process. Setting this value on windows will cause the spawn to /// fail. Failure in the `setuid` call on unix will also cause the spawn to /// fail. - pub fn uid<'a>(&'a mut self, id: uint) -> &'a mut Command { + pub fn uid<'a>(&'a mut self, id: usize) -> &'a mut Command { self.uid = Some(id); self } /// Similar to `uid`, but sets the group id of the child process. This has /// the same semantics as the `uid` field. - pub fn gid<'a>(&'a mut self, id: uint) -> &'a mut Command { + pub fn gid<'a>(&'a mut self, id: usize) -> &'a mut Command { self.gid = Some(id); self } @@ -458,10 +458,10 @@ impl sys::process::ProcessConfig<EnvKey, CString> for Command { fn cwd(&self) -> Option<&CString> { self.cwd.as_ref() } - fn uid(&self) -> Option<uint> { + fn uid(&self) -> Option<usize> { self.uid.clone() } - fn gid(&self) -> Option<uint> { + fn gid(&self) -> Option<usize> { self.gid.clone() } fn detach(&self) -> bool { @@ -507,10 +507,10 @@ pub enum StdioContainer { #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum ProcessExit { /// Normal termination with an exit status. - ExitStatus(int), + ExitStatus(isize), /// Termination by signal, with the signal number. - ExitSignal(int), + ExitSignal(isize), } #[stable(feature = "rust1", since = "1.0.0")] @@ -533,7 +533,7 @@ impl ProcessExit { /// Checks whether this ProcessExit matches the given exit status. /// Termination by signal will never match an exit code. - pub fn matches_exit_status(&self, wanted: int) -> bool { + pub fn matches_exit_status(&self, wanted: isize) -> bool { *self == ExitStatus(wanted) } } @@ -549,7 +549,7 @@ impl Process { /// process. Note, though, that on some platforms signals will continue to /// be successfully delivered if the child has exited, but not yet been /// reaped. - pub fn kill(id: libc::pid_t, signal: int) -> IoResult<()> { + pub fn kill(id: libc::pid_t, signal: isize) -> IoResult<()> { unsafe { ProcessImp::killpid(id, signal) } } @@ -571,7 +571,7 @@ impl Process { /// # Errors /// /// If the signal delivery fails, the corresponding error is returned. - pub fn signal(&mut self, signal: int) -> IoResult<()> { + pub fn signal(&mut self, signal: isize) -> IoResult<()> { #[cfg(unix)] fn collect_status(p: &mut Process) { // On Linux (and possibly other unices), a process that has exited will // continue to accept signals because it is "defunct". The delivery of @@ -888,8 +888,8 @@ mod tests { use libc; let mut p = Command::new("/bin/sh") .arg("-c").arg("true") - .uid(unsafe { libc::getuid() as uint }) - .gid(unsafe { libc::getgid() as uint }) + .uid(unsafe { libc::getuid() as usize }) + .gid(unsafe { libc::getgid() as usize }) .spawn().unwrap(); assert!(p.wait().unwrap().success()); } diff --git a/src/libstd/old_io/result.rs b/src/libstd/old_io/result.rs index 9dcb487cdb0..cda19f8ae84 100644 --- a/src/libstd/old_io/result.rs +++ b/src/libstd/old_io/result.rs @@ -35,7 +35,7 @@ impl<W: Writer> Writer for IoResult<W> { } impl<R: Reader> Reader for IoResult<R> { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { match *self { Ok(ref mut reader) => reader.read(buf), Err(ref e) => Err(e.clone()), diff --git a/src/libstd/old_io/stdio.rs b/src/libstd/old_io/stdio.rs index 90d27084911..b4924c7b78b 100644 --- a/src/libstd/old_io/stdio.rs +++ b/src/libstd/old_io/stdio.rs @@ -182,7 +182,7 @@ impl StdinReader { } impl Reader for StdinReader { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.inner.lock().unwrap().0.read(buf) } @@ -190,11 +190,11 @@ impl Reader for StdinReader { // read more than once and we don't want those calls to interleave (or // incur the costs of repeated locking). - fn read_at_least(&mut self, min: uint, buf: &mut [u8]) -> IoResult<uint> { + fn read_at_least(&mut self, min: usize, buf: &mut [u8]) -> IoResult<usize> { self.inner.lock().unwrap().0.read_at_least(min, buf) } - fn push_at_least(&mut self, min: uint, len: uint, buf: &mut Vec<u8>) -> IoResult<uint> { + fn push_at_least(&mut self, min: usize, len: usize, buf: &mut Vec<u8>) -> IoResult<usize> { self.inner.lock().unwrap().0.push_at_least(min, len, buf) } @@ -202,11 +202,11 @@ impl Reader for StdinReader { self.inner.lock().unwrap().0.read_to_end() } - fn read_le_uint_n(&mut self, nbytes: uint) -> IoResult<u64> { + fn read_le_uint_n(&mut self, nbytes: usize) -> IoResult<u64> { self.inner.lock().unwrap().0.read_le_uint_n(nbytes) } - fn read_be_uint_n(&mut self, nbytes: uint) -> IoResult<u64> { + fn read_be_uint_n(&mut self, nbytes: usize) -> IoResult<u64> { self.inner.lock().unwrap().0.read_be_uint_n(nbytes) } } @@ -410,16 +410,16 @@ impl StdReader { } impl Reader for StdReader { - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let ret = match self.inner { TTY(ref mut tty) => { // Flush the task-local stdout so that weird issues like a // print!'d prompt not being shown until after the user hits // enter. flush(); - tty.read(buf).map(|i| i as uint) + tty.read(buf).map(|i| i as usize) }, - File(ref mut file) => file.read(buf).map(|i| i as uint), + File(ref mut file) => file.read(buf).map(|i| i as usize), }; match ret { // When reading a piped stdin, libuv will return 0-length reads when @@ -452,7 +452,7 @@ impl StdWriter { /// /// This function will return an error if the output stream is not actually /// connected to a TTY instance, or if querying the TTY instance fails. - pub fn winsize(&mut self) -> IoResult<(int, int)> { + pub fn winsize(&mut self) -> IoResult<(isize, isize)> { match self.inner { TTY(ref mut tty) => { tty.get_winsize() diff --git a/src/libstd/old_io/tempfile.rs b/src/libstd/old_io/tempfile.rs index c0f6ddaaef7..bf9b79ce65a 100644 --- a/src/libstd/old_io/tempfile.rs +++ b/src/libstd/old_io/tempfile.rs @@ -89,7 +89,7 @@ const NUM_RETRIES: u32 = 1 << 31; // be enough to dissuade an attacker from trying to preemptively create names // of that length, but not so huge that we unnecessarily drain the random number // generator of entropy. -const NUM_RAND_CHARS: uint = 12; +const NUM_RAND_CHARS: usize = 12; impl TempDir { /// Attempts to make a temporary directory inside of `tmpdir` whose name diff --git a/src/libstd/old_io/util.rs b/src/libstd/old_io/util.rs index 1f782b6f221..604099f1178 100644 --- a/src/libstd/old_io/util.rs +++ b/src/libstd/old_io/util.rs @@ -22,7 +22,7 @@ use slice::bytes::MutableByteVector; #[deprecated(since = "1.0.0", reason = "use std::io::Take")] #[unstable(feature = "old_io")] pub struct LimitReader<R> { - limit: uint, + limit: usize, inner: R } @@ -32,7 +32,7 @@ impl<R: Reader> LimitReader<R> { /// Creates a new `LimitReader` #[deprecated(since = "1.0.0", reason = "use std::io's take method instead")] #[unstable(feature = "old_io")] - pub fn new(r: R, limit: uint) -> LimitReader<R> { + pub fn new(r: R, limit: usize) -> LimitReader<R> { LimitReader { limit: limit, inner: r } } @@ -46,13 +46,13 @@ impl<R: Reader> LimitReader<R> { /// /// The reader may reach EOF after reading fewer bytes than indicated by /// this method if the underlying reader reaches EOF. - pub fn limit(&self) -> uint { self.limit } + pub fn limit(&self) -> usize { self.limit } } #[deprecated(since = "1.0.0", reason = "use std::io's take method instead")] #[unstable(feature = "old_io")] impl<R: Reader> Reader for LimitReader<R> { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { if self.limit == 0 { return Err(old_io::standard_error(old_io::EndOfFile)); } @@ -80,7 +80,7 @@ impl<R: Buffer> Buffer for LimitReader<R> { } } - fn consume(&mut self, amt: uint) { + fn consume(&mut self, amt: usize) { // Don't let callers reset the limit by passing an overlarge value let amt = cmp::min(amt, self.limit); self.limit -= amt; @@ -112,7 +112,7 @@ pub struct ZeroReader; #[unstable(feature = "old_io")] impl Reader for ZeroReader { #[inline] - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { buf.set_memory(0); Ok(buf.len()) } @@ -126,7 +126,7 @@ impl Buffer for ZeroReader { Ok(&DATA) } - fn consume(&mut self, _amt: uint) {} + fn consume(&mut self, _amt: usize) {} } /// A `Reader` which is always at EOF, like /dev/null. @@ -139,7 +139,7 @@ pub struct NullReader; #[unstable(feature = "old_io")] impl Reader for NullReader { #[inline] - fn read(&mut self, _buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, _buf: &mut [u8]) -> old_io::IoResult<usize> { Err(old_io::standard_error(old_io::EndOfFile)) } } @@ -150,7 +150,7 @@ impl Buffer for NullReader { fn fill_buf<'a>(&'a mut self) -> old_io::IoResult<&'a [u8]> { Err(old_io::standard_error(old_io::EndOfFile)) } - fn consume(&mut self, _amt: uint) {} + fn consume(&mut self, _amt: usize) {} } /// A `Writer` which multiplexes writes to a set of `Writer`s. @@ -216,7 +216,7 @@ impl<R: Reader, I: Iterator<Item=R>> ChainedReader<I, R> { #[deprecated(since = "1.0.0", reason = "use std::io::Chain instead")] #[unstable(feature = "old_io")] impl<R: Reader, I: Iterator<Item=R>> Reader for ChainedReader<I, R> { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { loop { let err = match self.cur_reader { Some(ref mut r) => { @@ -269,7 +269,7 @@ impl<R: Reader, W: Writer> TeeReader<R, W> { #[deprecated(since = "1.0.0", reason = "use std::io::Tee instead")] #[unstable(feature = "old_io")] impl<R: Reader, W: Writer> Reader for TeeReader<R, W> { - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { self.reader.read(buf).and_then(|len| { self.writer.write_all(&mut buf[..len]).map(|()| len) }) @@ -307,7 +307,7 @@ impl<T: Iterator<Item=u8>> IterReader<T> { impl<T: Iterator<Item=u8>> Reader for IterReader<T> { #[inline] - fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<usize> { let mut len = 0; for (slot, elt) in buf.iter_mut().zip(self.iter.by_ref()) { *slot = elt; @@ -392,8 +392,8 @@ mod test { #[test] fn test_multi_writer() { - static mut writes: uint = 0; - static mut flushes: uint = 0; + static mut writes: usize = 0; + static mut flushes: usize = 0; struct TestWriter; impl Writer for TestWriter { diff --git a/src/libstd/old_path/posix.rs b/src/libstd/old_path/posix.rs index 0ab8612a7cb..67bfe2bd770 100644 --- a/src/libstd/old_path/posix.rs +++ b/src/libstd/old_path/posix.rs @@ -37,7 +37,7 @@ pub type StrComponents<'a> = #[derive(Clone)] pub struct Path { repr: Vec<u8>, // assumed to never be empty or contain NULs - sepidx: Option<uint> // index of the final separator in repr + sepidx: Option<usize> // index of the final separator in repr } /// The standard path separator character diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs index 4f367e30526..869a8127301 100644 --- a/src/libstd/old_path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -81,7 +81,7 @@ pub type Components<'a> = pub struct Path { repr: String, // assumed to never be empty prefix: Option<PathPrefix>, - sepidx: Option<uint> // index of the final separator in the non-prefix portion of repr + sepidx: Option<usize> // index of the final separator in the non-prefix portion of repr } #[stable(feature = "rust1", since = "1.0.0")] @@ -749,7 +749,7 @@ impl Path { if prefix.is_some() && comps.is_empty() { match prefix.unwrap() { DiskPrefix => { - let len = prefix_len(prefix) + is_abs as uint; + let len = prefix_len(prefix) + is_abs as usize; let mut s = String::from_str(&s[..len]); unsafe { let v = s.as_mut_vec(); @@ -764,7 +764,7 @@ impl Path { Some(s) } VerbatimDiskPrefix => { - let len = prefix_len(prefix) + is_abs as uint; + let len = prefix_len(prefix) + is_abs as usize; let mut s = String::from_str(&s[..len]); unsafe { let v = s.as_mut_vec(); @@ -838,7 +838,7 @@ impl Path { self.sepidx = idx.and_then(|x| if x < prefixlen { None } else { Some(x) }); } - fn prefix_len(&self) -> uint { + fn prefix_len(&self) -> usize { prefix_len(self.prefix) } @@ -847,7 +847,7 @@ impl Path { // end is the length of the string, normally, or the index of the final character if it is // a non-semantic trailing separator in a verbatim string. // If the prefix is considered the separator, before and after are the same. - fn sepidx_or_prefix_len(&self) -> Option<(uint,uint,uint)> { + fn sepidx_or_prefix_len(&self) -> Option<(usize,usize,usize)> { match self.sepidx { None => match self.prefix_len() { 0 => None, x => Some((x,x,self.repr.len())) }, Some(x) => { @@ -973,16 +973,16 @@ pub fn is_sep_byte_verbatim(u: &u8) -> bool { /// Prefix types for Path #[derive(Copy, PartialEq, Clone, Debug)] pub enum PathPrefix { - /// Prefix `\\?\`, uint is the length of the following component - VerbatimPrefix(uint), + /// Prefix `\\?\`, usize is the length of the following component + VerbatimPrefix(usize), /// Prefix `\\?\UNC\`, uints are the lengths of the UNC components - VerbatimUNCPrefix(uint, uint), + VerbatimUNCPrefix(usize, usize), /// Prefix `\\?\C:\` (for any alphabetic character) VerbatimDiskPrefix, - /// Prefix `\\.\`, uint is the length of the following component - DeviceNSPrefix(uint), + /// Prefix `\\.\`, usize is the length of the following component + DeviceNSPrefix(usize), /// UNC prefix `\\server\share`, uints are the lengths of the server/share - UNCPrefix(uint, uint), + UNCPrefix(usize, usize), /// Prefix `C:` for any alphabetic character DiskPrefix } @@ -1037,7 +1037,7 @@ fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> { } return None; - fn parse_two_comps(mut path: &str, f: fn(char) -> bool) -> Option<(uint, uint)> { + fn parse_two_comps(mut path: &str, f: fn(char) -> bool) -> Option<(usize, usize)> { let idx_a = match path.find(f) { None => return None, Some(x) => x @@ -1107,7 +1107,7 @@ fn prefix_is_verbatim(p: Option<PathPrefix>) -> bool { } } -fn prefix_len(p: Option<PathPrefix>) -> uint { +fn prefix_len(p: Option<PathPrefix>) -> usize { match p { None => 0, Some(VerbatimPrefix(x)) => 4 + x, diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 40aaea7aca0..2e8521cc94b 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -100,9 +100,9 @@ fn path2old(path: &path::Path) -> Path { } /// Get the number of cores available -pub fn num_cpus() -> uint { +pub fn num_cpus() -> usize { unsafe { - return rust_get_num_cpus() as uint; + return rust_get_num_cpus() as usize; } extern { @@ -110,7 +110,7 @@ pub fn num_cpus() -> uint { } } -pub const TMPBUF_SZ : uint = 1000; +pub const TMPBUF_SZ : usize = 1000; /// Returns the current working directory as a `Path`. /// @@ -592,7 +592,7 @@ pub fn last_os_error() -> String { /// Note that this is not synchronized against modifications of other threads. #[deprecated(since = "1.0.0", reason = "renamed to env::set_exit_status")] #[unstable(feature = "os")] -pub fn set_exit_status(code: int) { +pub fn set_exit_status(code: isize) { env::set_exit_status(code as i32) } @@ -600,12 +600,12 @@ pub fn set_exit_status(code: int) { /// by calling `set_exit_status`. #[deprecated(since = "1.0.0", reason = "renamed to env::get_exit_status")] #[unstable(feature = "os")] -pub fn get_exit_status() -> int { +pub fn get_exit_status() -> isize { env::get_exit_status() as isize } #[cfg(target_os = "macos")] -unsafe fn load_argc_and_argv(argc: int, +unsafe fn load_argc_and_argv(argc: isize, argv: *const *const c_char) -> Vec<Vec<u8>> { use ffi::CStr; @@ -620,7 +620,7 @@ unsafe fn load_argc_and_argv(argc: int, #[cfg(target_os = "macos")] fn real_args_as_bytes() -> Vec<Vec<u8>> { unsafe { - let (argc, argv) = (*_NSGetArgc() as int, + let (argc, argv) = (*_NSGetArgc() as isize, *_NSGetArgv() as *const *const c_char); load_argc_and_argv(argc, argv) } @@ -670,7 +670,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> { let info = objc_msgSend(klass, processInfoSel); let args = objc_msgSend(info, argumentsSel); - let cnt: int = mem::transmute(objc_msgSend(args, countSel)); + let cnt: isize = mem::transmute(objc_msgSend(args, countSel)); for i in 0..cnt { let tmp = objc_msgSend(args, objectAtSel, i); let utf_c_str: *const libc::c_char = @@ -711,11 +711,11 @@ fn real_args() -> Vec<String> { let lpCmdLine = unsafe { GetCommandLineW() }; let szArgList = unsafe { CommandLineToArgvW(lpCmdLine, lpArgCount) }; - let args: Vec<_> = (0..nArgs as uint).map(|i| unsafe { + let args: Vec<_> = (0..nArgs as usize).map(|i| unsafe { // Determine the length of this argument. - let ptr = *szArgList.offset(i as int); + let ptr = *szArgList.offset(i as isize); let mut len = 0; - while *ptr.offset(len as int) != 0 { len += 1; } + while *ptr.offset(len as isize) != 0 { len += 1; } // Push it onto the list. let ptr = ptr as *const u16; @@ -796,7 +796,7 @@ extern { /// Returns the page size of the current architecture in bytes. #[deprecated(since = "1.0.0", reason = "renamed to env::page_size")] #[unstable(feature = "os")] -pub fn page_size() -> uint { +pub fn page_size() -> usize { sys::os::page_size() } @@ -810,7 +810,7 @@ pub fn page_size() -> uint { /// let it leave scope by accident if you want it to stick around. pub struct MemoryMap { data: *mut u8, - len: uint, + len: usize, kind: MemoryMapKind, } @@ -846,9 +846,9 @@ pub enum MapOption { /// Create a memory mapping for a file with a given fd. #[cfg(not(windows))] MapFd(c_int), - /// When using `MapFd`, the start of the map is `uint` bytes from the start + /// When using `MapFd`, the start of the map is `usize` bytes from the start /// of the file. - MapOffset(uint), + MapOffset(usize), /// On POSIX, this can be used to specify the default flags passed to /// `mmap`. By default it uses `MAP_PRIVATE` and, if not using `MapFd`, /// `MAP_ANON`. This will override both of those. This is platform-specific @@ -880,7 +880,7 @@ pub enum MapError { /// Not all platforms obey this, but this wrapper does. ErrZeroLength, /// Unrecognized error. The inner value is the unrecognized errno. - ErrUnknown(int), + ErrUnknown(isize), /// # The following are Windows-specific /// /// Unsupported combination of protection flags @@ -940,7 +940,7 @@ impl Error for MapError { } // Round up `from` to be divisible by `to` -fn round_up(from: uint, to: uint) -> uint { +fn round_up(from: usize, to: usize) -> usize { let r = if from % to == 0 { from } else { @@ -958,7 +958,7 @@ impl MemoryMap { /// Create a new mapping with the given `options`, at least `min_len` bytes /// long. `min_len` must be greater than zero; see the note on /// `ErrZeroLength`. - pub fn new(min_len: uint, options: &[MapOption]) -> Result<MemoryMap, MapError> { + pub fn new(min_len: usize, options: &[MapOption]) -> Result<MemoryMap, MapError> { use libc::off_t; if min_len == 0 { @@ -1002,7 +1002,7 @@ impl MemoryMap { libc::EINVAL => ErrUnaligned, libc::ENODEV => ErrNoMapSupport, libc::ENOMEM => ErrNoMem, - code => ErrUnknown(code as int) + code => ErrUnknown(code as isize) }) } else { Ok(MemoryMap { @@ -1019,7 +1019,7 @@ impl MemoryMap { /// Granularity that the offset or address must be for `MapOffset` and /// `MapAddr` respectively. - pub fn granularity() -> uint { + pub fn granularity() -> usize { env::page_size() } } @@ -1040,7 +1040,7 @@ impl Drop for MemoryMap { #[cfg(windows)] impl MemoryMap { /// Create a new mapping with the given `options`, at least `min_len` bytes long. - pub fn new(min_len: uint, options: &[MapOption]) -> Result<MemoryMap, MapError> { + pub fn new(min_len: usize, options: &[MapOption]) -> Result<MemoryMap, MapError> { use libc::types::os::arch::extra::{LPVOID, DWORD, SIZE_T, HANDLE}; let mut lpAddress: LPVOID = ptr::null_mut(); @@ -1048,7 +1048,7 @@ impl MemoryMap { let mut writable = false; let mut executable = false; let mut handle: HANDLE = libc::INVALID_HANDLE_VALUE; - let mut offset: uint = 0; + let mut offset: usize = 0; let len = round_up(min_len, env::page_size()); for &o in options { @@ -1083,7 +1083,7 @@ impl MemoryMap { libc::MEM_COMMIT | libc::MEM_RESERVE, flProtect) }; - match r as uint { + match r as usize { 0 => Err(ErrVirtualAlloc(errno())), _ => Ok(MemoryMap { data: r as *mut u8, @@ -1119,7 +1119,7 @@ impl MemoryMap { ((len as u64) >> 32) as DWORD, (offset & 0xffff_ffff) as DWORD, 0); - match r as uint { + match r as usize { 0 => Err(ErrMapViewOfFile(errno())), _ => Ok(MemoryMap { data: r as *mut u8, @@ -1133,13 +1133,13 @@ impl MemoryMap { /// Granularity of MapAddr() and MapOffset() parameter values. /// This may be greater than the value returned by page_size(). - pub fn granularity() -> uint { + pub fn granularity() -> usize { use mem; unsafe { let mut info = mem::zeroed(); libc::GetSystemInfo(&mut info); - return info.dwAllocationGranularity as uint; + return info.dwAllocationGranularity as usize; } } } @@ -1178,7 +1178,7 @@ impl MemoryMap { /// Returns the pointer to the memory created or modified by this map. pub fn data(&self) -> *mut u8 { self.data } /// Returns the number of bytes this map applies to. - pub fn len(&self) -> uint { self.len } + pub fn len(&self) -> usize { self.len } /// Returns the type of mapping this represents. pub fn kind(&self) -> MemoryMapKind { self.kind } } diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 656ca980624..cfd4e17c021 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -64,7 +64,7 @@ //! //! let mut rng = rand::thread_rng(); //! if rng.gen() { // random bool -//! println!("int: {}, uint: {}", rng.gen::<int>(), rng.gen::<uint>()) +//! println!("isize: {}, usize: {}", rng.gen::<isize>(), rng.gen::<usize>()) //! } //! ``` //! @@ -148,7 +148,7 @@ //! } //! //! // Run a single simulation of the Monty Hall problem. -//! fn simulate<R: Rng>(random_door: &Range<uint>, rng: &mut R) -> SimulationResult { +//! fn simulate<R: Rng>(random_door: &Range<usize>, rng: &mut R) -> SimulationResult { //! let car = random_door.ind_sample(rng); //! //! // This is our initial choice @@ -168,18 +168,18 @@ //! //! // Returns the door the game host opens given our choice and knowledge of //! // where the car is. The game host will never open the door with the car. -//! fn game_host_open<R: Rng>(car: uint, choice: uint, rng: &mut R) -> uint { +//! fn game_host_open<R: Rng>(car: usize, choice: usize, rng: &mut R) -> usize { //! let choices = free_doors(&[car, choice]); //! rand::sample(rng, choices.into_iter(), 1)[0] //! } //! //! // Returns the door we switch to, given our current choice and //! // the open door. There will only be one valid door. -//! fn switch_door(choice: uint, open: uint) -> uint { +//! fn switch_door(choice: usize, open: usize) -> usize { //! free_doors(&[choice, open])[0] //! } //! -//! fn free_doors(blocked: &[uint]) -> Vec<uint> { +//! fn free_doors(blocked: &[usize]) -> Vec<usize> { //! (0..3).filter(|x| !blocked.contains(x)).collect() //! } //! @@ -336,7 +336,7 @@ pub struct ThreadRng { /// Retrieve the lazily-initialized thread-local random number /// generator, seeded by the system. Intended to be used in method -/// chaining style, e.g. `thread_rng().gen::<int>()`. +/// chaining style, e.g. `thread_rng().gen::<isize>()`. /// /// The RNG provided will reseed itself from the operating system /// after generating a certain amount of randomness. @@ -556,14 +556,14 @@ mod test { let mut r = thread_rng(); assert_eq!(r.choose(&[1, 1, 1]).cloned(), Some(1)); - let v: &[int] = &[]; + let v: &[isize] = &[]; assert_eq!(r.choose(v), None); } #[test] fn test_shuffle() { let mut r = thread_rng(); - let empty: &mut [int] = &mut []; + let empty: &mut [isize] = &mut []; r.shuffle(empty); let mut one = [1]; r.shuffle(&mut one); @@ -583,7 +583,7 @@ mod test { #[test] fn test_thread_rng() { let mut r = thread_rng(); - r.gen::<int>(); + r.gen::<isize>(); let mut v = [1, 1, 1]; r.shuffle(&mut v); let b: &[_] = &[1, 1, 1]; @@ -594,12 +594,12 @@ mod test { #[test] fn test_random() { // not sure how to test this aside from just getting some values - let _n : uint = random(); + let _n : usize = random(); let _f : f32 = random(); let _o : Option<Option<i8>> = random(); let _many : ((), - (uint, - int, + (usize, + isize, Option<(u32, (bool,))>), (u8, i8, u16, i16, u32, i32, u64, i64), (f32, (f64, (f64,)))) = random(); @@ -611,7 +611,7 @@ mod test { let max_val = 100; let mut r = thread_rng(); - let vals = (min_val..max_val).collect::<Vec<int>>(); + let vals = (min_val..max_val).collect::<Vec<isize>>(); let small_sample = sample(&mut r, vals.iter(), 5); let large_sample = sample(&mut r, vals.iter(), vals.len() + 5); @@ -625,7 +625,7 @@ mod test { #[test] fn test_std_rng_seeded() { - let s = thread_rng().gen_iter::<uint>().take(256).collect::<Vec<uint>>(); + let s = thread_rng().gen_iter::<usize>().take(256).collect::<Vec<usize>>(); let mut ra: StdRng = SeedableRng::from_seed(&*s); let mut rb: StdRng = SeedableRng::from_seed(&*s); assert!(order::equals(ra.gen_ascii_chars().take(100), @@ -634,7 +634,7 @@ mod test { #[test] fn test_std_rng_reseed() { - let s = thread_rng().gen_iter::<uint>().take(256).collect::<Vec<uint>>(); + let s = thread_rng().gen_iter::<usize>().take(256).collect::<Vec<usize>>(); let mut r: StdRng = SeedableRng::from_seed(&*s); let string1 = r.gen_ascii_chars().take(100).collect::<String>(); @@ -662,10 +662,10 @@ mod bench { let mut rng: XorShiftRng = OsRng::new().unwrap().gen(); b.iter(|| { for _ in 0..RAND_BENCH_N { - rng.gen::<uint>(); + rng.gen::<usize>(); } }); - b.bytes = size_of::<uint>() as u64 * RAND_BENCH_N; + b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } #[bench] @@ -673,10 +673,10 @@ mod bench { let mut rng: IsaacRng = OsRng::new().unwrap().gen(); b.iter(|| { for _ in 0..RAND_BENCH_N { - rng.gen::<uint>(); + rng.gen::<usize>(); } }); - b.bytes = size_of::<uint>() as u64 * RAND_BENCH_N; + b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } #[bench] @@ -684,10 +684,10 @@ mod bench { let mut rng: Isaac64Rng = OsRng::new().unwrap().gen(); b.iter(|| { for _ in 0..RAND_BENCH_N { - rng.gen::<uint>(); + rng.gen::<usize>(); } }); - b.bytes = size_of::<uint>() as u64 * RAND_BENCH_N; + b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } #[bench] @@ -695,16 +695,16 @@ mod bench { let mut rng = StdRng::new().unwrap(); b.iter(|| { for _ in 0..RAND_BENCH_N { - rng.gen::<uint>(); + rng.gen::<usize>(); } }); - b.bytes = size_of::<uint>() as u64 * RAND_BENCH_N; + b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } #[bench] fn rand_shuffle_100(b: &mut Bencher) { let mut rng = weak_rng(); - let x : &mut[uint] = &mut [1; 100]; + let x : &mut[usize] = &mut [1; 100]; b.iter(|| { rng.shuffle(x); }) diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index d3a8fa864fc..ece6867ddca 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -29,7 +29,7 @@ use result::Result::{Ok, Err}; /// use std::old_io::MemReader; /// /// let mut rng = reader::ReaderRng::new(MemReader::new(vec!(1,2,3,4,5,6,7,8))); -/// println!("{:x}", rng.gen::<uint>()); +/// println!("{:x}", rng.gen::<usize>()); /// ``` pub struct ReaderRng<R> { reader: R diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 9da63405346..428bcaa49f7 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -23,7 +23,7 @@ use core::prelude::*; use vec::Vec; /// One-time global initialization. -pub unsafe fn init(argc: int, argv: *const *const u8) { imp::init(argc, argv) } +pub unsafe fn init(argc: isize, argv: *const *const u8) { imp::init(argc, argv) } /// One-time global cleanup. pub unsafe fn cleanup() { imp::cleanup() } @@ -54,10 +54,10 @@ mod imp { use sync::{StaticMutex, MUTEX_INIT}; - static mut GLOBAL_ARGS_PTR: uint = 0; + static mut GLOBAL_ARGS_PTR: usize = 0; static LOCK: StaticMutex = MUTEX_INIT; - pub unsafe fn init(argc: int, argv: *const *const u8) { + pub unsafe fn init(argc: isize, argv: *const *const u8) { let args = load_argc_and_argv(argc, argv); put(args); } @@ -146,7 +146,7 @@ mod imp { use core::prelude::*; use vec::Vec; - pub unsafe fn init(_argc: int, _argv: *const *const u8) { + pub unsafe fn init(_argc: isize, _argv: *const *const u8) { } pub fn cleanup() { diff --git a/src/libstd/rt/libunwind.rs b/src/libstd/rt/libunwind.rs index 3063d9d942a..b7769910564 100644 --- a/src/libstd/rt/libunwind.rs +++ b/src/libstd/rt/libunwind.rs @@ -64,25 +64,25 @@ pub type _Unwind_Exception_Class = u64; pub type _Unwind_Word = libc::uintptr_t; #[cfg(target_arch = "x86")] -pub const unwinder_private_data_size: uint = 5; +pub const unwinder_private_data_size: usize = 5; #[cfg(target_arch = "x86_64")] -pub const unwinder_private_data_size: uint = 6; +pub const unwinder_private_data_size: usize = 6; #[cfg(all(target_arch = "arm", not(target_os = "ios")))] -pub const unwinder_private_data_size: uint = 20; +pub const unwinder_private_data_size: usize = 20; #[cfg(all(target_arch = "arm", target_os = "ios"))] -pub const unwinder_private_data_size: uint = 5; +pub const unwinder_private_data_size: usize = 5; #[cfg(target_arch = "aarch64")] -pub const unwinder_private_data_size: uint = 2; +pub const unwinder_private_data_size: usize = 2; #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] -pub const unwinder_private_data_size: uint = 2; +pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "powerpc")] -pub const unwinder_private_data_size: uint = 2; +pub const unwinder_private_data_size: usize = 2; #[repr(C)] pub struct _Unwind_Exception { diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 497076cc6ac..696c7960c3e 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -48,16 +48,16 @@ mod libunwind; /// The default error code of the rust runtime if the main thread panics instead /// of exiting cleanly. -pub const DEFAULT_ERROR_CODE: int = 101; +pub const DEFAULT_ERROR_CODE: isize = 101; #[cfg(any(windows, android))] -const OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20; +const OS_DEFAULT_STACK_ESTIMATE: usize = 1 << 20; #[cfg(all(unix, not(android)))] -const OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20); +const OS_DEFAULT_STACK_ESTIMATE: usize = 2 * (1 << 20); #[cfg(not(test))] #[lang = "start"] -fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int { +fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize { use prelude::v1::*; use mem; @@ -68,13 +68,13 @@ fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int { use thread::Thread; let something_around_the_top_of_the_stack = 1; - let addr = &something_around_the_top_of_the_stack as *const _ as *const int; - let my_stack_top = addr as uint; + let addr = &something_around_the_top_of_the_stack as *const _ as *const isize; + let my_stack_top = addr as usize; // FIXME #11359 we just assume that this thread has a stack of a // certain size, and estimate that there's at most 20KB of stack // frames above our current position. - const TWENTY_KB: uint = 20000; + const TWENTY_KB: usize = 20000; // saturating-add to sidestep overflow let top_plus_spill = if usize::MAX - TWENTY_KB < my_stack_top { diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 3ee3954ed64..e4927bbd3d2 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -78,12 +78,12 @@ struct Exception { cause: Option<Box<Any + Send + 'static>>, } -pub type Callback = fn(msg: &(Any + Send), file: &'static str, line: uint); +pub type Callback = fn(msg: &(Any + Send), file: &'static str, line: usize); // Variables used for invoking callbacks when a thread starts to unwind. // // For more information, see below. -const MAX_CALLBACKS: uint = 16; +const MAX_CALLBACKS: usize = 16; static CALLBACKS: [atomic::AtomicUsize; MAX_CALLBACKS] = [atomic::ATOMIC_USIZE_INIT, atomic::ATOMIC_USIZE_INIT, atomic::ATOMIC_USIZE_INIT, atomic::ATOMIC_USIZE_INIT, @@ -176,7 +176,7 @@ fn rust_panic(cause: Box<Any + Send + 'static>) -> ! { }; let exception_param = boxed::into_raw(exception) as *mut uw::_Unwind_Exception; let error = uw::_Unwind_RaiseException(exception_param); - rtabort!("Could not unwind stack, error = {}", error as int) + rtabort!("Could not unwind stack, error = {}", error as isize) } extern fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code, @@ -484,7 +484,7 @@ pub mod eabi { /// Entry point of panic from the libcore crate. #[lang = "panic_fmt"] pub extern fn rust_begin_unwind(msg: fmt::Arguments, - file: &'static str, line: uint) -> ! { + file: &'static str, line: usize) -> ! { begin_unwind_fmt(msg, &(file, line)) } @@ -496,7 +496,7 @@ pub extern fn rust_begin_unwind(msg: fmt::Arguments, /// the actual formatting into this shared place. #[inline(never)] #[cold] #[stable(since = "1.0.0", feature = "rust1")] -pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, uint)) -> ! { +pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, usize)) -> ! { use fmt::Write; // We do two allocations here, unfortunately. But (a) they're @@ -512,7 +512,7 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, uint)) - /// This is the entry point of unwinding for panic!() and assert!(). #[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible #[stable(since = "1.0.0", feature = "rust1")] -pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, uint)) -> ! { +pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, usize)) -> ! { // Note that this should be the only allocation performed in this code path. // Currently this means that panic!() on OOM will invoke this code path, // but then again we're not really ready for panic on OOM anyway. If @@ -535,7 +535,7 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, uint)) -> /// }` from ~1900/3700 (-O/no opts) to 180/590. #[inline(never)] #[cold] // this is the slow path, please never inline this fn begin_unwind_inner(msg: Box<Any + Send>, - file_line: &(&'static str, uint)) -> ! { + file_line: &(&'static str, usize)) -> ! { // Make sure the default failure handler is registered before we look at the // callbacks. We also use a raw sys-based mutex here instead of a // `std::sync` one as accessing TLS can cause weird recursive problems (and diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index cf627ca2548..5a482fbb50f 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -43,7 +43,7 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool { (cfg!(target_os="macos")) && running_on_valgrind() } -pub fn min_stack() -> uint { +pub fn min_stack() -> usize { static MIN: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT; match MIN.load(Ordering::SeqCst) { 0 => {} diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index eb421fe55a4..b2b87bb6c44 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1109,13 +1109,13 @@ mod test { #[test] fn drop_full() { - let (tx, _rx) = channel::<Box<int>>(); + let (tx, _rx) = channel::<Box<isize>>(); tx.send(box 1).unwrap(); } #[test] fn drop_full_shared() { - let (tx, _rx) = channel::<Box<int>>(); + let (tx, _rx) = channel::<Box<isize>>(); drop(tx.clone()); drop(tx.clone()); tx.send(box 1).unwrap(); @@ -1454,7 +1454,7 @@ mod test { #[test] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { - let (tx, rx) = channel::<Box<int>>(); + let (tx, rx) = channel::<Box<isize>>(); let _t = thread::spawn(move|| { tx.send(box 10).unwrap(); }); @@ -1631,7 +1631,7 @@ mod sync_tests { #[test] fn drop_full() { - let (tx, _rx) = sync_channel::<Box<int>>(1); + let (tx, _rx) = sync_channel::<Box<isize>>(1); tx.send(box 1).unwrap(); } diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index f3930a8a5d6..80cbd076163 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -398,7 +398,7 @@ impl<T: Send> Packet<T> { } // increment the count on the channel (used for selection) - fn bump(&mut self, amt: int) -> int { + fn bump(&mut self, amt: isize) -> isize { match self.cnt.fetch_add(amt, Ordering::SeqCst) { DISCONNECTED => { self.cnt.store(DISCONNECTED, Ordering::SeqCst); diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 6e94db6d753..a79ffaa0860 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -551,7 +551,7 @@ mod tests { let arc2 = arc.clone(); let _ = thread::spawn(move|| -> () { struct Unwinder { - i: Arc<RwLock<int>>, + i: Arc<RwLock<isize>>, } impl Drop for Unwinder { fn drop(&mut self) { diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index 059cce57245..be521095aa9 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -44,7 +44,7 @@ use sync::{Mutex, Condvar}; /// sem.release(); /// ``` pub struct Semaphore { - lock: Mutex<int>, + lock: Mutex<isize>, cvar: Condvar, } @@ -60,7 +60,7 @@ impl Semaphore { /// The count specified can be thought of as a number of resources, and a /// call to `acquire` or `access` will block until at least one resource is /// available. It is valid to initialize a semaphore with a negative count. - pub fn new(count: int) -> Semaphore { + pub fn new(count: isize) -> Semaphore { Semaphore { lock: Mutex::new(count), cvar: Condvar::new(), diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index c42a755b444..cd118b3c9ee 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -14,10 +14,10 @@ use io::prelude::*; use io; #[cfg(target_pointer_width = "64")] -pub const HEX_WIDTH: uint = 18; +pub const HEX_WIDTH: usize = 18; #[cfg(target_pointer_width = "32")] -pub const HEX_WIDTH: uint = 10; +pub const HEX_WIDTH: usize = 10; // All rust symbols are in theory lists of "::"-separated identifiers. Some // assemblers, however, can't handle these characters in symbol names. To get @@ -57,7 +57,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { let mut i = 0; for c in chars.by_ref() { if c.is_numeric() { - i = i * 10 + c as uint - '0' as uint; + i = i * 10 + c as usize - '0' as usize; } else { break } @@ -86,7 +86,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { while rest.char_at(0).is_numeric() { rest = &rest[1..]; } - let i: uint = inner[.. (inner.len() - rest.len())].parse().unwrap(); + let i: usize = inner[.. (inner.len() - rest.len())].parse().unwrap(); inner = &rest[i..]; rest = &rest[..i]; while rest.len() > 0 { diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index 10077dfd1b8..34a58f6c83a 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -51,7 +51,7 @@ pub struct Helper<M:Send> { pub chan: UnsafeCell<*mut Sender<M>>, /// OS handle used to wake up a blocked helper thread - pub signal: UnsafeCell<uint>, + pub signal: UnsafeCell<usize>, /// Flag if this helper thread has booted and been initialized yet. pub initialized: UnsafeCell<bool>, @@ -96,11 +96,11 @@ impl<M: Send> Helper<M> { { unsafe { let _guard = self.lock.lock().unwrap(); - if *self.chan.get() as uint == 0 { + if *self.chan.get() as usize == 0 { let (tx, rx) = channel(); *self.chan.get() = boxed::into_raw(box tx); let (receive, send) = helper_signal::new(); - *self.signal.get() = send as uint; + *self.signal.get() = send as usize; let receive = RaceBox(receive); @@ -114,7 +114,7 @@ impl<M: Send> Helper<M> { let _ = rt::at_exit(move || { self.shutdown() }); *self.initialized.get() = true; - } else if *self.chan.get() as uint == 1 { + } else if *self.chan.get() as usize == 1 { panic!("cannot continue usage after shutdown"); } } @@ -130,8 +130,8 @@ impl<M: Send> Helper<M> { // Must send and *then* signal to ensure that the child receives the // message. Otherwise it could wake up and go to sleep before we // send the message. - assert!(*self.chan.get() as uint != 0); - assert!(*self.chan.get() as uint != 1, + assert!(*self.chan.get() as usize != 0); + assert!(*self.chan.get() as usize != 1, "cannot continue usage after shutdown"); (**self.chan.get()).send(msg).unwrap(); helper_signal::signal(*self.signal.get() as helper_signal::signal); @@ -146,7 +146,7 @@ impl<M: Send> Helper<M> { let mut guard = self.lock.lock().unwrap(); let ptr = *self.chan.get(); - if ptr as uint == 1 { + if ptr as usize == 1 { panic!("cannot continue usage after shutdown"); } // Close the channel by destroying it diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index 29c05b1e0d8..a8769ba99e8 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -56,7 +56,7 @@ pub fn timeout(desc: &'static str) -> IoError { } #[allow(deprecated)] -pub fn short_write(n: uint, desc: &'static str) -> IoError { +pub fn short_write(n: usize, desc: &'static str) -> IoError { IoError { kind: if n == 0 { old_io::TimedOut } else { old_io::ShortWrite(n) }, desc: desc, @@ -84,7 +84,7 @@ pub fn mkerr_libc<T: Int>(ret: T) -> IoResult<()> { } pub fn keep_going<F>(data: &[u8], mut f: F) -> i64 where - F: FnMut(*const u8, uint) -> i64, + F: FnMut(*const u8, usize) -> i64, { let origamt = data.len(); let mut data = data.as_ptr(); @@ -94,8 +94,8 @@ pub fn keep_going<F>(data: &[u8], mut f: F) -> i64 where if ret == 0 { break } else if ret != -1 { - amt -= ret as uint; - data = unsafe { data.offset(ret as int) }; + amt -= ret as usize; + data = unsafe { data.offset(ret as isize) }; } else { return ret; } @@ -134,7 +134,7 @@ pub trait ProcessConfig<K: BytesContainer, V: BytesContainer> { fn args(&self) -> &[CString]; fn env(&self) -> Option<&collections::HashMap<K, V>>; fn cwd(&self) -> Option<&CString>; - fn uid(&self) -> Option<uint>; - fn gid(&self) -> Option<uint>; + fn uid(&self) -> Option<usize>; + fn gid(&self) -> Option<usize>; fn detach(&self) -> bool; } diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 96b72b42e54..1a0ee17904a 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -148,7 +148,7 @@ pub fn getsockopt<T: Copy>(fd: sock_t, opt: libc::c_int, if ret != 0 { Err(last_net_error()) } else { - assert!(len as uint == mem::size_of::<T>()); + assert!(len as usize == mem::size_of::<T>()); Ok(slot) } } @@ -170,14 +170,14 @@ pub fn sockname(fd: sock_t, return Err(last_net_error()) } } - return sockaddr_to_addr(&storage, len as uint); + return sockaddr_to_addr(&storage, len as usize); } pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, - len: uint) -> IoResult<SocketAddr> { + len: usize) -> IoResult<SocketAddr> { match storage.ss_family as libc::c_int { libc::AF_INET => { - assert!(len as uint >= mem::size_of::<libc::sockaddr_in>()); + assert!(len as usize >= mem::size_of::<libc::sockaddr_in>()); let storage: &libc::sockaddr_in = unsafe { mem::transmute(storage) }; @@ -192,7 +192,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, }) } libc::AF_INET6 => { - assert!(len as uint >= mem::size_of::<libc::sockaddr_in6>()); + assert!(len as usize >= mem::size_of::<libc::sockaddr_in6>()); let storage: &libc::sockaddr_in6 = unsafe { mem::transmute(storage) }; @@ -283,13 +283,13 @@ pub fn get_host_addresses(host: Option<&str>, servname: Option<&str>, while !rp.is_null() { unsafe { let addr = try!(sockaddr_to_addr(mem::transmute((*rp).ai_addr), - (*rp).ai_addrlen as uint)); + (*rp).ai_addrlen as usize)); addrs.push(addrinfo::Info { address: addr, - family: (*rp).ai_family as uint, + family: (*rp).ai_family as usize, socktype: None, protocol: None, - flags: (*rp).ai_flags as uint + flags: (*rp).ai_flags as usize }); rp = (*rp).ai_next as *mut libc::addrinfo; @@ -312,7 +312,7 @@ extern "system" { flags: c_int) -> c_int; } -const NI_MAXHOST: uint = 1025; +const NI_MAXHOST: usize = 1025; pub fn get_address_name(addr: IpAddr) -> Result<String, IoError> { let addr = SocketAddr{ip: addr, port: 0}; @@ -393,7 +393,7 @@ pub fn get_address_name(addr: IpAddr) -> Result<String, IoError> { // [1] http://twistedmatrix.com/pipermail/twisted-commits/2012-April/034692.html // [2] http://stackoverflow.com/questions/19819198/does-send-msg-dontwait -pub fn read<T, L, R>(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoResult<uint> where +pub fn read<T, L, R>(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoResult<usize> where L: FnMut() -> T, R: FnMut(bool) -> libc::c_int, { @@ -431,7 +431,7 @@ pub fn read<T, L, R>(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoR match ret { 0 => Err(sys_common::eof()), n if n < 0 => Err(last_net_error()), - n => Ok(n as uint) + n => Ok(n as usize) } } @@ -440,9 +440,9 @@ pub fn write<T, L, W>(fd: sock_t, buf: &[u8], write_everything: bool, mut lock: L, - mut write: W) -> IoResult<uint> where + mut write: W) -> IoResult<usize> where L: FnMut() -> T, - W: FnMut(bool, *const u8, uint) -> i64, + W: FnMut(bool, *const u8, usize) -> i64, { let mut ret = -1; let mut written = 0; @@ -454,7 +454,7 @@ pub fn write<T, L, W>(fd: sock_t, }); } else { ret = retry(|| { write(false, buf.as_ptr(), buf.len()) }); - if ret > 0 { written = ret as uint; } + if ret > 0 { written = ret as usize; } } } @@ -483,7 +483,7 @@ pub fn write<T, L, W>(fd: sock_t, match retry(|| write(deadline.is_some(), ptr, len)) { -1 if wouldblock() => {} -1 => return Err(last_net_error()), - n => { written += n as uint; } + n => { written += n as usize; } } } ret = 0; @@ -513,8 +513,8 @@ pub fn connect_timeout(fd: sock_t, // If the connection is in progress, then we need to wait for it to // finish (with a timeout). The current strategy for doing this is // to use select() with a timeout. - -1 if os::errno() as int == INPROGRESS as int || - os::errno() as int == WOULDBLOCK as int => { + -1 if os::errno() as isize == INPROGRESS as isize || + os::errno() as isize == WOULDBLOCK as isize => { let mut set: c::fd_set = unsafe { mem::zeroed() }; c::fd_set(&mut set, fd); match await(fd, &mut set, timeout_ms) { @@ -686,7 +686,7 @@ impl TcpStream { nodelay as libc::c_int) } - pub fn set_keepalive(&mut self, seconds: Option<uint>) -> IoResult<()> { + pub fn set_keepalive(&mut self, seconds: Option<usize>) -> IoResult<()> { let ret = setsockopt(self.fd(), libc::SOL_SOCKET, libc::SO_KEEPALIVE, seconds.is_some() as libc::c_int); match seconds { @@ -696,18 +696,18 @@ impl TcpStream { } #[cfg(any(target_os = "macos", target_os = "ios"))] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, seconds as libc::c_int) } #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, seconds as libc::c_int) } #[cfg(target_os = "openbsd")] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::SO_KEEPALIVE, seconds as libc::c_int) } @@ -716,7 +716,7 @@ impl TcpStream { target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")))] - fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, _seconds: usize) -> IoResult<()> { Ok(()) } @@ -733,7 +733,7 @@ impl TcpStream { ret } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); let doread = |nb| unsafe { @@ -749,7 +749,7 @@ impl TcpStream { pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe { + let dowrite = |nb: bool, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::send(fd, buf as *const _, @@ -876,7 +876,7 @@ impl UdpSocket { sockname(self.fd(), libc::getsockname) } - pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)> { + pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(usize, SocketAddr)> { let fd = self.fd(); let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; let storagep = &mut storage as *mut _ as *mut libc::sockaddr; @@ -893,7 +893,7 @@ impl UdpSocket { storagep, &mut addrlen) as libc::c_int })); - Ok((n as uint, sockaddr_to_addr(&storage, addrlen as uint).unwrap())) + Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize).unwrap())) } pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { @@ -903,7 +903,7 @@ impl UdpSocket { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb, buf: *const u8, len: uint| unsafe { + let dowrite = |nb, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::sendto(fd, buf as *const libc::c_void, @@ -939,11 +939,11 @@ impl UdpSocket { } } - pub fn multicast_time_to_live(&mut self, ttl: int) -> IoResult<()> { + pub fn multicast_time_to_live(&mut self, ttl: isize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_IP, libc::IP_MULTICAST_TTL, ttl as libc::c_int) } - pub fn time_to_live(&mut self, ttl: int) -> IoResult<()> { + pub fn time_to_live(&mut self, ttl: isize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_IP, libc::IP_TTL, ttl as libc::c_int) } diff --git a/src/libstd/sys/common/stack.rs b/src/libstd/sys/common/stack.rs index 8c428275ccf..8dc3407db77 100644 --- a/src/libstd/sys/common/stack.rs +++ b/src/libstd/sys/common/stack.rs @@ -46,7 +46,7 @@ // corresponding prolog, decision was taken to disable segmented // stack support on iOS. -pub const RED_ZONE: uint = 20 * 1024; +pub const RED_ZONE: usize = 20 * 1024; /// This function is invoked from rust's current __morestack function. Segmented /// stacks are currently not enabled as segmented stacks, but rather one giant @@ -117,7 +117,7 @@ extern fn stack_exhausted() { // On all other platforms both variants behave identically. #[inline(always)] -pub unsafe fn record_os_managed_stack_bounds(stack_lo: uint, _stack_hi: uint) { +pub unsafe fn record_os_managed_stack_bounds(stack_lo: usize, _stack_hi: usize) { record_sp_limit(stack_lo + RED_ZONE); } @@ -136,31 +136,31 @@ pub unsafe fn record_os_managed_stack_bounds(stack_lo: uint, _stack_hi: uint) { /// would be unfortunate for the functions themselves to trigger a morestack /// invocation (if they were an actual function call). #[inline(always)] -pub unsafe fn record_sp_limit(limit: uint) { +pub unsafe fn record_sp_limit(limit: usize) { return target_record_sp_limit(limit); // x86-64 #[cfg(all(target_arch = "x86_64", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $$0x60+90*8, %rsi movq $0, %gs:(%rsi)" :: "r"(limit) : "rsi" : "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:112" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile") } @@ -168,18 +168,18 @@ pub unsafe fn record_sp_limit(limit: uint) { #[cfg(all(target_arch = "x86", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movl $$0x48+90*4, %eax movl $0, %gs:(%eax)" :: "r"(limit) : "eax" : "volatile") } #[cfg(all(target_arch = "x86", any(target_os = "linux", target_os = "freebsd")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movl $0, %gs:48" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } // mips, arm - Some brave soul can port these to inline asm, but it's over @@ -188,7 +188,7 @@ pub unsafe fn record_sp_limit(limit: uint) { target_arch = "mipsel", all(target_arch = "arm", not(target_os = "ios"))))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { use libc::c_void; return record_sp_limit(limit as *const c_void); extern { @@ -205,7 +205,7 @@ pub unsafe fn record_sp_limit(limit: uint) { all(target_arch = "arm", target_os = "ios"), target_os = "bitrig", target_os = "openbsd"))] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } } @@ -218,38 +218,38 @@ pub unsafe fn record_sp_limit(limit: uint) { /// As with the setter, this function does not have a __morestack header and can /// therefore be called in a "we're out of stack" situation. #[inline(always)] -pub unsafe fn get_sp_limit() -> uint { +pub unsafe fn get_sp_limit() -> usize { return target_get_sp_limit(); // x86-64 #[cfg(all(target_arch = "x86_64", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq $$0x60+90*8, %rsi movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { return 1024; } #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile"); return limit; @@ -259,7 +259,7 @@ pub unsafe fn get_sp_limit() -> uint { #[cfg(all(target_arch = "x86", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movl $$0x48+90*4, %eax movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile"); @@ -268,13 +268,13 @@ pub unsafe fn get_sp_limit() -> uint { #[cfg(all(target_arch = "x86", any(target_os = "linux", target_os = "freebsd")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { return 1024; } @@ -284,9 +284,9 @@ pub unsafe fn get_sp_limit() -> uint { target_arch = "mipsel", all(target_arch = "arm", not(target_os = "ios"))))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { use libc::c_void; - return get_sp_limit() as uint; + return get_sp_limit() as usize; extern { fn get_sp_limit() -> *const c_void; } @@ -305,7 +305,7 @@ pub unsafe fn get_sp_limit() -> uint { target_os = "bitrig", target_os = "openbsd"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { 1024 } } diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs index 90526b8f4f3..22cb5943371 100644 --- a/src/libstd/sys/common/thread_info.rs +++ b/src/libstd/sys/common/thread_info.rs @@ -18,7 +18,7 @@ use thread::Thread; use thread::LocalKeyState; struct ThreadInfo { - stack_guard: uint, + stack_guard: usize, thread: Thread, } @@ -47,11 +47,11 @@ pub fn current_thread() -> Thread { ThreadInfo::with(|info| info.thread.clone()) } -pub fn stack_guard() -> uint { +pub fn stack_guard() -> usize { ThreadInfo::with(|info| info.stack_guard) } -pub fn set(stack_guard: uint, thread: Thread) { +pub fn set(stack_guard: usize, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ stack_guard: stack_guard, diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs index 5e2a138fa63..5995d7ac10f 100644 --- a/src/libstd/sys/common/thread_local.rs +++ b/src/libstd/sys/common/thread_local.rs @@ -178,7 +178,7 @@ impl StaticKey { } } - unsafe fn lazy_init(&self) -> uint { + unsafe fn lazy_init(&self) -> usize { // POSIX allows the key created here to be 0, but the compare_and_swap // below relies on using 0 as a sentinel value to check who won the // race to set the shared TLS key. As far as I know, there is no @@ -197,9 +197,9 @@ impl StaticKey { key2 }; assert!(key != 0); - match self.inner.key.compare_and_swap(0, key as uint, Ordering::SeqCst) { + match self.inner.key.compare_and_swap(0, key as usize, Ordering::SeqCst) { // The CAS succeeded, so we've created the actual key - 0 => key as uint, + 0 => key as usize, // If someone beat us to the punch, use their key instead n => { imp::destroy(key); n } } @@ -261,8 +261,8 @@ mod tests { assert!(k2.get().is_null()); k1.set(1 as *mut _); k2.set(2 as *mut _); - assert_eq!(k1.get() as uint, 1); - assert_eq!(k2.get() as uint, 2); + assert_eq!(k1.get() as usize, 1); + assert_eq!(k2.get() as usize, 2); } #[test] @@ -275,8 +275,8 @@ mod tests { assert!(K2.get().is_null()); K1.set(1 as *mut _); K2.set(2 as *mut _); - assert_eq!(K1.get() as uint, 1); - assert_eq!(K2.get() as uint, 2); + assert_eq!(K1.get() as usize, 1); + assert_eq!(K2.get() as usize, 2); } } } diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 9f3dae34c7a..7efe7d96b71 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -158,7 +158,7 @@ impl Wtf8Buf { /// Create an new, empty WTF-8 string with pre-allocated capacity for `n` bytes. #[inline] - pub fn with_capacity(n: uint) -> Wtf8Buf { + pub fn with_capacity(n: usize) -> Wtf8Buf { Wtf8Buf { bytes: Vec::with_capacity(n) } } @@ -214,7 +214,7 @@ impl Wtf8Buf { // Attempt to not use an intermediate buffer by just pushing bytes // directly onto this string. let slice = slice::from_raw_parts_mut( - self.bytes.as_mut_ptr().offset(cur_len as int), + self.bytes.as_mut_ptr().offset(cur_len as isize), 4 ); let used = encode_utf8_raw(code_point.value, mem::transmute(slice)) @@ -234,15 +234,15 @@ impl Wtf8Buf { /// /// # Panics /// - /// Panics if the new capacity overflows `uint`. + /// Panics if the new capacity overflows `usize`. #[inline] - pub fn reserve(&mut self, additional: uint) { + pub fn reserve(&mut self, additional: usize) { self.bytes.reserve(additional) } /// Returns the number of bytes that this string buffer can hold without reallocating. #[inline] - pub fn capacity(&self) -> uint { + pub fn capacity(&self) -> usize { self.bytes.capacity() } @@ -313,7 +313,7 @@ impl Wtf8Buf { /// Panics if `new_len` > current length, /// or if `new_len` is not a code point boundary. #[inline] - pub fn truncate(&mut self, new_len: uint) { + pub fn truncate(&mut self, new_len: usize) { assert!(is_code_point_boundary(self, new_len)); self.bytes.truncate(new_len) } @@ -463,7 +463,7 @@ impl Wtf8 { /// Return the length, in WTF-8 bytes. #[inline] - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.bytes.len() } @@ -474,7 +474,7 @@ impl Wtf8 { /// /// Panics if `position` is beyond the end of the string. #[inline] - pub fn ascii_byte_at(&self, position: uint) -> u8 { + pub fn ascii_byte_at(&self, position: usize) -> u8 { match self.bytes[position] { ascii_byte @ 0x00 ... 0x7F => ascii_byte, _ => 0xFF @@ -488,7 +488,7 @@ impl Wtf8 { /// Panics if `position` is not at a code point boundary, /// or is beyond the end of the string. #[inline] - pub fn code_point_at(&self, position: uint) -> CodePoint { + pub fn code_point_at(&self, position: usize) -> CodePoint { let (code_point, _) = self.code_point_range_at(position); code_point } @@ -501,7 +501,7 @@ impl Wtf8 { /// Panics if `position` is not at a code point boundary, /// or is beyond the end of the string. #[inline] - pub fn code_point_range_at(&self, position: uint) -> (CodePoint, uint) { + pub fn code_point_range_at(&self, position: usize) -> (CodePoint, usize) { let (c, n) = char_range_at_raw(&self.bytes, position); (CodePoint { value: c }, n) } @@ -570,7 +570,7 @@ impl Wtf8 { } #[inline] - fn next_surrogate(&self, mut pos: uint) -> Option<(uint, u16)> { + fn next_surrogate(&self, mut pos: usize) -> Option<(usize, u16)> { let mut iter = self.bytes[pos..].iter(); loop { let b = match iter.next() { @@ -792,7 +792,7 @@ fn decode_surrogate_pair(lead: u16, trail: u16) -> char { /// Copied from core::str::StrPrelude::is_char_boundary #[inline] -pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { +pub fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool { if index == slice.len() { return true; } match slice.bytes.get(index) { None => false, @@ -802,17 +802,17 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { /// Copied from core::str::raw::slice_unchecked #[inline] -pub unsafe fn slice_unchecked(s: &Wtf8, begin: uint, end: uint) -> &Wtf8 { +pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { // memory layout of an &[u8] and &Wtf8 are the same mem::transmute(slice::from_raw_parts( - s.bytes.as_ptr().offset(begin as int), + s.bytes.as_ptr().offset(begin as isize), end - begin )) } /// Copied from core::str::raw::slice_error_fail #[inline(never)] -pub fn slice_error_fail(s: &Wtf8, begin: uint, end: uint) -> ! { +pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! { assert!(begin <= end); panic!("index {} and/or {} in `{:?}` do not lie on character boundary", begin, end, s); @@ -835,7 +835,7 @@ impl<'a> Iterator for Wtf8CodePoints<'a> { } #[inline] - fn size_hint(&self) -> (uint, Option<uint>) { + fn size_hint(&self) -> (usize, Option<usize>) { let (len, _) = self.bytes.size_hint(); (len.saturating_add(3) / 4, Some(len)) } @@ -869,7 +869,7 @@ impl<'a> Iterator for EncodeWide<'a> { } #[inline] - fn size_hint(&self) -> (uint, Option<uint>) { + fn size_hint(&self) -> (usize, Option<usize>) { let (low, high) = self.code_points.size_hint(); // every code point gets either one u16 or two u16, // so this iterator is between 1 or 2 times as diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index 7db64cfb936..b46d390826c 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -128,7 +128,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { // skipping the first one as it is write itself let iter = (1..cnt).map(|i| { - print(w, i as int, buf[i], buf[i]) + print(w, i as isize, buf[i], buf[i]) }); result::fold(iter, (), |_, _| ()) } @@ -138,7 +138,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { // tracing pub fn write(w: &mut Write) -> io::Result<()> { struct Context<'a> { - idx: int, + idx: isize, writer: &'a mut (Write+'a), last_error: Option<io::Error>, } @@ -222,7 +222,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { } #[cfg(any(target_os = "macos", target_os = "ios"))] -fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, _symaddr: *mut libc::c_void) -> io::Result<()> { use intrinsics; #[repr(C)] @@ -248,7 +248,7 @@ fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, } #[cfg(not(any(target_os = "macos", target_os = "ios")))] -fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, symaddr: *mut libc::c_void) -> io::Result<()> { use env; use ffi::AsOsStr; @@ -441,7 +441,7 @@ fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, } // Finally, after all that work above, we can emit a symbol. -fn output(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn output(w: &mut Write, idx: isize, addr: *mut libc::c_void, s: Option<&[u8]>) -> io::Result<()> { try!(write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH)); match s.and_then(|s| str::from_utf8(s).ok()) { diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 4e9f9c80a18..2514d4bf4a3 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -167,7 +167,7 @@ extern { #[cfg(any(target_os = "macos", target_os = "ios"))] mod select { - pub const FD_SETSIZE: uint = 1024; + pub const FD_SETSIZE: usize = 1024; #[repr(C)] pub struct fd_set { @@ -175,7 +175,7 @@ mod select { } pub fn fd_set(set: &mut fd_set, fd: i32) { - set.fds_bits[(fd / 32) as uint] |= 1 << ((fd % 32) as uint); + set.fds_bits[(fd / 32) as usize] |= 1 << ((fd % 32) as usize); } } @@ -198,7 +198,7 @@ mod select { } pub fn fd_set(set: &mut fd_set, fd: i32) { - let fd = fd as uint; + let fd = fd as usize; set.fds_bits[fd / usize::BITS as usize] |= 1 << (fd % usize::BITS as usize); } } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 327ff3953aa..2569653811f 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -42,7 +42,7 @@ impl FileDesc { FileDesc { fd: fd, close_on_drop: close_on_drop } } - pub fn read(&self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&self, buf: &mut [u8]) -> IoResult<usize> { let ret = retry(|| unsafe { libc::read(self.fd(), buf.as_mut_ptr() as *mut libc::c_void, @@ -53,7 +53,7 @@ impl FileDesc { } else if ret < 0 { Err(super::last_error()) } else { - Ok(ret as uint) + Ok(ret as usize) } } pub fn write(&self, buf: &[u8]) -> IoResult<()> { @@ -181,7 +181,7 @@ pub fn open(path: &Path, fm: FileMode, fa: FileAccess) -> IoResult<FileDesc> { } } -pub fn mkdir(p: &Path, mode: uint) -> IoResult<()> { +pub fn mkdir(p: &Path, mode: usize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) }) } @@ -204,13 +204,13 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> { } let size = unsafe { rust_dirent_t_size() }; - let mut buf = Vec::<u8>::with_capacity(size as uint); + let mut buf = Vec::<u8>::with_capacity(size as usize); let ptr = buf.as_mut_ptr() as *mut dirent_t; let p = try!(CString::new(p.as_vec())); let dir_ptr = unsafe {opendir(p.as_ptr())}; - if dir_ptr as uint != 0 { + if dir_ptr as usize != 0 { let mut paths = vec!(); let mut entry_ptr = ptr::null_mut(); while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } { @@ -239,7 +239,7 @@ pub fn rename(old: &Path, new: &Path) -> IoResult<()> { }) } -pub fn chmod(p: &Path, mode: uint) -> IoResult<()> { +pub fn chmod(p: &Path, mode: usize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(retry(|| unsafe { libc::chmod(p.as_ptr(), mode as libc::mode_t) @@ -251,7 +251,7 @@ pub fn rmdir(p: &Path) -> IoResult<()> { mkerr_libc(unsafe { libc::rmdir(p.as_ptr()) }) } -pub fn chown(p: &Path, uid: int, gid: int) -> IoResult<()> { +pub fn chown(p: &Path, uid: isize, gid: isize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(retry(|| unsafe { libc::chown(p.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) @@ -265,7 +265,7 @@ pub fn readlink(p: &Path) -> IoResult<Path> { if len == -1 { len = 1024; // FIXME: read PATH_MAX from C ffi? } - let mut buf: Vec<u8> = Vec::with_capacity(len as uint); + let mut buf: Vec<u8> = Vec::with_capacity(len as usize); match unsafe { libc::readlink(p, buf.as_ptr() as *mut libc::c_char, len as libc::size_t) as libc::c_int @@ -273,7 +273,7 @@ pub fn readlink(p: &Path) -> IoResult<Path> { -1 => Err(super::last_error()), n => { assert!(n > 0); - unsafe { buf.set_len(n as uint); } + unsafe { buf.set_len(n as usize); } Ok(Path::new(buf)) } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index c73d30d543a..724156d81d8 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -199,13 +199,13 @@ pub fn current_exe() -> io::Result<PathBuf> { 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } - let mut v: Vec<u8> = Vec::with_capacity(sz as uint); + let mut v: Vec<u8> = Vec::with_capacity(sz as usize); let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, v.as_mut_ptr() as *mut libc::c_void, &mut sz, ptr::null_mut(), 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } - v.set_len(sz as uint - 1); // chop off trailing NUL + v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } } @@ -249,10 +249,10 @@ pub fn current_exe() -> io::Result<PathBuf> { let mut sz: u32 = 0; _NSGetExecutablePath(ptr::null_mut(), &mut sz); if sz == 0 { return Err(io::Error::last_os_error()); } - let mut v: Vec<u8> = Vec::with_capacity(sz as uint); + let mut v: Vec<u8> = Vec::with_capacity(sz as usize); let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); if err != 0 { return Err(io::Error::last_os_error()); } - v.set_len(sz as uint - 1); // chop off trailing NUL + v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } } diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index daa981720f6..f0071295bf2 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -151,7 +151,7 @@ impl UnixStream { ret } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); let doread = |nb| unsafe { @@ -167,7 +167,7 @@ impl UnixStream { pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe { + let dowrite = |nb: bool, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::send(fd, buf as *const _, diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index df0e8de3ff1..0d35ace185d 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -49,11 +49,11 @@ impl Process { self.pid } - pub unsafe fn kill(&self, signal: int) -> IoResult<()> { + pub unsafe fn kill(&self, signal: isize) -> IoResult<()> { Process::killpid(self.pid, signal) } - pub unsafe fn killpid(pid: pid_t, signal: int) -> IoResult<()> { + pub unsafe fn killpid(pid: pid_t, signal: isize) -> IoResult<()> { let r = libc::funcs::posix88::signal::kill(pid, signal as c_int); mkerr_libc(r) } @@ -454,7 +454,7 @@ impl Process { // with process timeouts, but libgreen should get there first // (currently libuv doesn't handle old signal handlers). if drain(read_fd) { - let i: uint = unsafe { mem::transmute(old.sa_handler) }; + let i: usize = unsafe { mem::transmute(old.sa_handler) }; if i != 0 { assert!(old.sa_flags & c::SA_SIGINFO == 0); (old.sa_handler)(c::SIGCHLD); @@ -618,8 +618,8 @@ fn translate_status(status: c_int) -> ProcessExit { } if imp::WIFEXITED(status) { - ExitStatus(imp::WEXITSTATUS(status) as int) + ExitStatus(imp::WEXITSTATUS(status) as isize) } else { - ExitSignal(imp::WTERMSIG(status) as int) + ExitSignal(imp::WTERMSIG(status) as isize) } } diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 35706682047..6887095c53a 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -60,7 +60,7 @@ mod imp { // This is initialized in init() and only read from after - static mut PAGE_SIZE: uint = 0; + static mut PAGE_SIZE: usize = 0; #[no_stack_check] unsafe extern fn signal_handler(signum: libc::c_int, @@ -82,7 +82,7 @@ mod imp { stack::record_sp_limit(0); let guard = thread_info::stack_guard(); - let addr = (*info).si_addr as uint; + let addr = (*info).si_addr as usize; if guard == 0 || addr < guard - PAGE_SIZE || addr >= guard { term(signum); @@ -101,7 +101,7 @@ mod imp { panic!("failed to get page size"); } - PAGE_SIZE = psize as uint; + PAGE_SIZE = psize as usize; let mut action: sigaction = mem::zeroed(); action.sa_flags = SA_SIGINFO | SA_ONSTACK; diff --git a/src/libstd/sys/unix/sync.rs b/src/libstd/sys/unix/sync.rs index c7d704922cb..3c05fd602be 100644 --- a/src/libstd/sys/unix/sync.rs +++ b/src/libstd/sys/unix/sync.rs @@ -66,24 +66,24 @@ mod os { #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_MUTEX_SIZE__: uint = 56; + const __PTHREAD_MUTEX_SIZE__: usize = 56; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_MUTEX_SIZE__: uint = 40; + const __PTHREAD_MUTEX_SIZE__: usize = 40; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_COND_SIZE__: uint = 40; + const __PTHREAD_COND_SIZE__: usize = 40; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_COND_SIZE__: uint = 24; + const __PTHREAD_COND_SIZE__: usize = 24; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_RWLOCK_SIZE__: uint = 192; + const __PTHREAD_RWLOCK_SIZE__: usize = 192; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_RWLOCK_SIZE__: uint = 124; + const __PTHREAD_RWLOCK_SIZE__: usize = 124; const _PTHREAD_MUTEX_SIG_INIT: libc::c_long = 0x32AAABA7; const _PTHREAD_COND_SIG_INIT: libc::c_long = 0x3CB0B1BB; @@ -125,15 +125,15 @@ mod os { // minus 8 because we have an 'align' field #[cfg(target_arch = "x86_64")] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 40 - 8; #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 24 - 8; #[cfg(target_arch = "aarch64")] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 48 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 48 - 8; #[cfg(any(target_arch = "x86_64", target_arch = "x86", @@ -142,18 +142,18 @@ mod os { target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; + const __SIZEOF_PTHREAD_COND_T: usize = 48 - 8; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __SIZEOF_PTHREAD_RWLOCK_T: uint = 56 - 8; + const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56 - 8; #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_RWLOCK_T: uint = 32 - 8; + const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 - 8; #[repr(C)] pub struct pthread_mutex_t { diff --git a/src/libstd/sys/unix/tcp.rs b/src/libstd/sys/unix/tcp.rs index 2a6994824c7..a9f2198208b 100644 --- a/src/libstd/sys/unix/tcp.rs +++ b/src/libstd/sys/unix/tcp.rs @@ -64,7 +64,7 @@ impl TcpListener { pub fn fd(&self) -> sock_t { self.inner.fd() } - pub fn listen(self, backlog: int) -> IoResult<TcpAcceptor> { + pub fn listen(self, backlog: isize) -> IoResult<TcpAcceptor> { match unsafe { libc::listen(self.fd(), backlog as libc::c_int) } { -1 => Err(last_net_error()), _ => { diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index b6d2aca9a52..d9a162302fc 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -69,7 +69,7 @@ pub trait Callback { } pub struct Timer { - id: uint, + id: usize, inner: Option<Box<Inner>>, } @@ -78,7 +78,7 @@ pub struct Inner { interval: u64, repeat: bool, target: u64, - id: uint, + id: usize, } pub enum Req { @@ -87,7 +87,7 @@ pub enum Req { // Remove a timer based on its id and then send it back on the channel // provided - RemoveTimer(uint, Sender<Box<Inner>>), + RemoveTimer(usize, Sender<Box<Inner>>), } // returns the current time (in milliseconds) @@ -121,7 +121,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) { // signals the first requests in the queue, possible re-enqueueing it. fn signal(active: &mut Vec<Box<Inner>>, - dead: &mut Vec<(uint, Box<Inner>)>) { + dead: &mut Vec<(usize, Box<Inner>)>) { if active.is_empty() { return } let mut timer = active.remove(0); @@ -216,7 +216,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) { impl Timer { pub fn new() -> IoResult<Timer> { - // See notes above regarding using int return value + // See notes above regarding using isize return value // instead of () HELPER.boot(|| {}, helper); @@ -244,7 +244,7 @@ impl Timer { tv_nsec: ((ms % 1000) * 1000000) as libc::c_long, }; while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) } != 0 { - if os::errno() as int != libc::EINTR as int { + if os::errno() as isize != libc::EINTR as isize { panic!("failed to sleep, but not because of EINTR?"); } } diff --git a/src/libstd/sys/unix/tty.rs b/src/libstd/sys/unix/tty.rs index e4973a8f9f3..2f6fd713bfb 100644 --- a/src/libstd/sys/unix/tty.rs +++ b/src/libstd/sys/unix/tty.rs @@ -46,7 +46,7 @@ impl TTY { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.fd.read(buf) } pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { @@ -56,7 +56,7 @@ impl TTY { Err(sys_common::unimpl()) } - pub fn get_winsize(&mut self) -> IoResult<(int, int)> { + pub fn get_winsize(&mut self) -> IoResult<(isize, isize)> { unsafe { #[repr(C)] struct winsize { @@ -74,7 +74,7 @@ impl TTY { detail: None, }) } else { - Ok((size.ws_col as int, size.ws_row as int)) + Ok((size.ws_col as isize, size.ws_row as isize)) } } } diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index ffa4b37b487..509205a20b1 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -63,7 +63,7 @@ type StackWalk64Fn = *mut libc::c_void, *mut libc::c_void, *mut libc::c_void, *mut libc::c_void) -> libc::BOOL; -const MAX_SYM_NAME: uint = 2000; +const MAX_SYM_NAME: usize = 2000; const IMAGE_FILE_MACHINE_I386: libc::DWORD = 0x014c; const IMAGE_FILE_MACHINE_IA64: libc::DWORD = 0x0200; const IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664; @@ -138,7 +138,7 @@ struct KDHELP64 { mod arch { use libc; - const MAXIMUM_SUPPORTED_EXTENSION: uint = 512; + const MAXIMUM_SUPPORTED_EXTENSION: usize = 512; #[repr(C)] pub struct CONTEXT { diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index e7a01478908..3330130c770 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -42,7 +42,7 @@ impl FileDesc { FileDesc { fd: fd, close_on_drop: close_on_drop } } - pub fn read(&self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&self, buf: &mut [u8]) -> IoResult<usize> { let mut read = 0; let ret = unsafe { libc::ReadFile(self.handle(), buf.as_ptr() as libc::LPVOID, @@ -50,7 +50,7 @@ impl FileDesc { ptr::null_mut()) }; if ret != 0 { - Ok(read as uint) + Ok(read as usize) } else { Err(super::last_error()) } @@ -67,8 +67,8 @@ impl FileDesc { ptr::null_mut()) }; if ret != 0 { - remaining -= amt as uint; - cur = unsafe { cur.offset(amt as int) }; + remaining -= amt as usize; + cur = unsafe { cur.offset(amt as isize) }; } else { return Err(super::last_error()) } @@ -234,7 +234,7 @@ pub fn open(path: &Path, fm: FileMode, fa: FileAccess) -> IoResult<FileDesc> { } } -pub fn mkdir(p: &Path, _mode: uint) -> IoResult<()> { +pub fn mkdir(p: &Path, _mode: usize) -> IoResult<()> { let p = try!(to_utf16(p)); super::mkerr_winbool(unsafe { // FIXME: turn mode into something useful? #2623 @@ -308,11 +308,11 @@ pub fn unlink(p: &Path) -> IoResult<()> { }; if stat.perm.intersects(old_io::USER_WRITE) { return Err(e) } - match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as uint) { + match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as usize) { Ok(()) => do_unlink(&p_utf16), Err(..) => { // Try to put it back as we found it - let _ = chmod(p, stat.perm.bits() as uint); + let _ = chmod(p, stat.perm.bits() as usize); Err(e) } } @@ -331,7 +331,7 @@ pub fn rename(old: &Path, new: &Path) -> IoResult<()> { }) } -pub fn chmod(p: &Path, mode: uint) -> IoResult<()> { +pub fn chmod(p: &Path, mode: usize) -> IoResult<()> { let p = try!(to_utf16(p)); mkerr_libc(unsafe { libc::wchmod(p.as_ptr(), mode as libc::c_int) @@ -343,7 +343,7 @@ pub fn rmdir(p: &Path) -> IoResult<()> { super::mkerr_winbool(unsafe { libc::RemoveDirectoryW(p.as_ptr()) }) } -pub fn chown(_p: &Path, _uid: int, _gid: int) -> IoResult<()> { +pub fn chown(_p: &Path, _uid: isize, _gid: isize) -> IoResult<()> { // libuv has this as a no-op, so seems like this should as well? Ok(()) } diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 17fdd6755c6..064c003bd15 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -115,7 +115,7 @@ impl Event { initial_state as libc::BOOL, ptr::null()) }; - if event as uint == 0 { + if event as usize == 0 { Err(super::last_error()) } else { Ok(Event(event)) @@ -181,7 +181,7 @@ unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE { } pub fn await(handle: libc::HANDLE, deadline: u64, - events: &[libc::HANDLE]) -> IoResult<uint> { + events: &[libc::HANDLE]) -> IoResult<usize> { use libc::consts::os::extra::{WAIT_FAILED, WAIT_TIMEOUT, WAIT_OBJECT_0}; // If we've got a timeout, use WaitForSingleObject in tandem with CancelIo @@ -204,7 +204,7 @@ pub fn await(handle: libc::HANDLE, deadline: u64, let _ = c::CancelIo(handle); Err(sys_common::timeout("operation timed out")) }, - n => Ok((n - WAIT_OBJECT_0) as uint) + n => Ok((n - WAIT_OBJECT_0) as usize) } } @@ -314,7 +314,7 @@ impl UnixStream { // `WaitNamedPipe` function, and this is indicated with an error // code of ERROR_PIPE_BUSY. let code = unsafe { libc::GetLastError() }; - if code as int != libc::ERROR_PIPE_BUSY as int { + if code as isize != libc::ERROR_PIPE_BUSY as isize { return Err(super::last_error()) } @@ -362,7 +362,7 @@ impl UnixStream { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { if self.read.is_none() { self.read = Some(try!(Event::new(true, false))); } @@ -390,7 +390,7 @@ impl UnixStream { &mut bytes_read, &mut overlapped) }; - if ret != 0 { return Ok(bytes_read as uint) } + if ret != 0 { return Ok(bytes_read as usize) } // If our errno doesn't say that the I/O is pending, then we hit some // legitimate error and return immediately. @@ -418,7 +418,7 @@ impl UnixStream { }; // If we succeeded, or we failed for some reason other than // CancelIoEx, return immediately - if ret != 0 { return Ok(bytes_read as uint) } + if ret != 0 { return Ok(bytes_read as usize) } if os::errno() != libc::ERROR_OPERATION_ABORTED as i32 { return Err(super::last_error()) } @@ -487,7 +487,7 @@ impl UnixStream { return Err(super::last_error()) } if !wait_succeeded.is_ok() { - let amt = offset + bytes_written as uint; + let amt = offset + bytes_written as usize; return if amt > 0 { Err(IoError { kind: old_io::ShortWrite(amt), @@ -504,7 +504,7 @@ impl UnixStream { continue // retry } } - offset += bytes_written as uint; + offset += bytes_written as usize; } Ok(()) } diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index e08a6e6b3cd..297f6e173ab 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -63,11 +63,11 @@ impl Process { self.pid } - pub unsafe fn kill(&self, signal: int) -> IoResult<()> { + pub unsafe fn kill(&self, signal: isize) -> IoResult<()> { Process::killpid(self.pid, signal) } - pub unsafe fn killpid(pid: pid_t, signal: int) -> IoResult<()> { + pub unsafe fn killpid(pid: pid_t, signal: isize) -> IoResult<()> { let handle = libc::OpenProcess(libc::PROCESS_TERMINATE | libc::PROCESS_QUERY_INFORMATION, libc::FALSE, pid as libc::DWORD); @@ -309,7 +309,7 @@ impl Process { } if status != STILL_ACTIVE { assert!(CloseHandle(process) != 0); - return Ok(ExitStatus(status as int)); + return Ok(ExitStatus(status as isize)); } let interval = if deadline == 0 { INFINITE @@ -394,7 +394,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String { } } - fn append_char_at(cmd: &mut String, arg: &[char], i: uint) { + fn append_char_at(cmd: &mut String, arg: &[char], i: usize) { match arg[i] { '"' => { // Escape quotes. @@ -415,7 +415,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String { } } - fn backslash_run_ends_in_quote(s: &[char], mut i: uint) -> bool { + fn backslash_run_ends_in_quote(s: &[char], mut i: usize) -> bool { while i < s.len() && s[i] == '\\' { i += 1; } diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index b0410701ee1..79b7de4f341 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -31,7 +31,7 @@ impl Drop for Handler { } // This is initialized in init() and only read from after -static mut PAGE_SIZE: uint = 0; +static mut PAGE_SIZE: usize = 0; #[no_stack_check] extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG { @@ -56,7 +56,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> L pub unsafe fn init() { let mut info = mem::zeroed(); libc::GetSystemInfo(&mut info); - PAGE_SIZE = info.dwPageSize as uint; + PAGE_SIZE = info.dwPageSize as usize; if AddVectoredExceptionHandler(0, vectored_handler) == ptr::null_mut() { panic!("failed to install exception handler"); @@ -96,7 +96,7 @@ pub type PVECTORED_EXCEPTION_HANDLER = extern "system" pub type ULONG = libc::c_ulong; const EXCEPTION_CONTINUE_SEARCH: LONG = 0; -const EXCEPTION_MAXIMUM_PARAMETERS: uint = 15; +const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd; extern "system" { diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index 6e46bf97d1b..2ac8ac10aa9 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -77,7 +77,7 @@ impl TcpListener { pub fn socket(&self) -> sock_t { self.sock } - pub fn listen(self, backlog: int) -> IoResult<TcpAcceptor> { + pub fn listen(self, backlog: isize) -> IoResult<TcpAcceptor> { match unsafe { libc::listen(self.socket(), backlog as libc::c_int) } { -1 => Err(last_net_error()), diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index d1d4ad90081..98e4a737c7b 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -25,8 +25,8 @@ use time::Duration; pub type rust_thread = HANDLE; pub mod guard { - pub unsafe fn main() -> uint { 0 } - pub unsafe fn current() -> uint { 0 } + pub unsafe fn main() -> usize { 0 } + pub unsafe fn current() -> usize { 0 } pub unsafe fn init() {} } diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index c908c791247..cbabab8acb7 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -139,7 +139,7 @@ unsafe fn init_dtors() { let dtors = DTORS; DTORS = 1 as *mut _; Box::from_raw(dtors); - assert!(DTORS as uint == 1); // can't re-init after destructing + assert!(DTORS as usize == 1); // can't re-init after destructing DTOR_LOCK.unlock(); }); if res.is_ok() { @@ -152,8 +152,8 @@ unsafe fn init_dtors() { unsafe fn register_dtor(key: Key, dtor: Dtor) { DTOR_LOCK.lock(); init_dtors(); - assert!(DTORS as uint != 0); - assert!(DTORS as uint != 1, + assert!(DTORS as usize != 0); + assert!(DTORS as usize != 1, "cannot create new TLS keys after the main thread has exited"); (*DTORS).push((key, dtor)); DTOR_LOCK.unlock(); @@ -162,8 +162,8 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) { unsafe fn unregister_dtor(key: Key) -> bool { DTOR_LOCK.lock(); init_dtors(); - assert!(DTORS as uint != 0); - assert!(DTORS as uint != 1, + assert!(DTORS as usize != 0); + assert!(DTORS as usize != 1, "cannot unregister destructors after the main thread has exited"); let ret = { let dtors = &mut *DTORS; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 9bcae926eea..8856cc26b2e 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -91,13 +91,13 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>, _: ()) { } } else { let remove = { - match &mut chans[idx as uint - 1] { + match &mut chans[idx as usize - 1] { &mut (ref mut c, oneshot) => { c.call(); oneshot } } }; if remove { - drop(objs.remove(idx as uint)); - drop(chans.remove(idx as uint - 1)); + drop(objs.remove(idx as usize)); + drop(chans.remove(idx as usize - 1)); } } } diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 52f4cce4aa3..38faabf3276 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -92,7 +92,7 @@ impl TTY { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { // Read more if the buffer is empty if self.utf8.eof() { let mut utf16: Vec<u16> = repeat(0u16).take(0x1000).collect(); @@ -105,7 +105,7 @@ impl TTY { 0 => return Err(super::last_error()), _ => (), }; - utf16.truncate(num as uint); + utf16.truncate(num as usize); let utf8 = match String::from_utf16(&utf16) { Ok(utf8) => utf8.into_bytes(), Err(..) => return Err(invalid_encoding()), @@ -149,12 +149,12 @@ impl TTY { } } - pub fn get_winsize(&mut self) -> IoResult<(int, int)> { + pub fn get_winsize(&mut self) -> IoResult<(isize, isize)> { let mut info: CONSOLE_SCREEN_BUFFER_INFO = unsafe { mem::zeroed() }; match unsafe { GetConsoleScreenBufferInfo(self.handle, &mut info as *mut _) } { 0 => Err(super::last_error()), - _ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as int, - (info.srWindow.Bottom + 1 - info.srWindow.Top) as int)), + _ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as isize, + (info.srWindow.Bottom + 1 - info.srWindow.Top) as isize)), } } } |
