From 9a259f4303cd6550a38ccd12b07ae14c1e21a263 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 1 Apr 2014 20:39:26 -0700 Subject: [PATCH] Fix fallout of requiring uint indices --- src/libcollections/hashmap.rs | 18 ++++++------ src/libnative/io/timer_other.rs | 4 +-- src/libnative/io/timer_win32.rs | 2 +- src/librand/isaac.rs | 8 +++--- src/librustc/middle/ty.rs | 2 +- src/librustuv/net.rs | 8 +++--- src/libserialize/base64.rs | 18 ++++++------ src/libserialize/hex.rs | 4 +-- src/libstd/ascii.rs | 18 +++++++----- src/libstd/comm/mod.rs | 2 +- src/libstd/hash/sip.rs | 2 +- src/libstd/io/test.rs | 2 +- src/libstd/num/mod.rs | 4 +-- src/libstd/num/strconv.rs | 12 ++++---- src/libstd/slice.rs | 4 +-- src/libstd/str.rs | 6 ++-- src/libsyntax/parse/parser.rs | 4 +-- src/libterm/terminfo/parm.rs | 9 +++--- src/libterm/terminfo/parser/compiled.rs | 4 +-- src/test/bench/noise.rs | 13 +++++---- src/test/bench/shootout-fannkuch-redux.rs | 10 +++---- src/test/bench/shootout-k-nucleotide.rs | 2 +- src/test/bench/shootout-meteor.rs | 6 ++-- src/test/bench/shootout-reverse-complement.rs | 10 +++---- src/test/compile-fail/integral-indexing.rs | 26 +++++++++++++++++ .../lexical-scopes-in-block-expression.rs | 6 ++-- src/test/run-pass/assignability-trait.rs | 2 +- src/test/run-pass/integral-indexing.rs | 28 ------------------- src/test/run-pass/utf8.rs | 2 +- 29 files changed, 118 insertions(+), 118 deletions(-) create mode 100644 src/test/compile-fail/integral-indexing.rs delete mode 100644 src/test/run-pass/integral-indexing.rs diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs index 47100559f44..7a51fca6cd5 100644 --- a/src/libcollections/hashmap.rs +++ b/src/libcollections/hashmap.rs @@ -1600,12 +1600,12 @@ fn test_insert() { #[deriving(Hash, Eq, TotalEq)] struct Dropable { - k: int + k: uint } impl Dropable { - fn new(k: int) -> Dropable { + fn new(k: uint) -> Dropable { local_data::get_mut(drop_vector, |v| { v.unwrap().as_mut_slice()[k] += 1; }); @@ -1628,24 +1628,24 @@ fn test_drops() { let mut m = HashMap::new(); local_data::get(drop_vector, |v| { - for i in range(0, 200) { + for i in range(0u, 200) { assert_eq!(v.unwrap().as_slice()[i], 0); } }); - for i in range(0, 100) { + for i in range(0u, 100) { let d1 = Dropable::new(i); let d2 = Dropable::new(i+100); m.insert(d1, d2); } local_data::get(drop_vector, |v| { - for i in range(0, 200) { + for i in range(0u, 200) { assert_eq!(v.unwrap().as_slice()[i], 1); } }); - for i in range(0, 50) { + for i in range(0u, 50) { let k = Dropable::new(i); let v = m.pop(&k); @@ -1658,12 +1658,12 @@ fn test_drops() { } local_data::get(drop_vector, |v| { - for i in range(0, 50) { + for i in range(0u, 50) { assert_eq!(v.unwrap().as_slice()[i], 0); assert_eq!(v.unwrap().as_slice()[i+100], 0); } - for i in range(50, 100) { + for i in range(50u, 100) { assert_eq!(v.unwrap().as_slice()[i], 1); assert_eq!(v.unwrap().as_slice()[i+100], 1); } @@ -1671,7 +1671,7 @@ fn test_drops() { } local_data::get(drop_vector, |v| { - for i in range(0, 200) { + for i in range(0u, 200) { assert_eq!(v.unwrap().as_slice()[i], 0); } }); diff --git a/src/libnative/io/timer_other.rs b/src/libnative/io/timer_other.rs index ea237944bad..7979075aa02 100644 --- a/src/libnative/io/timer_other.rs +++ b/src/libnative/io/timer_other.rs @@ -296,7 +296,7 @@ pub struct fd_set { } pub fn fd_set(set: &mut fd_set, fd: i32) { - set.fds_bits[fd / 32] |= 1 << (fd % 32); + set.fds_bits[(fd / 32) as uint] |= 1 << (fd % 32); } extern { @@ -323,7 +323,7 @@ pub struct fd_set { } pub fn fd_set(set: &mut fd_set, fd: i32) { - set.fds_bits[fd / 64] |= (1 << (fd % 64)) as u64; + set.fds_bits[(fd / 64) as uint] |= (1 << (fd % 64)) as u64; } extern { diff --git a/src/libnative/io/timer_win32.rs b/src/libnative/io/timer_win32.rs index a342afa6854..3e420e45448 100644 --- a/src/libnative/io/timer_win32.rs +++ b/src/libnative/io/timer_win32.rs @@ -78,7 +78,7 @@ fn helper(input: libc::HANDLE, messages: Receiver) { } } else { let remove = { - match &chans[idx - 1] { + match &chans[idx as uint - 1] { &(ref c, oneshot) => !c.try_send(()) || oneshot } }; diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 23371ed2bd8..1d9da40f18b 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -103,7 +103,7 @@ macro_rules! mix( if use_rsl { macro_rules! memloop ( ($arr:expr) => {{ - for i in range_step(0u32, RAND_SIZE, 8) { + for i in range_step(0, RAND_SIZE as uint, 8) { a+=$arr[i ]; b+=$arr[i+1]; c+=$arr[i+2]; d+=$arr[i+3]; e+=$arr[i+4]; f+=$arr[i+5]; @@ -120,7 +120,7 @@ macro_rules! memloop ( memloop!(self.rsl); memloop!(self.mem); } else { - for i in range_step(0u32, RAND_SIZE, 8) { + for i in range_step(0, RAND_SIZE as uint, 8) { mix!(); self.mem[i ]=a; self.mem[i+1]=b; self.mem[i+2]=c; self.mem[i+3]=d; @@ -143,7 +143,7 @@ fn isaac(&mut self) { static MIDPOINT: uint = RAND_SIZE as uint / 2; macro_rules! ind (($x:expr) => { - self.mem[($x >> 2) & (RAND_SIZE - 1)] + self.mem[(($x >> 2) & (RAND_SIZE - 1)) as uint] }); macro_rules! rngstep( ($j:expr, $shift:expr) => {{ @@ -188,7 +188,7 @@ fn next_u32(&mut self) -> u32 { self.isaac(); } self.cnt -= 1; - self.rsl[self.cnt] + self.rsl[self.cnt as uint] } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index e8082e149af..176ed409dd4 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4365,7 +4365,7 @@ fn tycat(cx: &ctxt, ty: t) -> int { /*bot*/ [t, t, t, t, t, t, t, t], /*raw ptr*/ [f, f, f, f, t, t, f, f]]; - return tbl[tycat(cx, ty)][opcat(op)]; + return tbl[tycat(cx, ty) as uint ][opcat(op) as uint]; } pub fn ty_params_to_tys(tcx: &ctxt, generics: &ast::Generics) -> Vec { diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index 0514975cc7b..a6d1e1a6efd 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -791,7 +791,7 @@ fn listen_ip4() { Ok(10) => {} e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + assert_eq!(buf[i as uint], i + 1); } } Err(e) => fail!("{:?}", e) @@ -827,7 +827,7 @@ fn listen_ip6() { Ok(10) => {} e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + assert_eq!(buf[i as uint], i + 1); } } Err(e) => fail!("{:?}", e) @@ -859,7 +859,7 @@ fn udp_recv_ip4() { e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + assert_eq!(buf[i as uint], i + 1); } } Err(e) => fail!("{:?}", e) @@ -891,7 +891,7 @@ fn udp_recv_ip6() { e => fail!("{:?}", e), } for i in range(0, 10u8) { - assert_eq!(buf[i], i + 1); + assert_eq!(buf[i as uint], i + 1); } } Err(e) => fail!("{:?}", e) diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 62e078e26c1..6aad2f5abbf 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -99,10 +99,10 @@ fn to_base64(&self, config: Config) -> ~str { (self[i + 2] as u32); // This 24-bit number gets separated into four 6-bit numbers. - v.push(bytes[(n >> 18) & 63]); - v.push(bytes[(n >> 12) & 63]); - v.push(bytes[(n >> 6 ) & 63]); - v.push(bytes[n & 63]); + v.push(bytes[((n >> 18) & 63) as uint]); + v.push(bytes[((n >> 12) & 63) as uint]); + v.push(bytes[((n >> 6 ) & 63) as uint]); + v.push(bytes[(n & 63) as uint]); cur_length += 4; i += 3; @@ -125,8 +125,8 @@ fn to_base64(&self, config: Config) -> ~str { 0 => (), 1 => { let n = (self[i] as u32) << 16; - v.push(bytes[(n >> 18) & 63]); - v.push(bytes[(n >> 12) & 63]); + v.push(bytes[((n >> 18) & 63) as uint]); + v.push(bytes[((n >> 12) & 63) as uint]); if config.pad { v.push('=' as u8); v.push('=' as u8); @@ -135,9 +135,9 @@ fn to_base64(&self, config: Config) -> ~str { 2 => { let n = (self[i] as u32) << 16 | (self[i + 1u] as u32) << 8; - v.push(bytes[(n >> 18) & 63]); - v.push(bytes[(n >> 12) & 63]); - v.push(bytes[(n >> 6 ) & 63]); + v.push(bytes[((n >> 18) & 63) as uint]); + v.push(bytes[((n >> 12) & 63) as uint]); + v.push(bytes[((n >> 6 ) & 63) as uint]); if config.pad { v.push('=' as u8); } diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index a95c77c7c13..e6658f3b367 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -41,8 +41,8 @@ impl<'a> ToHex for &'a [u8] { fn to_hex(&self) -> ~str { let mut v = slice::with_capacity(self.len() * 2); for &byte in self.iter() { - v.push(CHARS[byte >> 4]); - v.push(CHARS[byte & 0xf]); + v.push(CHARS[(byte >> 4) as uint]); + v.push(CHARS[(byte & 0xf) as uint]); } unsafe { diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index c9112caa1b9..a52658da209 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -43,19 +43,19 @@ pub fn to_char(self) -> char { /// Convert to lowercase. #[inline] pub fn to_lower(self) -> Ascii { - Ascii{chr: ASCII_LOWER_MAP[self.chr]} + Ascii{chr: ASCII_LOWER_MAP[self.chr as uint]} } /// Convert to uppercase. #[inline] pub fn to_upper(self) -> Ascii { - Ascii{chr: ASCII_UPPER_MAP[self.chr]} + Ascii{chr: ASCII_UPPER_MAP[self.chr as uint]} } /// Compares two ascii characters of equality, ignoring case. #[inline] pub fn eq_ignore_case(self, other: Ascii) -> bool { - ASCII_LOWER_MAP[self.chr] == ASCII_LOWER_MAP[other.chr] + ASCII_LOWER_MAP[self.chr as uint] == ASCII_LOWER_MAP[other.chr as uint] } // the following methods are like ctype, and the implementation is inspired by musl @@ -370,8 +370,12 @@ fn to_ascii_lower(&self) -> ~str { #[inline] fn eq_ignore_ascii_case(&self, other: &str) -> bool { - self.len() == other.len() && self.as_bytes().iter().zip(other.as_bytes().iter()).all( - |(byte_self, byte_other)| ASCII_LOWER_MAP[*byte_self] == ASCII_LOWER_MAP[*byte_other]) + self.len() == other.len() && + self.as_bytes().iter().zip(other.as_bytes().iter()).all( + |(byte_self, byte_other)| { + ASCII_LOWER_MAP[*byte_self as uint] == + ASCII_LOWER_MAP[*byte_other as uint] + }) } } @@ -392,7 +396,7 @@ unsafe fn str_map_bytes(string: ~str, map: &'static [u8]) -> ~str { let mut bytes = string.into_bytes(); for b in bytes.mut_iter() { - *b = map[*b]; + *b = map[*b as uint]; } str::raw::from_utf8_owned(bytes) @@ -400,7 +404,7 @@ unsafe fn str_map_bytes(string: ~str, map: &'static [u8]) -> ~str { #[inline] unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> ~str { - let bytes = string.bytes().map(|b| map[b]).collect::<~[_]>(); + let bytes = string.bytes().map(|b| map[b as uint]).collect::<~[_]>(); str::raw::from_utf8_owned(bytes) } diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index e951077ac83..d01c4913b32 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -254,7 +254,7 @@ macro_rules! test ( { fn $name:ident() $b:block $(#[$a:meta])*} => ( mod $name { - #[allow(unused_imports)]; + #![allow(unused_imports)] use native; use comm::*; diff --git a/src/libstd/hash/sip.rs b/src/libstd/hash/sip.rs index d780c30d850..6217ff0f58c 100644 --- a/src/libstd/hash/sip.rs +++ b/src/libstd/hash/sip.rs @@ -432,7 +432,7 @@ fn result_str(h: u64) -> ~str { assert!(f == i && f == v); buf.push(t as u8); - state_inc.write_u8(t); + state_inc.write_u8(t as u8); t += 1; } diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index d5bd7ad24f8..14b9b5c1e06 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -21,7 +21,7 @@ macro_rules! iotest ( { fn $name:ident() $b:block $(#[$a:meta])* } => ( mod $name { - #[allow(unused_imports)]; + #![allow(unused_imports)] use super::super::*; use super::*; diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 2c628112957..761bd072bf8 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -1655,7 +1655,7 @@ fn test_checked_mul() { macro_rules! test_next_power_of_two( ($test_name:ident, $T:ident) => ( fn $test_name() { - #[test]; + #![test] assert_eq!(next_power_of_two::<$T>(0), 0); let mut next_power = 1; for i in range::<$T>(1, 40) { @@ -1675,7 +1675,7 @@ fn $test_name() { macro_rules! test_checked_next_power_of_two( ($test_name:ident, $T:ident) => ( fn $test_name() { - #[test]; + #![test] assert_eq!(checked_next_power_of_two::<$T>(0), None); let mut next_power = 1; for i in range::<$T>(1, 40) { diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 15c7b251fa7..b15b5872fc2 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -411,23 +411,23 @@ pub fn float_to_str_bytes_common uint { n * n } - fn square_ref(n: &uint) -> uint { square(*n) } - fn is_odd(n: &uint) -> bool { *n % 2u == 1u } #[test] @@ -4441,7 +4439,7 @@ fn zero_1kb_loop_set(bh: &mut BenchHarness) { unsafe { v.set_len(1024); } - for i in range(0, 1024) { + for i in range(0u, 1024) { v[i] = 0; } }); diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 408d236ccc6..1d80af70b97 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -1053,7 +1053,7 @@ pub fn with_capacity(capacity: uint) -> ~str { /// Given a first byte, determine how many bytes are in this UTF-8 character #[inline] pub fn utf8_char_width(b: u8) -> uint { - return UTF8_CHAR_WIDTH[b] as uint; + return UTF8_CHAR_WIDTH[b as uint] as uint; } /// Struct that contains a `char` and the index of the first byte of @@ -2636,7 +2636,7 @@ fn char_range_at(&self, i: uint) -> CharRange { // Multibyte case is a fn to allow char_range_at to inline cleanly fn multibyte_char_range_at(s: &str, i: uint) -> CharRange { let mut val = s[i] as u32; - let w = UTF8_CHAR_WIDTH[val] as uint; + let w = UTF8_CHAR_WIDTH[val as uint] as uint; assert!((w != 0)); val = utf8_first_byte!(val, w); @@ -2665,7 +2665,7 @@ fn multibyte_char_range_at_reverse(s: &str, mut i: uint) -> CharRange { } let mut val = s[i] as u32; - let w = UTF8_CHAR_WIDTH[val] as uint; + let w = UTF8_CHAR_WIDTH[val as uint] as uint; assert!((w != 0)); val = utf8_first_byte!(val, w); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 83cc92d4828..b3e488a464d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -780,10 +780,10 @@ pub fn look_ahead(&mut self, distance: uint, f: |&token::Token| -> R) -> R { let dist = distance as int; while self.buffer_length() < dist { - self.buffer[self.buffer_end] = self.reader.next_token(); + self.buffer[self.buffer_end as uint] = self.reader.next_token(); self.buffer_end = (self.buffer_end + 1) & 3; } - f(&self.buffer[(self.buffer_start + dist - 1) & 3].tok) + f(&self.buffer[((self.buffer_start + dist - 1) & 3) as uint].tok) } pub fn fatal(&mut self, m: &str) -> ! { self.sess.span_diagnostic.span_fatal(self.span, m) diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index aed752fcb09..408d452adba 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -293,12 +293,12 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) if cur >= 'A' && cur <= 'Z' { if stack.len() > 0 { let idx = (cur as u8) - ('A' as u8); - vars.sta[idx] = stack.pop().unwrap(); + vars.sta[idx as uint] = stack.pop().unwrap(); } else { return Err(~"stack is empty") } } else if cur >= 'a' && cur <= 'z' { if stack.len() > 0 { let idx = (cur as u8) - ('a' as u8); - vars.dyn[idx] = stack.pop().unwrap(); + vars.dyn[idx as uint] = stack.pop().unwrap(); } else { return Err(~"stack is empty") } } else { return Err(~"bad variable name in %P"); @@ -307,10 +307,10 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) GetVar => { if cur >= 'A' && cur <= 'Z' { let idx = (cur as u8) - ('A' as u8); - stack.push(vars.sta[idx].clone()); + stack.push(vars.sta[idx as uint].clone()); } else if cur >= 'a' && cur <= 'z' { let idx = (cur as u8) - ('a' as u8); - stack.push(vars.dyn[idx].clone()); + stack.push(vars.dyn[idx as uint].clone()); } else { return Err(~"bad variable name in %g"); } @@ -563,7 +563,6 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result ,~str> { mod test { use super::{expand,String,Variables,Number}; use std::result::Ok; - use std::vec; #[test] fn test_basic_setabf() { diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index edaa55a6603..6d87d91ffc0 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -223,7 +223,7 @@ macro_rules! try( ($e:expr) => ( if b < 0 { return Err(~"error: expected more bools but hit EOF"); } else if b == 1 { - bools_map.insert(bnames[i].to_owned(), true); + bools_map.insert(bnames[i as uint].to_owned(), true); } } } @@ -237,7 +237,7 @@ macro_rules! try( ($e:expr) => ( for i in range(0, numbers_count) { let n = try!(file.read_le_u16()); if n != 0xFFFF { - numbers_map.insert(nnames[i].to_owned(), n); + numbers_map.insert(nnames[i as uint].to_owned(), n); } } } diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index babf3f737fb..7e41fdea778 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -58,8 +58,9 @@ fn new() -> Noise2DContext { } fn get_gradient(&self, x: i32, y: i32) -> Vec2 { - let idx = self.permutations[x & 255] + self.permutations[y & 255]; - self.rgradients[idx & 255] + let idx = self.permutations[(x & 255) as uint] + + self.permutations[(y & 255) as uint]; + self.rgradients[(idx & 255) as uint] } fn get_gradients(&self, x: f32, y: f32) -> ([Vec2, ..4], [Vec2, ..4]) { @@ -103,16 +104,16 @@ fn main() { let n2d = Noise2DContext::new(); for _ in range(0, 100) { - for y in range(0, 256) { - for x in range(0, 256) { + for y in range(0u, 256) { + for x in range(0u, 256) { let v = n2d.get(x as f32 * 0.1, y as f32 * 0.1); pixels[y*256+x] = v * 0.5 + 0.5; } } } - for y in range(0, 256) { - for x in range(0, 256) { + for y in range(0u, 256) { + for x in range(0u, 256) { let idx = (pixels[y*256+x] / 0.2) as uint; print!("{:c}", symbols[idx]); } diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 8d860206d0c..e650367c6f5 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -30,7 +30,7 @@ fn fannkuch_redux(n: i32) -> i32 { let mut r = n; loop { while r != 1 { - count[r - 1] = r; + count[r as uint - 1] = r; r -= 1; } @@ -71,13 +71,13 @@ fn fannkuch_redux(n: i32) -> i32 { let mut i: i32 = 0; while i < r { let j = i + 1; - perm1[i] = perm1[j]; + perm1[i as uint] = perm1[j as uint]; i = j; } - perm1[r] = perm0; + perm1[r as uint] = perm0; - count[r] -= 1; - if count[r] > 0 { + count[r as uint] -= 1; + if count[r as uint] > 0 { break; } r += 1; diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 71d900ba03a..7ceaaa7ad22 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -201,7 +201,7 @@ fn pack_symbol(c: u8) -> u8 { } fn unpack_symbol(c: u8) -> u8 { - TABLE[c] + TABLE[c as uint] } fn generate_frequencies(frequencies: &mut Table, diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index b26053bdf35..45ce1776620 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -255,9 +255,9 @@ fn search( // for every unused piece for id in range(0, 10).filter(|id| board & (1 << (id + 50)) == 0) { // for each mask that fits on the board - for &m in masks[id].get(i as uint) - .iter() - .filter(|&m| board & *m == 0) { + for &m in masks[id as uint].get(i as uint) + .iter() + .filter(|&m| board & *m == 0) { // This check is too costy. //if is_board_unfeasible(board | m, masks) {continue;} if !search(masks, board | m, i + 1, Cons(m, &cur), data) { diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index acd6620d4af..a96e9e9f81a 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -29,8 +29,8 @@ fn make_complements() -> [u8, ..256] { } let lower = 'A' as u8 - 'a' as u8; for &(from, to) in transforms.iter() { - complements[from as u8] = to as u8; - complements[from as u8 - lower] = to as u8; + complements[from as uint] = to as u8; + complements[(from as u8 - lower) as uint] = to as u8; } complements } @@ -70,11 +70,11 @@ fn main() { loop { match (it.next(), it.next_back()) { (Some(front), Some(back)) => { - let tmp = complements[*front]; - *front = complements[*back]; + let tmp = complements[*front as uint]; + *front = complements[*back as uint]; *back = tmp; } - (Some(last), None) => *last = complements[*last], // last element + (Some(last), None) => *last = complements[*last as uint], // last element _ => break // vector exhausted. } } diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs new file mode 100644 index 00000000000..feda4be87ac --- /dev/null +++ b/src/test/compile-fail/integral-indexing.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let v: Vec = vec!(0, 1, 2, 3, 4, 5); + let s: ~str = ~"abcdef"; + assert_eq!(v.as_slice()[3u], 3); + assert_eq!(v.as_slice()[3u8], 3); //~ ERROR: mismatched types + assert_eq!(v.as_slice()[3i8], 3); //~ ERROR: mismatched types + assert_eq!(v.as_slice()[3u32], 3); //~ ERROR: mismatched types + assert_eq!(v.as_slice()[3i32], 3); //~ ERROR: mismatched types + println!("{}", v.as_slice()[3u8]); //~ ERROR: mismatched types + assert_eq!(s[3u], 'd' as u8); + assert_eq!(s[3u8], 'd' as u8); //~ ERROR: mismatched types + assert_eq!(s[3i8], 'd' as u8); //~ ERROR: mismatched types + assert_eq!(s[3u32], 'd' as u8); //~ ERROR: mismatched types + assert_eq!(s[3i32], 'd' as u8); //~ ERROR: mismatched types + println!("{}", s[3u8]); //~ ERROR: mismatched types +} diff --git a/src/test/debug-info/lexical-scopes-in-block-expression.rs b/src/test/debug-info/lexical-scopes-in-block-expression.rs index 72611e3bafa..2a3fbecad9d 100644 --- a/src/test/debug-info/lexical-scopes-in-block-expression.rs +++ b/src/test/debug-info/lexical-scopes-in-block-expression.rs @@ -211,8 +211,8 @@ // check:$57 = 10 // debugger:continue -#[allow(unused_variable)]; -#[allow(dead_assignment)]; +#![allow(unused_variable)] +#![allow(dead_assignment)] static mut MUT_INT: int = 0; @@ -366,7 +366,7 @@ fn main() { zzz(); sentinel(); - val + val as uint }]; zzz(); diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 2682d9e54bc..dddec5a5624 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -51,7 +51,7 @@ pub fn main() { // Now try it with a type that *needs* to be borrowed let z = [0,1,2,3]; // Call a method - z.iterate(|y| { assert!(z[*y] == *y); true }); + z.iterate(|y| { assert!(z[*y as uint] == *y); true }); // Call a parameterized function assert_eq!(length::(z), z.len()); } diff --git a/src/test/run-pass/integral-indexing.rs b/src/test/run-pass/integral-indexing.rs deleted file mode 100644 index b3885691093..00000000000 --- a/src/test/run-pass/integral-indexing.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// This is a testcase for issue #94. -pub fn main() { - let v: Vec = vec!(0, 1, 2, 3, 4, 5); - let s: ~str = ~"abcdef"; - assert_eq!(v.as_slice()[3u], 3); - assert_eq!(v.as_slice()[3u8], 3); - assert_eq!(v.as_slice()[3i8], 3); - assert_eq!(v.as_slice()[3u32], 3); - assert_eq!(v.as_slice()[3i32], 3); - println!("{}", v.as_slice()[3u8]); - assert_eq!(s[3u], 'd' as u8); - assert_eq!(s[3u8], 'd' as u8); - assert_eq!(s[3i8], 'd' as u8); - assert_eq!(s[3u32], 'd' as u8); - assert_eq!(s[3i32], 'd' as u8); - println!("{}", s[3u8]); -} diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index 9531563fcbe..c7763617269 100644 --- a/src/test/run-pass/utf8.rs +++ b/src/test/run-pass/utf8.rs @@ -44,7 +44,7 @@ fn check_str_eq(a: ~str, b: ~str) { for ab in a.bytes() { println!("{}", i); println!("{}", ab); - let bb: u8 = b[i]; + let bb: u8 = b[i as uint]; println!("{}", bb); assert_eq!(ab, bb); i += 1;