Skip to content

Commit b1cd769

Browse files
committed
Fix the fallout
1 parent 09f53fd commit b1cd769

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

src/libcore/fmt/float.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum SignFormat {
5353
SignNeg
5454
}
5555

56-
static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11;
56+
static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
5757

5858
/// Converts a number to its string representation as a byte vector.
5959
/// This is meant to be a common base implementation for all numeric string
@@ -87,7 +87,7 @@ static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11;
8787
/// between digit and exponent sign `'p'`.
8888
pub fn float_to_str_bytes_common<T: Float, U, F>(
8989
num: T,
90-
radix: uint,
90+
radix: u32,
9191
negative_zero: bool,
9292
sign: SignFormat,
9393
digits: SignificantDigits,
@@ -156,7 +156,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
156156
deccum = deccum / radix_gen;
157157
deccum = deccum.trunc();
158158

159-
let c = char::from_digit(current_digit.to_int().unwrap() as uint, radix);
159+
let c = char::from_digit(current_digit.to_int().unwrap() as u32, radix);
160160
buf[end] = c.unwrap() as u8;
161161
end += 1;
162162

@@ -211,7 +211,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
211211
// See note in first loop.
212212
let current_digit = deccum.trunc().abs();
213213

214-
let c = char::from_digit(current_digit.to_int().unwrap() as uint,
214+
let c = char::from_digit(current_digit.to_int().unwrap() as u32,
215215
radix);
216216
buf[end] = c.unwrap() as u8;
217217
end += 1;
@@ -228,7 +228,7 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
228228
let ascii2value = |chr: u8| {
229229
(chr as char).to_digit(radix).unwrap()
230230
};
231-
let value2ascii = |val: uint| {
231+
let value2ascii = |val: u32| {
232232
char::from_digit(val, radix).unwrap() as u8
233233
};
234234

src/libcore/num/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1432,12 +1432,12 @@ pub trait Float
14321432
#[unstable(feature = "core", reason = "needs reevaluation")]
14331433
pub trait FromStrRadix {
14341434
type Err;
1435-
fn from_str_radix(str: &str, radix: uint) -> Result<Self, Self::Err>;
1435+
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::Err>;
14361436
}
14371437

14381438
/// A utility function that just calls FromStrRadix::from_str_radix.
14391439
#[unstable(feature = "core", reason = "needs reevaluation")]
1440-
pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: uint)
1440+
pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: u32)
14411441
-> Result<T, T::Err> {
14421442
FromStrRadix::from_str_radix(str, radix)
14431443
}
@@ -1501,7 +1501,7 @@ macro_rules! from_str_radix_float_impl {
15011501
/// `None` if the string did not represent a valid number.
15021502
/// Otherwise, `Some(n)` where `n` is the floating-point number
15031503
/// represented by `src`.
1504-
fn from_str_radix(src: &str, radix: uint)
1504+
fn from_str_radix(src: &str, radix: u32)
15051505
-> Result<$T, ParseFloatError> {
15061506
use self::FloatErrorKind::*;
15071507
use self::ParseFloatError as PFE;
@@ -1661,7 +1661,7 @@ macro_rules! from_str_radix_int_impl {
16611661
#[stable(feature = "rust1", since = "1.0.0")]
16621662
impl FromStrRadix for $T {
16631663
type Err = ParseIntError;
1664-
fn from_str_radix(src: &str, radix: uint)
1664+
fn from_str_radix(src: &str, radix: u32)
16651665
-> Result<$T, ParseIntError> {
16661666
use self::IntErrorKind::*;
16671667
use self::ParseIntError as PIE;

src/libfmt_macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl<'a> Parser<'a> {
422422
Some((_, c)) => {
423423
match c.to_digit(10) {
424424
Some(i) => {
425-
cur = cur * 10 + i;
425+
cur = cur * 10 + i as usize;
426426
found = true;
427427
self.cur.next();
428428
}

src/libstd/num/f32.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl Float for f32 {
369369
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
370370
pub fn to_string(num: f32) -> String {
371371
let (r, _) = strconv::float_to_str_common(
372-
num, 10u, true, SignNeg, DigAll, ExpNone, false);
372+
num, 10, true, SignNeg, DigAll, ExpNone, false);
373373
r
374374
}
375375

@@ -382,7 +382,7 @@ pub fn to_string(num: f32) -> String {
382382
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
383383
pub fn to_str_hex(num: f32) -> String {
384384
let (r, _) = strconv::float_to_str_common(
385-
num, 16u, true, SignNeg, DigAll, ExpNone, false);
385+
num, 16, true, SignNeg, DigAll, ExpNone, false);
386386
r
387387
}
388388

@@ -395,7 +395,7 @@ pub fn to_str_hex(num: f32) -> String {
395395
/// * radix - The base to use
396396
#[inline]
397397
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
398-
pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) {
398+
pub fn to_str_radix_special(num: f32, rdx: u32) -> (String, bool) {
399399
strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false)
400400
}
401401

@@ -410,7 +410,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) {
410410
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
411411
pub fn to_str_exact(num: f32, dig: uint) -> String {
412412
let (r, _) = strconv::float_to_str_common(
413-
num, 10u, true, SignNeg, DigExact(dig), ExpNone, false);
413+
num, 10, true, SignNeg, DigExact(dig), ExpNone, false);
414414
r
415415
}
416416

@@ -425,7 +425,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String {
425425
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
426426
pub fn to_str_digits(num: f32, dig: uint) -> String {
427427
let (r, _) = strconv::float_to_str_common(
428-
num, 10u, true, SignNeg, DigMax(dig), ExpNone, false);
428+
num, 10, true, SignNeg, DigMax(dig), ExpNone, false);
429429
r
430430
}
431431

@@ -441,7 +441,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String {
441441
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
442442
pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String {
443443
let (r, _) = strconv::float_to_str_common(
444-
num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper);
444+
num, 10, true, SignNeg, DigExact(dig), ExpDec, upper);
445445
r
446446
}
447447

@@ -457,7 +457,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String {
457457
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
458458
pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String {
459459
let (r, _) = strconv::float_to_str_common(
460-
num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper);
460+
num, 10, true, SignNeg, DigMax(dig), ExpDec, upper);
461461
r
462462
}
463463

src/libstd/num/f64.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl Float for f64 {
378378
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
379379
pub fn to_string(num: f64) -> String {
380380
let (r, _) = strconv::float_to_str_common(
381-
num, 10u, true, SignNeg, DigAll, ExpNone, false);
381+
num, 10, true, SignNeg, DigAll, ExpNone, false);
382382
r
383383
}
384384

@@ -391,7 +391,7 @@ pub fn to_string(num: f64) -> String {
391391
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
392392
pub fn to_str_hex(num: f64) -> String {
393393
let (r, _) = strconv::float_to_str_common(
394-
num, 16u, true, SignNeg, DigAll, ExpNone, false);
394+
num, 16, true, SignNeg, DigAll, ExpNone, false);
395395
r
396396
}
397397

@@ -404,7 +404,7 @@ pub fn to_str_hex(num: f64) -> String {
404404
/// * radix - The base to use
405405
#[inline]
406406
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
407-
pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) {
407+
pub fn to_str_radix_special(num: f64, rdx: u32) -> (String, bool) {
408408
strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false)
409409
}
410410

@@ -419,7 +419,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) {
419419
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
420420
pub fn to_str_exact(num: f64, dig: uint) -> String {
421421
let (r, _) = strconv::float_to_str_common(
422-
num, 10u, true, SignNeg, DigExact(dig), ExpNone, false);
422+
num, 10, true, SignNeg, DigExact(dig), ExpNone, false);
423423
r
424424
}
425425

@@ -434,7 +434,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String {
434434
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
435435
pub fn to_str_digits(num: f64, dig: uint) -> String {
436436
let (r, _) = strconv::float_to_str_common(
437-
num, 10u, true, SignNeg, DigMax(dig), ExpNone, false);
437+
num, 10, true, SignNeg, DigMax(dig), ExpNone, false);
438438
r
439439
}
440440

@@ -450,7 +450,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String {
450450
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
451451
pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String {
452452
let (r, _) = strconv::float_to_str_common(
453-
num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper);
453+
num, 10, true, SignNeg, DigExact(dig), ExpDec, upper);
454454
r
455455
}
456456

@@ -466,7 +466,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String {
466466
#[unstable(feature = "std_misc", reason = "may be removed or relocated")]
467467
pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String {
468468
let (r, _) = strconv::float_to_str_common(
469-
num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper);
469+
num, 10, true, SignNeg, DigMax(dig), ExpDec, upper);
470470
r
471471
}
472472

src/libstd/num/strconv.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F
182182
/// - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict
183183
/// between digit and exponent sign `'p'`.
184184
pub fn float_to_str_bytes_common<T: Float>(
185-
num: T, radix: uint, negative_zero: bool,
185+
num: T, radix: u32, negative_zero: bool,
186186
sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_upper: bool
187187
) -> (Vec<u8>, bool) {
188188
assert!(2 <= radix && radix <= 36);
@@ -253,7 +253,7 @@ pub fn float_to_str_bytes_common<T: Float>(
253253
deccum = deccum / radix_gen;
254254
deccum = deccum.trunc();
255255

256-
buf.push(char::from_digit(current_digit.to_int().unwrap() as uint, radix)
256+
buf.push(char::from_digit(current_digit.to_int().unwrap() as u32, radix)
257257
.unwrap() as u8);
258258

259259
// No more digits to calculate for the non-fractional part -> break
@@ -310,7 +310,7 @@ pub fn float_to_str_bytes_common<T: Float>(
310310
let current_digit = deccum.trunc().abs();
311311

312312
buf.push(char::from_digit(
313-
current_digit.to_int().unwrap() as uint, radix).unwrap() as u8);
313+
current_digit.to_int().unwrap() as u32, radix).unwrap() as u8);
314314

315315
// Decrease the deccumulator one fractional digit at a time
316316
deccum = deccum.fract();
@@ -324,7 +324,7 @@ pub fn float_to_str_bytes_common<T: Float>(
324324
let ascii2value = |chr: u8| {
325325
(chr as char).to_digit(radix).unwrap()
326326
};
327-
let value2ascii = |val: uint| {
327+
let value2ascii = |val: u32| {
328328
char::from_digit(val, radix).unwrap() as u8
329329
};
330330

@@ -412,7 +412,7 @@ pub fn float_to_str_bytes_common<T: Float>(
412412
/// `to_str_bytes_common()`, for details see there.
413413
#[inline]
414414
pub fn float_to_str_common<T: Float>(
415-
num: T, radix: uint, negative_zero: bool,
415+
num: T, radix: u32, negative_zero: bool,
416416
sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_capital: bool
417417
) -> (String, bool) {
418418
let (bytes, special) = float_to_str_bytes_common(num, radix,
@@ -422,8 +422,8 @@ pub fn float_to_str_common<T: Float>(
422422

423423
// Some constants for from_str_bytes_common's input validation,
424424
// they define minimum radix values for which the character is a valid digit.
425-
static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u;
426-
static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
425+
static DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11;
426+
static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
427427

428428
#[cfg(test)]
429429
mod tests {

src/libsyntax/parse/lexer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl<'a> StringReader<'a> {
645645

646646
/// Scan through any digits (base `radix`) or underscores, and return how
647647
/// many digits there were.
648-
fn scan_digits(&mut self, radix: usize) -> usize {
648+
fn scan_digits(&mut self, radix: u32) -> usize {
649649
let mut len = 0;
650650
loop {
651651
let c = self.curr;

src/libterm/terminfo/parm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
297297
PushParam => {
298298
// params are 1-indexed
299299
stack.push(mparams[match cur.to_digit(10) {
300-
Some(d) => d - 1,
300+
Some(d) => d as usize - 1,
301301
None => return Err("bad param number".to_string())
302302
}].clone());
303303
},

src/test/run-pass/exponential-notation.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ macro_rules! t {
1919

2020
pub fn main() {
2121
// Basic usage
22-
t!(to_string(1.2345678e-5f64, 10u, true, SignNeg, DigMax(6), ExpDec, false),
22+
t!(to_string(1.2345678e-5f64, 10, true, SignNeg, DigMax(6), ExpDec, false),
2323
"1.234568e-5");
2424

2525
// Hexadecimal output
26-
t!(to_string(7.281738281250e+01f64, 16u, true, SignAll, DigMax(6), ExpBin, false),
26+
t!(to_string(7.281738281250e+01f64, 16, true, SignAll, DigMax(6), ExpBin, false),
2727
"+1.2345p+6");
28-
t!(to_string(-1.777768135071e-02f64, 16u, true, SignAll, DigMax(6), ExpBin, false),
28+
t!(to_string(-1.777768135071e-02f64, 16, true, SignAll, DigMax(6), ExpBin, false),
2929
"-1.2345p-6");
3030

3131
// Some denormals
32-
t!(to_string(4.9406564584124654e-324f64, 10u, true, SignNeg, DigMax(6), ExpBin, false),
32+
t!(to_string(4.9406564584124654e-324f64, 10, true, SignNeg, DigMax(6), ExpBin, false),
3333
"1p-1074");
34-
t!(to_string(2.2250738585072009e-308f64, 10u, true, SignNeg, DigMax(6), ExpBin, false),
34+
t!(to_string(2.2250738585072009e-308f64, 10, true, SignNeg, DigMax(6), ExpBin, false),
3535
"1p-1022");
3636
}

0 commit comments

Comments
 (0)