Fix remaining bench/debuginfo tests (and a few stragglers)

This commit is contained in:
Niko Matsakis 2015-02-18 09:05:34 -05:00
parent 72eb214ee4
commit 362d713026
23 changed files with 85 additions and 83 deletions

View File

@ -75,7 +75,7 @@ fn read_line() {
let mut path = Path::new(env!("CFG_SRC_DIR"));
path.push("src/test/bench/shootout-k-nucleotide.data");
for _ in 0u..3 {
for _ in 0..3 {
let mut reader = BufferedReader::new(File::open(&path).unwrap());
for _line in reader.lines() {
}
@ -88,7 +88,7 @@ fn vec_plus() {
let mut v = Vec::new();
let mut i = 0;
while i < 1500 {
let rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
let rv = repeat(i).take(r.gen_range(0, i + 1)).collect::<Vec<_>>();
if r.gen() {
v.extend(rv.into_iter());
} else {
@ -106,7 +106,7 @@ fn vec_append() {
let mut v = Vec::new();
let mut i = 0;
while i < 1500 {
let rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
let rv = repeat(i).take(r.gen_range(0, i + 1)).collect::<Vec<_>>();
if r.gen() {
let mut t = v.clone();
t.push_all(&rv);
@ -125,8 +125,8 @@ fn vec_push_all() {
let mut r = rand::thread_rng();
let mut v = Vec::new();
for i in 0u..1500 {
let mut rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
for i in 0..1500 {
let mut rv = repeat(i).take(r.gen_range(0, i + 1)).collect::<Vec<_>>();
if r.gen() {
v.push_all(&rv);
}
@ -139,7 +139,7 @@ fn vec_push_all() {
fn is_utf8_ascii() {
let mut v : Vec<u8> = Vec::new();
for _ in 0u..20000 {
for _ in 0..20000 {
v.push('b' as u8);
if str::from_utf8(&v).is_err() {
panic!("from_utf8 panicked");
@ -150,7 +150,7 @@ fn is_utf8_ascii() {
fn is_utf8_multibyte() {
let s = "b¢€𤭢";
let mut v : Vec<u8> = Vec::new();
for _ in 0u..5000 {
for _ in 0..5000 {
v.push_all(s.as_bytes());
if str::from_utf8(&v).is_err() {
panic!("from_utf8 panicked");

View File

@ -14,7 +14,7 @@ fn main() {
let args = env::args();
let args = if env::var_os("RUST_BENCH").is_some() {
vec!("".to_string(), "10000000".to_string())
} else if args.len() <= 1u {
} else if args.len() <= 1 {
vec!("".to_string(), "100000".to_string())
} else {
args.collect()
@ -22,7 +22,7 @@ fn main() {
let n = args[1].parse().unwrap();
for i in 0u..n {
for i in 0..n {
let x = i.to_string();
println!("{}", x);
}

View File

@ -32,7 +32,7 @@ enum request {
}
fn server(requests: &Receiver<request>, responses: &Sender<uint>) {
let mut count = 0u;
let mut count = 0;
let mut done = false;
while !done {
match requests.recv() {
@ -61,10 +61,10 @@ fn run(args: &[String]) {
let dur = Duration::span(|| {
let (to_child, to_parent, from_parent) = p.take().unwrap();
let mut worker_results = Vec::new();
for _ in 0u..workers {
for _ in 0..workers {
let to_child = to_child.clone();
worker_results.push(thread::spawn(move|| {
for _ in 0u..size / workers {
for _ in 0..size / workers {
//println!("worker {}: sending {} bytes", i, num_bytes);
to_child.send(request::bytes(num_bytes)).unwrap();
}

View File

@ -57,7 +57,7 @@ fn run(args: &[String]) {
let from_parent = if workers == 1 {
let (to_child, from_parent) = channel();
worker_results.push(thread::spawn(move|| {
for _ in 0u..size / workers {
for _ in 0..size / workers {
//println!("worker {}: sending {} bytes", i, num_bytes);
to_child.send(request::bytes(num_bytes));
}
@ -66,10 +66,10 @@ fn run(args: &[String]) {
from_parent
} else {
let (to_child, from_parent) = channel();
for _ in 0u..workers {
for _ in 0..workers {
let to_child = to_child.clone();
worker_results.push(thread::spawn(move|| {
for _ in 0u..size / workers {
for _ in 0..size / workers {
//println!("worker {}: sending {} bytes", i, num_bytes);
to_child.send(request::bytes(num_bytes));
}

View File

@ -50,7 +50,7 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
let mut num_chan = Some(num_chan);
let mut num_port = Some(num_port);
// Send/Receive lots of messages.
for j in 0u..count {
for j in 0..count {
//println!("task %?, iter %?", i, j);
let num_chan2 = num_chan.take().unwrap();
let num_port2 = num_port.take().unwrap();
@ -84,7 +84,7 @@ fn main() {
// create the ring
let mut futures = Vec::new();
for i in 1u..num_tasks {
for i in 1..num_tasks {
//println!("spawning %?", i);
let (new_chan, num_port) = init();
let num_chan_2 = num_chan.clone();

View File

@ -113,8 +113,8 @@ fn main() {
}
}
for y in 0u..256 {
for x in 0u..256 {
for y in 0..256 {
for x in 0..256 {
let idx = (pixels[y*256+x] / 0.2) as uint;
print!("{}", symbols[idx]);
}

View File

@ -233,7 +233,7 @@ fn main() {
std::env::args()
.nth(1)
.and_then(|arg| arg.parse().ok())
.unwrap_or(600us)
.unwrap_or(600)
};
print_complements();

View File

@ -77,7 +77,7 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String {
fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
let key = key.into_ascii_lowercase();
match mm.get(key.as_bytes()) {
option::Option::None => { return 0u; }
option::Option::None => { return 0; }
option::Option::Some(&num) => { return num; }
}
}
@ -98,15 +98,15 @@ fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
fn windows_with_carry<F>(bb: &[u8], nn: uint, mut it: F) -> Vec<u8> where
F: FnMut(&[u8]),
{
let mut ii = 0u;
let mut ii = 0;
let len = bb.len();
while ii < len - (nn - 1u) {
while ii < len - (nn - 1) {
it(&bb[ii..ii+nn]);
ii += 1u;
ii += 1;
}
return bb[len - (nn - 1u)..len].to_vec();
return bb[len - (nn - 1)..len].to_vec();
}
fn make_sequence_processor(sz: uint,
@ -114,7 +114,7 @@ fn make_sequence_processor(sz: uint,
to_parent: &Sender<String>) {
let mut freqs: HashMap<Vec<u8>, uint> = HashMap::new();
let mut carry = Vec::new();
let mut total: uint = 0u;
let mut total: uint = 0;
let mut line: Vec<u8>;
@ -126,20 +126,20 @@ fn make_sequence_processor(sz: uint,
carry.push_all(&line);
carry = windows_with_carry(&carry, sz, |window| {
update_freq(&mut freqs, window);
total += 1u;
total += 1;
});
}
let buffer = match sz {
1u => { sort_and_fmt(&freqs, total) }
2u => { sort_and_fmt(&freqs, total) }
3u => { format!("{}\t{}", find(&freqs, "GGT".to_string()), "GGT") }
4u => { format!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") }
6u => { format!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
12u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
18u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
1 => { sort_and_fmt(&freqs, total) }
2 => { sort_and_fmt(&freqs, total) }
3 => { format!("{}\t{}", find(&freqs, "GGT".to_string()), "GGT") }
4 => { format!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") }
6 => { format!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
12 => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
18 => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
"GGTATTTTAATTTATAGT") }
_ => { "".to_string() }
_ => { "".to_string() }
};
to_parent.send(buffer).unwrap();
@ -158,7 +158,7 @@ fn main() {
let mut rdr = BufferedReader::new(rdr);
// initialize each sequence sorter
let sizes = vec!(1u,2,3,4,6,12,18);
let sizes: Vec<usize> = vec!(1,2,3,4,6,12,18);
let mut streams = (0..sizes.len()).map(|_| {
Some(channel::<String>())
}).collect::<Vec<_>>();
@ -177,7 +177,7 @@ fn main() {
});
to_child
}).collect::<Vec<Sender<Vec<u8> >> >();
}).collect::<Vec<Sender<Vec<u8>>>>();
// latch stores true after we've started
@ -187,7 +187,7 @@ fn main() {
for line in rdr.lines() {
let line = line.unwrap().trim().to_string();
if line.len() == 0u { continue; }
if line.len() == 0 { continue; }
match (line.as_bytes()[0] as char, proc_mode) {

View File

@ -301,7 +301,7 @@ fn main() {
};
let input = Arc::new(input);
let nb_freqs: Vec<_> = (1u..3).map(|i| {
let nb_freqs: Vec<_> = (1..3).map(|i| {
let input = input.clone();
(i, thread::scoped(move|| generate_frequencies(&input, i)))
}).collect();

View File

@ -222,7 +222,7 @@ fn to_vec(raw_sol: &List<u64>) -> Vec<u8> {
let mut sol = repeat('.' as u8).take(50).collect::<Vec<_>>();
for &m in raw_sol.iter() {
let id = '0' as u8 + get_id(m);
for i in 0us..50 {
for i in 0..50 {
if m & 1 << i != 0 {
sol[i] = id;
}
@ -297,7 +297,7 @@ fn search(
let masks_at = &masks[i];
// for every unused piece
for id in (0us..10).filter(|&id| board & (1 << (id + 50)) == 0) {
for id in (0..10).filter(|&id| board & (1 << (id + 50)) == 0) {
// for each mask that fits on the board
for m in masks_at[id].iter().filter(|&m| board & *m == 0) {
// This check is too costly.

View File

@ -69,7 +69,7 @@ fn spectralnorm(n: uint) -> f64 {
let mut u = repeat(1.0).take(n).collect::<Vec<_>>();
let mut v = u.clone();
let mut tmp = v.clone();
for _ in 0u..10 {
for _ in 0..10 {
mult_AtAv(&u, &mut v, &mut tmp);
mult_AtAv(&v, &mut u, &mut tmp);
}

View File

@ -49,8 +49,8 @@ impl Sudoku {
}
pub fn from_vec(vec: &[[u8;9];9]) -> Sudoku {
let g = (0..9u).map(|i| {
(0..9u).map(|j| { vec[i][j] }).collect()
let g = (0..9).map(|i| {
(0..9).map(|j| { vec[i][j] }).collect()
}).collect();
return Sudoku::new(g)
}
@ -68,7 +68,7 @@ impl Sudoku {
.split(',')
.collect();
if comps.len() == 3u {
if comps.len() == 3 {
let row = comps[0].parse::<u8>().unwrap();
let col = comps[1].parse::<u8>().unwrap();
g[row as uint][col as uint] = comps[2].parse().unwrap();
@ -102,7 +102,7 @@ impl Sudoku {
}
}
let mut ptr = 0u;
let mut ptr = 0;
let end = work.len();
while ptr < end {
let (row, col) = work[ptr];
@ -111,11 +111,11 @@ impl Sudoku {
(1 as u8);
if self.next_color(row, col, the_color) {
// yes: advance work list
ptr = ptr + 1u;
ptr = ptr + 1;
} else {
// no: redo this field aft recoloring pred; unless there is none
if ptr == 0u { panic!("No solution found for this sudoku"); }
ptr = ptr - 1u;
if ptr == 0 { panic!("No solution found for this sudoku"); }
ptr = ptr - 1;
}
}
}

View File

@ -12,10 +12,10 @@ use std::env;
use std::thread;
fn f(n: usize) {
let mut i = 0u;
let mut i = 0;
while i < n {
let _ = thread::spawn(move|| g()).join();
i += 1u;
i += 1;
}
}

View File

@ -139,7 +139,7 @@ fn main() {
let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false);
let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 };
let some = Some(110u);
let some = Some(110_usize);
let none: Option<int> = None;
let some_fat = Some("abc");
let none_fat: Option<&'static str> = None;

View File

@ -18,6 +18,6 @@
// Nothing to do here really, just make sure it compiles. See issue #8513.
fn main() {
let _ = ||();
let _ = (1u..3).map(|_| 5);
let _ = (1_usize..3).map(|_| 5);
}

View File

@ -26,7 +26,7 @@
#![omit_gdb_pretty_printer_section]
fn function_with_debuginfo() {
let abc = 10u;
let abc = 10_usize;
return (); // #break
}

View File

@ -129,10 +129,10 @@ fn main() {
let some_str: Option<&'static str> = Some("abc");
let none_str: Option<&'static str> = None;
let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678u) });
let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678_usize) });
let none: Option<&u32> = None;
let full = MoreFields::Full(454545, unsafe { std::mem::transmute(0x87654321u) }, 9988);
let full = MoreFields::Full(454545, unsafe { std::mem::transmute(0x87654321_usize) }, 9988);
let empty = MoreFields::Empty;
let empty_gdb: &MoreFieldsRepr = unsafe { std::mem::transmute(&MoreFields::Empty) };
@ -140,7 +140,7 @@ fn main() {
let droid = NamedFields::Droid {
id: 675675,
range: 10000001,
internals: unsafe { std::mem::transmute(0x43218765u) }
internals: unsafe { std::mem::transmute(0x43218765_usize) }
};
let void_droid = NamedFields::Void;

View File

@ -280,9 +280,9 @@ fn main() {
// Vectors
let fixed_size_vec1 = ([Struct1, Struct1, Struct1], 0i16);
let fixed_size_vec2 = ([0u, 1u, 2u], 0i16);
let fixed_size_vec2 = ([0_usize, 1, 2], 0i16);
let vec1 = vec![0u, 2u, 3u];
let vec1 = vec![0_usize, 2, 3];
let slice1 = &*vec1;
let vec2 = vec![Mod1::Variant2_2(Struct1)];
let slice2 = &*vec2;
@ -301,20 +301,20 @@ fn main() {
&mut Trait2<Mod1::Mod2::Struct3, GenericStruct<usize, isize>>;
// Bare Functions
let rust_fn = (rust_fn, 0u);
let extern_c_fn = (extern_c_fn, 0u);
let unsafe_fn = (unsafe_fn, 0u);
let extern_stdcall_fn = (extern_stdcall_fn, 0u);
let rust_fn = (rust_fn, 0_usize);
let extern_c_fn = (extern_c_fn, 0_usize);
let unsafe_fn = (unsafe_fn, 0_usize);
let extern_stdcall_fn = (extern_stdcall_fn, 0_usize);
let rust_fn_with_return_value = (rust_fn_with_return_value, 0u);
let extern_c_fn_with_return_value = (extern_c_fn_with_return_value, 0u);
let unsafe_fn_with_return_value = (unsafe_fn_with_return_value, 0u);
let extern_stdcall_fn_with_return_value = (extern_stdcall_fn_with_return_value, 0u);
let rust_fn_with_return_value = (rust_fn_with_return_value, 0_usize);
let extern_c_fn_with_return_value = (extern_c_fn_with_return_value, 0_usize);
let unsafe_fn_with_return_value = (unsafe_fn_with_return_value, 0_usize);
let extern_stdcall_fn_with_return_value = (extern_stdcall_fn_with_return_value, 0_usize);
let generic_function_int = (generic_function::<isize>, 0u);
let generic_function_struct3 = (generic_function::<Mod1::Mod2::Struct3>, 0u);
let generic_function_int = (generic_function::<isize>, 0_usize);
let generic_function_struct3 = (generic_function::<Mod1::Mod2::Struct3>, 0_usize);
let variadic_function = (printf, 0u);
let variadic_function = (printf, 0_usize);
// Closures
// I (mw) am a bit unclear about the current state of closures, their
@ -322,8 +322,8 @@ fn main() {
// how that maps to rustc's internal representation of these forms.
// Once closures have reached their 1.0 form, the tests below should
// probably be expanded.
let closure1 = (|x:isize| {}, 0u);
let closure2 = (|x:i8, y: f32| { (x as f32) + y }, 0u);
let closure1 = (|x:isize| {}, 0_usize);
let closure2 = (|x:i8, y: f32| { (x as f32) + y }, 0_usize);
zzz(); // #break
}

View File

@ -67,7 +67,7 @@ fn main() {
closure();
let constant2 = 6u;
let constant2 = 6_usize;
// The `self` argument of the following closure should be passed by value
// to FnOnce::call_once(self, args), which gets translated a bit differently

View File

@ -13,5 +13,5 @@
fn a() -> uint {
1u
1usize
}

View File

@ -23,15 +23,15 @@ extern crate "std" as std;
pub fn foo(_: [i32; (3 as usize)]) { }
pub fn bar() {
const FOO: usize = ((5usize as usize) - (4usize as usize) as usize);
const FOO: usize = ((5 as usize) - (4 as usize) as usize);
let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
let _: [(); (1us as usize)] = ([(() as ())] as [(); 1]);
let _: [(); (1usize as usize)] = ([(() as ())] as [(); 1]);
let _ =
(((&((([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3])
as &[i32; 3]) as *const _ as *const [i32; 3]) as
*const [i32; (3us as usize)] as *const [i32; 3]);
*const [i32; (3usize as usize)] as *const [i32; 3]);
@ -79,16 +79,16 @@ pub fn bar() {
core::fmt::Arguments<'_>))
as collections::string::String);
}
pub type Foo = [i32; (3us as usize)];
pub type Foo = [i32; (3 as usize)];
pub struct Bar {
pub x: [i32; (3us as usize)],
pub x: [i32; (3 as usize)],
}
pub struct TupleBar([i32; (4 as usize)]);
pub enum Baz { BazVariant([i32; (5 as usize)]), }
pub fn id<T>(x: T) -> T { (x as T) }
pub fn use_id() {
let _ =
((id::<[i32; (3us as usize)]> as
((id::<[i32; (3 as usize)]> as
fn([i32; 3]) -> [i32; 3] {id})(([(1 as i32), (2 as i32),
(3 as i32)] as [i32; 3])) as
[i32; 3]);

View File

@ -20,9 +20,9 @@ pub fn bar() {
const FOO: usize = 5 - 4;
let _: [(); FOO] = [()];
let _ : [(); 1us] = [()];
let _ : [(); 1usize] = [()];
let _ = &([1,2,3]) as *const _ as *const [i32; 3us];
let _ = &([1,2,3]) as *const _ as *const [i32; 3usize];
format!("test");
}

View File

@ -82,7 +82,9 @@ pub fn main() {
let mut v = Foo::NestedVariant(box 42usize, SendOnDrop {
sender: sender.clone()
}, sender.clone());
v = Foo::NestedVariant(box 42_usize, SendOnDrop { sender: sender.clone() }, sender.clone());
v = Foo::NestedVariant(box 42_usize,
SendOnDrop { sender: sender.clone() },
sender.clone());
v = Foo::SimpleVariant(sender.clone());
v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } };
})