]> git.lizzy.rs Git - rust.git/commitdiff
Fix the fallout
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 14 Feb 2015 21:10:19 +0000 (00:10 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 14 Feb 2015 21:10:19 +0000 (00:10 +0300)
src/libcore/fmt/float.rs
src/libcore/num/mod.rs
src/libfmt_macros/lib.rs
src/libstd/num/f32.rs
src/libstd/num/f64.rs
src/libstd/num/strconv.rs
src/libsyntax/parse/lexer/mod.rs
src/libterm/terminfo/parm.rs
src/test/run-pass/exponential-notation.rs

index 25bb959b9b3aa9db02d12d0dbc894c151077555f..8e09e52daee198cff18f31a26433f173e4ad5d14 100644 (file)
@@ -53,7 +53,7 @@ pub enum SignFormat {
     SignNeg
 }
 
-static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11;
+static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
 
 /// Converts a number to its string representation as a byte vector.
 /// This is meant to be a common base implementation for all numeric string
@@ -87,7 +87,7 @@ pub enum SignFormat {
 ///   between digit and exponent sign `'p'`.
 pub fn float_to_str_bytes_common<T: Float, U, F>(
     num: T,
-    radix: uint,
+    radix: u32,
     negative_zero: bool,
     sign: SignFormat,
     digits: SignificantDigits,
@@ -156,7 +156,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
         deccum = deccum / radix_gen;
         deccum = deccum.trunc();
 
-        let c = char::from_digit(current_digit.to_int().unwrap() as uint, radix);
+        let c = char::from_digit(current_digit.to_int().unwrap() as u32, radix);
         buf[end] = c.unwrap() as u8;
         end += 1;
 
@@ -211,7 +211,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
             // See note in first loop.
             let current_digit = deccum.trunc().abs();
 
-            let c = char::from_digit(current_digit.to_int().unwrap() as uint,
+            let c = char::from_digit(current_digit.to_int().unwrap() as u32,
                                      radix);
             buf[end] = c.unwrap() as u8;
             end += 1;
@@ -228,7 +228,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
             let ascii2value = |chr: u8| {
                 (chr as char).to_digit(radix).unwrap()
             };
-            let value2ascii = |val: uint| {
+            let value2ascii = |val: u32| {
                 char::from_digit(val, radix).unwrap() as u8
             };
 
index b7c5c6640ced0132dddde8709a0c2b222b262e55..d6c01ddc74acbb657e48c722a24dfeec650930e4 100644 (file)
@@ -1432,12 +1432,12 @@ pub trait Float
 #[unstable(feature = "core", reason = "needs reevaluation")]
 pub trait FromStrRadix {
     type Err;
-    fn from_str_radix(str: &str, radix: uint) -> Result<Self, Self::Err>;
+    fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::Err>;
 }
 
 /// A utility function that just calls FromStrRadix::from_str_radix.
 #[unstable(feature = "core", reason = "needs reevaluation")]
-pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: uint)
+pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: u32)
                                        -> Result<T, T::Err> {
     FromStrRadix::from_str_radix(str, radix)
 }
@@ -1501,7 +1501,7 @@ impl FromStrRadix for $T {
             /// `None` if the string did not represent a valid number.
             /// Otherwise, `Some(n)` where `n` is the floating-point number
             /// represented by `src`.
-            fn from_str_radix(src: &str, radix: uint)
+            fn from_str_radix(src: &str, radix: u32)
                               -> Result<$T, ParseFloatError> {
                 use self::FloatErrorKind::*;
                 use self::ParseFloatError as PFE;
@@ -1661,7 +1661,7 @@ fn from_str(src: &str) -> Result<$T, ParseIntError> {
         #[stable(feature = "rust1", since = "1.0.0")]
         impl FromStrRadix for $T {
             type Err = ParseIntError;
-            fn from_str_radix(src: &str, radix: uint)
+            fn from_str_radix(src: &str, radix: u32)
                               -> Result<$T, ParseIntError> {
                 use self::IntErrorKind::*;
                 use self::ParseIntError as PIE;
index fc8d18df81523a6889f4216ccbc935fe9dbe4959..baad31a61e105817916cd12ed9708afa4b61a683 100644 (file)
@@ -422,7 +422,7 @@ fn integer(&mut self) -> Option<uint> {
                 Some((_, c)) => {
                     match c.to_digit(10) {
                         Some(i) => {
-                            cur = cur * 10 + i;
+                            cur = cur * 10 + i as usize;
                             found = true;
                             self.cur.next();
                         }
index 58b93665fe15339bb981821b5b064cb165a66bb4..62ed824c3ba9e54183fe54cc8ce58ba3f593ff09 100644 (file)
@@ -369,7 +369,7 @@ fn atanh(self) -> f32 {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_string(num: f32) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigAll, ExpNone, false);
+        num, 10, true, SignNeg, DigAll, ExpNone, false);
     r
 }
 
@@ -382,7 +382,7 @@ pub fn to_string(num: f32) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_hex(num: f32) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 16u, true, SignNeg, DigAll, ExpNone, false);
+        num, 16, true, SignNeg, DigAll, ExpNone, false);
     r
 }
 
@@ -395,7 +395,7 @@ pub fn to_str_hex(num: f32) -> String {
 /// * radix - The base to use
 #[inline]
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
-pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) {
+pub fn to_str_radix_special(num: f32, rdx: u32) -> (String, bool) {
     strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false)
 }
 
@@ -410,7 +410,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_exact(num: f32, dig: uint) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigExact(dig), ExpNone, false);
+        num, 10, true, SignNeg, DigExact(dig), ExpNone, false);
     r
 }
 
@@ -425,7 +425,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_digits(num: f32, dig: uint) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigMax(dig), ExpNone, false);
+        num, 10, true, SignNeg, DigMax(dig), ExpNone, false);
     r
 }
 
@@ -441,7 +441,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper);
+        num, 10, true, SignNeg, DigExact(dig), ExpDec, upper);
     r
 }
 
@@ -457,7 +457,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper);
+        num, 10, true, SignNeg, DigMax(dig), ExpDec, upper);
     r
 }
 
index 8b17feeb70cdcfc35a7e18701a4abd615a007853..0e2ac97ca01eae9c881c96723b92f610c08c0d63 100644 (file)
@@ -378,7 +378,7 @@ fn atanh(self) -> f64 {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_string(num: f64) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigAll, ExpNone, false);
+        num, 10, true, SignNeg, DigAll, ExpNone, false);
     r
 }
 
@@ -391,7 +391,7 @@ pub fn to_string(num: f64) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_hex(num: f64) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 16u, true, SignNeg, DigAll, ExpNone, false);
+        num, 16, true, SignNeg, DigAll, ExpNone, false);
     r
 }
 
@@ -404,7 +404,7 @@ pub fn to_str_hex(num: f64) -> String {
 /// * radix - The base to use
 #[inline]
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
-pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) {
+pub fn to_str_radix_special(num: f64, rdx: u32) -> (String, bool) {
     strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false)
 }
 
@@ -419,7 +419,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_exact(num: f64, dig: uint) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigExact(dig), ExpNone, false);
+        num, 10, true, SignNeg, DigExact(dig), ExpNone, false);
     r
 }
 
@@ -434,7 +434,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_digits(num: f64, dig: uint) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigMax(dig), ExpNone, false);
+        num, 10, true, SignNeg, DigMax(dig), ExpNone, false);
     r
 }
 
@@ -450,7 +450,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper);
+        num, 10, true, SignNeg, DigExact(dig), ExpDec, upper);
     r
 }
 
@@ -466,7 +466,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String {
 #[unstable(feature = "std_misc", reason = "may be removed or relocated")]
 pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
     let (r, _) = strconv::float_to_str_common(
-        num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper);
+        num, 10, true, SignNeg, DigMax(dig), ExpDec, upper);
     r
 }
 
index 4ae7d3437fd93f689f8bdaeb67257f05c50641aa..cf5e1eb0eb7ca4095ef85c2df69faa54a28f7398 100644 (file)
@@ -182,7 +182,7 @@ fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F
 /// - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict
 ///   between digit and exponent sign `'p'`.
 pub fn float_to_str_bytes_common<T: Float>(
-        num: T, radix: uint, negative_zero: bool,
+        num: T, radix: u32, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_upper: bool
         ) -> (Vec<u8>, bool) {
     assert!(2 <= radix && radix <= 36);
@@ -253,7 +253,7 @@ pub fn float_to_str_bytes_common<T: Float>(
         deccum = deccum / radix_gen;
         deccum = deccum.trunc();
 
-        buf.push(char::from_digit(current_digit.to_int().unwrap() as uint, radix)
+        buf.push(char::from_digit(current_digit.to_int().unwrap() as u32, radix)
              .unwrap() as u8);
 
         // No more digits to calculate for the non-fractional part -> break
@@ -310,7 +310,7 @@ pub fn float_to_str_bytes_common<T: Float>(
             let current_digit = deccum.trunc().abs();
 
             buf.push(char::from_digit(
-                current_digit.to_int().unwrap() as uint, radix).unwrap() as u8);
+                current_digit.to_int().unwrap() as u32, radix).unwrap() as u8);
 
             // Decrease the deccumulator one fractional digit at a time
             deccum = deccum.fract();
@@ -324,7 +324,7 @@ pub fn float_to_str_bytes_common<T: Float>(
             let ascii2value = |chr: u8| {
                 (chr as char).to_digit(radix).unwrap()
             };
-            let value2ascii = |val: uint| {
+            let value2ascii = |val: u32| {
                 char::from_digit(val, radix).unwrap() as u8
             };
 
@@ -412,7 +412,7 @@ pub fn float_to_str_bytes_common<T: Float>(
 /// `to_str_bytes_common()`, for details see there.
 #[inline]
 pub fn float_to_str_common<T: Float>(
-        num: T, radix: uint, negative_zero: bool,
+        num: T, radix: u32, negative_zero: bool,
         sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_capital: bool
         ) -> (String, bool) {
     let (bytes, special) = float_to_str_bytes_common(num, radix,
@@ -422,8 +422,8 @@ pub fn float_to_str_common<T: Float>(
 
 // Some constants for from_str_bytes_common's input validation,
 // they define minimum radix values for which the character is a valid digit.
-static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u;
-static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
+static DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11;
+static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
 
 #[cfg(test)]
 mod tests {
index ecc39925a40c55b495c459b032279c178a05d3a6..cfd80b6755cf95a767279441407c40f5345a0333 100644 (file)
@@ -645,7 +645,7 @@ fn bump_expecting_char<'a,D:fmt::Debug>(r: &mut StringReader<'a>,
 
     /// Scan through any digits (base `radix`) or underscores, and return how
     /// many digits there were.
-    fn scan_digits(&mut self, radix: usize) -> usize {
+    fn scan_digits(&mut self, radix: u32) -> usize {
         let mut len = 0;
         loop {
             let c = self.curr;
index 016dc84b23b9e22ae910d7970c7dda0e04c703eb..82b5ec11d95d1dd8aef5c9f990ade25c9a950d27 100644 (file)
@@ -297,7 +297,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
             PushParam => {
                 // params are 1-indexed
                 stack.push(mparams[match cur.to_digit(10) {
-                    Some(d) => d - 1,
+                    Some(d) => d as usize - 1,
                     None => return Err("bad param number".to_string())
                 }].clone());
             },
index 1fb434f7d76192332c667e6747fa6c317e634563..bfe22712de8c3b2e0b4e5b2092fd6854b8a8b1da 100644 (file)
@@ -19,18 +19,18 @@ macro_rules! t {
 
 pub fn main() {
     // Basic usage
-    t!(to_string(1.2345678e-5f64, 10u, true, SignNeg, DigMax(6), ExpDec, false),
+    t!(to_string(1.2345678e-5f64, 10, true, SignNeg, DigMax(6), ExpDec, false),
              "1.234568e-5");
 
     // Hexadecimal output
-    t!(to_string(7.281738281250e+01f64, 16u, true, SignAll, DigMax(6), ExpBin, false),
+    t!(to_string(7.281738281250e+01f64, 16, true, SignAll, DigMax(6), ExpBin, false),
               "+1.2345p+6");
-    t!(to_string(-1.777768135071e-02f64, 16u, true, SignAll, DigMax(6), ExpBin, false),
+    t!(to_string(-1.777768135071e-02f64, 16, true, SignAll, DigMax(6), ExpBin, false),
              "-1.2345p-6");
 
     // Some denormals
-    t!(to_string(4.9406564584124654e-324f64, 10u, true, SignNeg, DigMax(6), ExpBin, false),
+    t!(to_string(4.9406564584124654e-324f64, 10, true, SignNeg, DigMax(6), ExpBin, false),
              "1p-1074");
-    t!(to_string(2.2250738585072009e-308f64, 10u, true, SignNeg, DigMax(6), ExpBin, false),
+    t!(to_string(2.2250738585072009e-308f64, 10, true, SignNeg, DigMax(6), ExpBin, false),
              "1p-1022");
 }