1
Fork 0

Fix fallout of requiring uint indices

This commit is contained in:
Alex Crichton 2014-04-01 20:39:26 -07:00
parent 46abacfdfe
commit 9a259f4303
29 changed files with 118 additions and 118 deletions

View file

@ -1600,12 +1600,12 @@ mod test_map {
#[deriving(Hash, Eq, TotalEq)] #[deriving(Hash, Eq, TotalEq)]
struct Dropable { struct Dropable {
k: int k: uint
} }
impl Dropable { impl Dropable {
fn new(k: int) -> Dropable { fn new(k: uint) -> Dropable {
local_data::get_mut(drop_vector, local_data::get_mut(drop_vector,
|v| { v.unwrap().as_mut_slice()[k] += 1; }); |v| { v.unwrap().as_mut_slice()[k] += 1; });
@ -1628,24 +1628,24 @@ mod test_map {
let mut m = HashMap::new(); let mut m = HashMap::new();
local_data::get(drop_vector, |v| { 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); 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 d1 = Dropable::new(i);
let d2 = Dropable::new(i+100); let d2 = Dropable::new(i+100);
m.insert(d1, d2); m.insert(d1, d2);
} }
local_data::get(drop_vector, |v| { 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); 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 k = Dropable::new(i);
let v = m.pop(&k); let v = m.pop(&k);
@ -1658,12 +1658,12 @@ mod test_map {
} }
local_data::get(drop_vector, |v| { 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], 0);
assert_eq!(v.unwrap().as_slice()[i+100], 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], 1);
assert_eq!(v.unwrap().as_slice()[i+100], 1); assert_eq!(v.unwrap().as_slice()[i+100], 1);
} }
@ -1671,7 +1671,7 @@ mod test_map {
} }
local_data::get(drop_vector, |v| { 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); assert_eq!(v.unwrap().as_slice()[i], 0);
} }
}); });

View file

@ -296,7 +296,7 @@ mod imp {
} }
pub fn fd_set(set: &mut fd_set, fd: i32) { 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 { extern {
@ -323,7 +323,7 @@ mod imp {
} }
pub fn fd_set(set: &mut fd_set, fd: i32) { 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 { extern {

View file

@ -78,7 +78,7 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>) {
} }
} else { } else {
let remove = { let remove = {
match &chans[idx - 1] { match &chans[idx as uint - 1] {
&(ref c, oneshot) => !c.try_send(()) || oneshot &(ref c, oneshot) => !c.try_send(()) || oneshot
} }
}; };

View file

@ -103,7 +103,7 @@ impl IsaacRng {
if use_rsl { if use_rsl {
macro_rules! memloop ( macro_rules! memloop (
($arr:expr) => {{ ($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]; a+=$arr[i ]; b+=$arr[i+1];
c+=$arr[i+2]; d+=$arr[i+3]; c+=$arr[i+2]; d+=$arr[i+3];
e+=$arr[i+4]; f+=$arr[i+5]; e+=$arr[i+4]; f+=$arr[i+5];
@ -120,7 +120,7 @@ impl IsaacRng {
memloop!(self.rsl); memloop!(self.rsl);
memloop!(self.mem); memloop!(self.mem);
} else { } else {
for i in range_step(0u32, RAND_SIZE, 8) { for i in range_step(0, RAND_SIZE as uint, 8) {
mix!(); mix!();
self.mem[i ]=a; self.mem[i+1]=b; self.mem[i ]=a; self.mem[i+1]=b;
self.mem[i+2]=c; self.mem[i+3]=d; self.mem[i+2]=c; self.mem[i+3]=d;
@ -143,7 +143,7 @@ impl IsaacRng {
static MIDPOINT: uint = RAND_SIZE as uint / 2; static MIDPOINT: uint = RAND_SIZE as uint / 2;
macro_rules! ind (($x:expr) => { macro_rules! ind (($x:expr) => {
self.mem[($x >> 2) & (RAND_SIZE - 1)] self.mem[(($x >> 2) & (RAND_SIZE - 1)) as uint]
}); });
macro_rules! rngstep( macro_rules! rngstep(
($j:expr, $shift:expr) => {{ ($j:expr, $shift:expr) => {{
@ -188,7 +188,7 @@ impl Rng for IsaacRng {
self.isaac(); self.isaac();
} }
self.cnt -= 1; self.cnt -= 1;
self.rsl[self.cnt] self.rsl[self.cnt as uint]
} }
} }

View file

@ -4365,7 +4365,7 @@ pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool {
/*bot*/ [t, t, t, t, t, t, t, t], /*bot*/ [t, t, t, t, t, t, t, t],
/*raw ptr*/ [f, f, f, f, t, t, f, f]]; /*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<t> { pub fn ty_params_to_tys(tcx: &ctxt, generics: &ast::Generics) -> Vec<t> {

View file

@ -791,7 +791,7 @@ mod test {
Ok(10) => {} e => fail!("{:?}", e), Ok(10) => {} e => fail!("{:?}", e),
} }
for i in range(0, 10u8) { for i in range(0, 10u8) {
assert_eq!(buf[i], i + 1); assert_eq!(buf[i as uint], i + 1);
} }
} }
Err(e) => fail!("{:?}", e) Err(e) => fail!("{:?}", e)
@ -827,7 +827,7 @@ mod test {
Ok(10) => {} e => fail!("{:?}", e), Ok(10) => {} e => fail!("{:?}", e),
} }
for i in range(0, 10u8) { for i in range(0, 10u8) {
assert_eq!(buf[i], i + 1); assert_eq!(buf[i as uint], i + 1);
} }
} }
Err(e) => fail!("{:?}", e) Err(e) => fail!("{:?}", e)
@ -859,7 +859,7 @@ mod test {
e => fail!("{:?}", e), e => fail!("{:?}", e),
} }
for i in range(0, 10u8) { for i in range(0, 10u8) {
assert_eq!(buf[i], i + 1); assert_eq!(buf[i as uint], i + 1);
} }
} }
Err(e) => fail!("{:?}", e) Err(e) => fail!("{:?}", e)
@ -891,7 +891,7 @@ mod test {
e => fail!("{:?}", e), e => fail!("{:?}", e),
} }
for i in range(0, 10u8) { for i in range(0, 10u8) {
assert_eq!(buf[i], i + 1); assert_eq!(buf[i as uint], i + 1);
} }
} }
Err(e) => fail!("{:?}", e) Err(e) => fail!("{:?}", e)

View file

@ -99,10 +99,10 @@ impl<'a> ToBase64 for &'a [u8] {
(self[i + 2] as u32); (self[i + 2] as u32);
// This 24-bit number gets separated into four 6-bit numbers. // This 24-bit number gets separated into four 6-bit numbers.
v.push(bytes[(n >> 18) & 63]); v.push(bytes[((n >> 18) & 63) as uint]);
v.push(bytes[(n >> 12) & 63]); v.push(bytes[((n >> 12) & 63) as uint]);
v.push(bytes[(n >> 6 ) & 63]); v.push(bytes[((n >> 6 ) & 63) as uint]);
v.push(bytes[n & 63]); v.push(bytes[(n & 63) as uint]);
cur_length += 4; cur_length += 4;
i += 3; i += 3;
@ -125,8 +125,8 @@ impl<'a> ToBase64 for &'a [u8] {
0 => (), 0 => (),
1 => { 1 => {
let n = (self[i] as u32) << 16; let n = (self[i] as u32) << 16;
v.push(bytes[(n >> 18) & 63]); v.push(bytes[((n >> 18) & 63) as uint]);
v.push(bytes[(n >> 12) & 63]); v.push(bytes[((n >> 12) & 63) as uint]);
if config.pad { if config.pad {
v.push('=' as u8); v.push('=' as u8);
v.push('=' as u8); v.push('=' as u8);
@ -135,9 +135,9 @@ impl<'a> ToBase64 for &'a [u8] {
2 => { 2 => {
let n = (self[i] as u32) << 16 | let n = (self[i] as u32) << 16 |
(self[i + 1u] as u32) << 8; (self[i + 1u] as u32) << 8;
v.push(bytes[(n >> 18) & 63]); v.push(bytes[((n >> 18) & 63) as uint]);
v.push(bytes[(n >> 12) & 63]); v.push(bytes[((n >> 12) & 63) as uint]);
v.push(bytes[(n >> 6 ) & 63]); v.push(bytes[((n >> 6 ) & 63) as uint]);
if config.pad { if config.pad {
v.push('=' as u8); v.push('=' as u8);
} }

View file

@ -41,8 +41,8 @@ impl<'a> ToHex for &'a [u8] {
fn to_hex(&self) -> ~str { fn to_hex(&self) -> ~str {
let mut v = slice::with_capacity(self.len() * 2); let mut v = slice::with_capacity(self.len() * 2);
for &byte in self.iter() { for &byte in self.iter() {
v.push(CHARS[byte >> 4]); v.push(CHARS[(byte >> 4) as uint]);
v.push(CHARS[byte & 0xf]); v.push(CHARS[(byte & 0xf) as uint]);
} }
unsafe { unsafe {

View file

@ -43,19 +43,19 @@ impl Ascii {
/// Convert to lowercase. /// Convert to lowercase.
#[inline] #[inline]
pub fn to_lower(self) -> Ascii { 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. /// Convert to uppercase.
#[inline] #[inline]
pub fn to_upper(self) -> Ascii { 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. /// Compares two ascii characters of equality, ignoring case.
#[inline] #[inline]
pub fn eq_ignore_case(self, other: Ascii) -> bool { 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 // the following methods are like ctype, and the implementation is inspired by musl
@ -370,8 +370,12 @@ impl<'a> StrAsciiExt for &'a str {
#[inline] #[inline]
fn eq_ignore_ascii_case(&self, other: &str) -> bool { fn eq_ignore_ascii_case(&self, other: &str) -> bool {
self.len() == other.len() && self.as_bytes().iter().zip(other.as_bytes().iter()).all( self.len() == other.len() &&
|(byte_self, byte_other)| ASCII_LOWER_MAP[*byte_self] == ASCII_LOWER_MAP[*byte_other]) 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(); let mut bytes = string.into_bytes();
for b in bytes.mut_iter() { for b in bytes.mut_iter() {
*b = map[*b]; *b = map[*b as uint];
} }
str::raw::from_utf8_owned(bytes) str::raw::from_utf8_owned(bytes)
@ -400,7 +404,7 @@ unsafe fn str_map_bytes(string: ~str, map: &'static [u8]) -> ~str {
#[inline] #[inline]
unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> ~str { 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) str::raw::from_utf8_owned(bytes)
} }

View file

@ -254,7 +254,7 @@ pub use comm::select::{Select, Handle};
macro_rules! test ( macro_rules! test (
{ fn $name:ident() $b:block $(#[$a:meta])*} => ( { fn $name:ident() $b:block $(#[$a:meta])*} => (
mod $name { mod $name {
#[allow(unused_imports)]; #![allow(unused_imports)]
use native; use native;
use comm::*; use comm::*;

View file

@ -432,7 +432,7 @@ mod tests {
assert!(f == i && f == v); assert!(f == i && f == v);
buf.push(t as u8); buf.push(t as u8);
state_inc.write_u8(t); state_inc.write_u8(t as u8);
t += 1; t += 1;
} }

View file

@ -21,7 +21,7 @@ use sync::atomics::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
macro_rules! iotest ( macro_rules! iotest (
{ fn $name:ident() $b:block $(#[$a:meta])* } => ( { fn $name:ident() $b:block $(#[$a:meta])* } => (
mod $name { mod $name {
#[allow(unused_imports)]; #![allow(unused_imports)]
use super::super::*; use super::super::*;
use super::*; use super::*;

View file

@ -1655,7 +1655,7 @@ mod tests {
macro_rules! test_next_power_of_two( macro_rules! test_next_power_of_two(
($test_name:ident, $T:ident) => ( ($test_name:ident, $T:ident) => (
fn $test_name() { fn $test_name() {
#[test]; #![test]
assert_eq!(next_power_of_two::<$T>(0), 0); assert_eq!(next_power_of_two::<$T>(0), 0);
let mut next_power = 1; let mut next_power = 1;
for i in range::<$T>(1, 40) { for i in range::<$T>(1, 40) {
@ -1675,7 +1675,7 @@ mod tests {
macro_rules! test_checked_next_power_of_two( macro_rules! test_checked_next_power_of_two(
($test_name:ident, $T:ident) => ( ($test_name:ident, $T:ident) => (
fn $test_name() { fn $test_name() {
#[test]; #![test]
assert_eq!(checked_next_power_of_two::<$T>(0), None); assert_eq!(checked_next_power_of_two::<$T>(0), None);
let mut next_power = 1; let mut next_power = 1;
for i in range::<$T>(1, 40) { for i in range::<$T>(1, 40) {

View file

@ -411,23 +411,23 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
// If reached left end of number, have to // If reached left end of number, have to
// insert additional digit: // insert additional digit:
if i < 0 if i < 0
|| buf[i] == '-' as u8 || buf[i as uint] == '-' as u8
|| buf[i] == '+' as u8 { || buf[i as uint] == '+' as u8 {
buf.insert((i + 1) as uint, value2ascii(1)); buf.insert((i + 1) as uint, value2ascii(1));
break; break;
} }
// Skip the '.' // Skip the '.'
if buf[i] == '.' as u8 { i -= 1; continue; } if buf[i as uint] == '.' as u8 { i -= 1; continue; }
// Either increment the digit, // Either increment the digit,
// or set to 0 if max and carry the 1. // or set to 0 if max and carry the 1.
let current_digit = ascii2value(buf[i]); let current_digit = ascii2value(buf[i as uint]);
if current_digit < (radix - 1) { if current_digit < (radix - 1) {
buf[i] = value2ascii(current_digit+1); buf[i as uint] = value2ascii(current_digit+1);
break; break;
} else { } else {
buf[i] = value2ascii(0); buf[i as uint] = value2ascii(0);
i -= 1; i -= 1;
} }
} }

View file

@ -2922,8 +2922,6 @@ mod tests {
fn square(n: uint) -> uint { n * n } fn square(n: uint) -> uint { n * n }
fn square_ref(n: &uint) -> uint { square(*n) }
fn is_odd(n: &uint) -> bool { *n % 2u == 1u } fn is_odd(n: &uint) -> bool { *n % 2u == 1u }
#[test] #[test]
@ -4441,7 +4439,7 @@ mod bench {
unsafe { unsafe {
v.set_len(1024); v.set_len(1024);
} }
for i in range(0, 1024) { for i in range(0u, 1024) {
v[i] = 0; v[i] = 0;
} }
}); });

View file

@ -1053,7 +1053,7 @@ static UTF8_CHAR_WIDTH: [u8, ..256] = [
/// Given a first byte, determine how many bytes are in this UTF-8 character /// Given a first byte, determine how many bytes are in this UTF-8 character
#[inline] #[inline]
pub fn utf8_char_width(b: u8) -> uint { 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 /// Struct that contains a `char` and the index of the first byte of
@ -2636,7 +2636,7 @@ impl<'a> StrSlice<'a> for &'a str {
// Multibyte case is a fn to allow char_range_at to inline cleanly // Multibyte case is a fn to allow char_range_at to inline cleanly
fn multibyte_char_range_at(s: &str, i: uint) -> CharRange { fn multibyte_char_range_at(s: &str, i: uint) -> CharRange {
let mut val = s[i] as u32; 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)); assert!((w != 0));
val = utf8_first_byte!(val, w); val = utf8_first_byte!(val, w);
@ -2665,7 +2665,7 @@ impl<'a> StrSlice<'a> for &'a str {
} }
let mut val = s[i] as u32; 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)); assert!((w != 0));
val = utf8_first_byte!(val, w); val = utf8_first_byte!(val, w);

View file

@ -780,10 +780,10 @@ impl<'a> Parser<'a> {
-> R { -> R {
let dist = distance as int; let dist = distance as int;
while self.buffer_length() < dist { 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; 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) -> ! { pub fn fatal(&mut self, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(self.span, m) self.sess.span_diagnostic.span_fatal(self.span, m)

View file

@ -293,12 +293,12 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
if cur >= 'A' && cur <= 'Z' { if cur >= 'A' && cur <= 'Z' {
if stack.len() > 0 { if stack.len() > 0 {
let idx = (cur as u8) - ('A' as u8); 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 { return Err(~"stack is empty") }
} else if cur >= 'a' && cur <= 'z' { } else if cur >= 'a' && cur <= 'z' {
if stack.len() > 0 { if stack.len() > 0 {
let idx = (cur as u8) - ('a' as u8); 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(~"stack is empty") }
} else { } else {
return Err(~"bad variable name in %P"); return Err(~"bad variable name in %P");
@ -307,10 +307,10 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
GetVar => { GetVar => {
if cur >= 'A' && cur <= 'Z' { if cur >= 'A' && cur <= 'Z' {
let idx = (cur as u8) - ('A' as u8); 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' { } else if cur >= 'a' && cur <= 'z' {
let idx = (cur as u8) - ('a' as u8); let idx = (cur as u8) - ('a' as u8);
stack.push(vars.dyn[idx].clone()); stack.push(vars.dyn[idx as uint].clone());
} else { } else {
return Err(~"bad variable name in %g"); return Err(~"bad variable name in %g");
} }
@ -563,7 +563,6 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,~str> {
mod test { mod test {
use super::{expand,String,Variables,Number}; use super::{expand,String,Variables,Number};
use std::result::Ok; use std::result::Ok;
use std::vec;
#[test] #[test]
fn test_basic_setabf() { fn test_basic_setabf() {

View file

@ -223,7 +223,7 @@ pub fn parse(file: &mut io::Reader,
if b < 0 { if b < 0 {
return Err(~"error: expected more bools but hit EOF"); return Err(~"error: expected more bools but hit EOF");
} else if b == 1 { } 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 @@ pub fn parse(file: &mut io::Reader,
for i in range(0, numbers_count) { for i in range(0, numbers_count) {
let n = try!(file.read_le_u16()); let n = try!(file.read_le_u16());
if n != 0xFFFF { if n != 0xFFFF {
numbers_map.insert(nnames[i].to_owned(), n); numbers_map.insert(nnames[i as uint].to_owned(), n);
} }
} }
} }

View file

@ -58,8 +58,9 @@ impl Noise2DContext {
} }
fn get_gradient(&self, x: i32, y: i32) -> Vec2 { fn get_gradient(&self, x: i32, y: i32) -> Vec2 {
let idx = self.permutations[x & 255] + self.permutations[y & 255]; let idx = self.permutations[(x & 255) as uint] +
self.rgradients[idx & 255] self.permutations[(y & 255) as uint];
self.rgradients[(idx & 255) as uint]
} }
fn get_gradients(&self, x: f32, y: f32) -> ([Vec2, ..4], [Vec2, ..4]) { fn get_gradients(&self, x: f32, y: f32) -> ([Vec2, ..4], [Vec2, ..4]) {
@ -103,16 +104,16 @@ fn main() {
let n2d = Noise2DContext::new(); let n2d = Noise2DContext::new();
for _ in range(0, 100) { for _ in range(0, 100) {
for y in range(0, 256) { for y in range(0u, 256) {
for x in range(0, 256) { for x in range(0u, 256) {
let v = n2d.get(x as f32 * 0.1, y as f32 * 0.1); let v = n2d.get(x as f32 * 0.1, y as f32 * 0.1);
pixels[y*256+x] = v * 0.5 + 0.5; pixels[y*256+x] = v * 0.5 + 0.5;
} }
} }
} }
for y in range(0, 256) { for y in range(0u, 256) {
for x in range(0, 256) { for x in range(0u, 256) {
let idx = (pixels[y*256+x] / 0.2) as uint; let idx = (pixels[y*256+x] / 0.2) as uint;
print!("{:c}", symbols[idx]); print!("{:c}", symbols[idx]);
} }

View file

@ -30,7 +30,7 @@ fn fannkuch_redux(n: i32) -> i32 {
let mut r = n; let mut r = n;
loop { loop {
while r != 1 { while r != 1 {
count[r - 1] = r; count[r as uint - 1] = r;
r -= 1; r -= 1;
} }
@ -71,13 +71,13 @@ fn fannkuch_redux(n: i32) -> i32 {
let mut i: i32 = 0; let mut i: i32 = 0;
while i < r { while i < r {
let j = i + 1; let j = i + 1;
perm1[i] = perm1[j]; perm1[i as uint] = perm1[j as uint];
i = j; i = j;
} }
perm1[r] = perm0; perm1[r as uint] = perm0;
count[r] -= 1; count[r as uint] -= 1;
if count[r] > 0 { if count[r as uint] > 0 {
break; break;
} }
r += 1; r += 1;

View file

@ -201,7 +201,7 @@ fn pack_symbol(c: u8) -> u8 {
} }
fn unpack_symbol(c: u8) -> u8 { fn unpack_symbol(c: u8) -> u8 {
TABLE[c] TABLE[c as uint]
} }
fn generate_frequencies(frequencies: &mut Table, fn generate_frequencies(frequencies: &mut Table,

View file

@ -255,7 +255,7 @@ fn search(
// for every unused piece // for every unused piece
for id in range(0, 10).filter(|id| board & (1 << (id + 50)) == 0) { for id in range(0, 10).filter(|id| board & (1 << (id + 50)) == 0) {
// for each mask that fits on the board // for each mask that fits on the board
for &m in masks[id].get(i as uint) for &m in masks[id as uint].get(i as uint)
.iter() .iter()
.filter(|&m| board & *m == 0) { .filter(|&m| board & *m == 0) {
// This check is too costy. // This check is too costy.

View file

@ -29,8 +29,8 @@ fn make_complements() -> [u8, ..256] {
} }
let lower = 'A' as u8 - 'a' as u8; let lower = 'A' as u8 - 'a' as u8;
for &(from, to) in transforms.iter() { for &(from, to) in transforms.iter() {
complements[from as u8] = to as u8; complements[from as uint] = to as u8;
complements[from as u8 - lower] = to as u8; complements[(from as u8 - lower) as uint] = to as u8;
} }
complements complements
} }
@ -70,11 +70,11 @@ fn main() {
loop { loop {
match (it.next(), it.next_back()) { match (it.next(), it.next_back()) {
(Some(front), Some(back)) => { (Some(front), Some(back)) => {
let tmp = complements[*front]; let tmp = complements[*front as uint];
*front = complements[*back]; *front = complements[*back as uint];
*back = tmp; *back = tmp;
} }
(Some(last), None) => *last = complements[*last], // last element (Some(last), None) => *last = complements[*last as uint], // last element
_ => break // vector exhausted. _ => break // vector exhausted.
} }
} }

View file

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
let v: Vec<int> = 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
}

View file

@ -211,8 +211,8 @@
// check:$57 = 10 // check:$57 = 10
// debugger:continue // debugger:continue
#[allow(unused_variable)]; #![allow(unused_variable)]
#[allow(dead_assignment)]; #![allow(dead_assignment)]
static mut MUT_INT: int = 0; static mut MUT_INT: int = 0;
@ -366,7 +366,7 @@ fn main() {
zzz(); zzz();
sentinel(); sentinel();
val val as uint
}]; }];
zzz(); zzz();

View file

@ -51,7 +51,7 @@ pub fn main() {
// Now try it with a type that *needs* to be borrowed // Now try it with a type that *needs* to be borrowed
let z = [0,1,2,3]; let z = [0,1,2,3];
// Call a method // 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 // Call a parameterized function
assert_eq!(length::<int, &[int]>(z), z.len()); assert_eq!(length::<int, &[int]>(z), z.len());
} }

View file

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This is a testcase for issue #94.
pub fn main() {
let v: Vec<int> = 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]);
}

View file

@ -44,7 +44,7 @@ pub fn main() {
for ab in a.bytes() { for ab in a.bytes() {
println!("{}", i); println!("{}", i);
println!("{}", ab); println!("{}", ab);
let bb: u8 = b[i]; let bb: u8 = b[i as uint];
println!("{}", bb); println!("{}", bb);
assert_eq!(ab, bb); assert_eq!(ab, bb);
i += 1; i += 1;