diff options
Diffstat (limited to 'src/test')
202 files changed, 650 insertions, 654 deletions
diff --git a/src/test/auxiliary/cci_class_6.rs b/src/test/auxiliary/cci_class_6.rs index a6d6372f88f..8258a668f46 100644 --- a/src/test/auxiliary/cci_class_6.rs +++ b/src/test/auxiliary/cci_class_6.rs @@ -9,6 +9,8 @@ // except according to those terms. pub mod kitties { + use std::vec_ng::Vec; + pub struct cat<U> { priv info : Vec<U> , priv meows : uint, diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index a9be1e62195..8386a6f78c1 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -11,6 +11,7 @@ #[feature(managed_boxes)]; use std::cell::RefCell; +use std::vec_ng::Vec; pub struct Entry<A,B> { key: A, diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index ac8d3181227..191313263aa 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -10,12 +10,14 @@ #[crate_id="cci_no_inline_lib"]; +use std::vec_ng::Vec; + // same as cci_iter_lib, more-or-less, but not marked inline pub fn iter(v: Vec<uint> , f: |uint|) { let mut i = 0u; let n = v.len(); while i < n { - f(v[i]); + f(*v.get(i)); i += 1u; } } diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index e4b8b9e166d..6bea93e953b 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -15,11 +15,12 @@ extern crate collections; use std::cell::RefCell; +use std::vec_ng::Vec; use collections::HashMap; -pub type header_map = HashMap<~str, @RefCell<vec!(@~str)>>; +pub type header_map = HashMap<~str, @RefCell<Vec<@~str>>>; // the unused ty param is necessary so this gets monomorphized pub fn request<T>(req: &header_map) { - let _x = (*((**req.get(&~"METHOD")).clone()).get()[0u]).clone(); + let _x = (**((**req.get(&~"METHOD")).clone()).get().get(0)).clone(); } diff --git a/src/test/auxiliary/issue_2723_a.rs b/src/test/auxiliary/issue_2723_a.rs index 3323e56e8f4..57acf3a7a91 100644 --- a/src/test/auxiliary/issue_2723_a.rs +++ b/src/test/auxiliary/issue_2723_a.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + pub unsafe fn f(xs: Vec<int> ) { xs.map(|_x| { unsafe fn q() { fail!(); } }); } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index edac363eb1a..d0655a43d15 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -20,7 +20,6 @@ use rand::Rng; use std::mem::swap; use std::os; use std::str; -use std::slice; use std::vec; use std::io::File; @@ -89,11 +88,11 @@ fn vec_plus() { let mut v = Vec::new(); let mut i = 0; while i < 1500 { - let rv = slice::from_elem(r.gen_range(0u, i + 1), i); + let rv = Vec::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { v.push_all_move(rv); } else { - v = rv + v; + v = vec::append(rv.clone(), v.as_slice()); } i += 1; } @@ -105,12 +104,12 @@ fn vec_append() { let mut v = Vec::new(); let mut i = 0; while i < 1500 { - let rv = slice::from_elem(r.gen_range(0u, i + 1), i); + let rv = Vec::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { - v = vec::append(v, rv); + v = vec::append(v.clone(), rv.as_slice()); } else { - v = vec::append(rv, v); + v = vec::append(rv.clone(), v.as_slice()); } i += 1; } @@ -121,13 +120,13 @@ fn vec_push_all() { let mut v = Vec::new(); for i in range(0u, 1500) { - let mut rv = slice::from_elem(r.gen_range(0u, i + 1), i); + let mut rv = Vec::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { - v.push_all(rv); + v.push_all(rv.as_slice()); } else { swap(&mut v, &mut rv); - v.push_all(rv); + v.push_all(rv.as_slice()); } } } @@ -136,7 +135,7 @@ fn is_utf8_ascii() { let mut v : Vec<u8> = Vec::new(); for _ in range(0u, 20000) { v.push('b' as u8); - if !str::is_utf8(v) { + if !str::is_utf8(v.as_slice()) { fail!("is_utf8 failed"); } } @@ -147,7 +146,7 @@ fn is_utf8_multibyte() { let mut v : Vec<u8> = Vec::new(); for _ in range(0u, 5000) { v.push_all(s.as_bytes()); - if !str::is_utf8(v) { + if !str::is_utf8(v.as_slice()) { fail!("is_utf8 failed"); } } diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index 07571b17905..f5566172287 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -10,6 +10,7 @@ use std::os; use std::uint; +use std::vec_ng::Vec; fn main() { let args = os::args(); @@ -18,10 +19,10 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"100000") } else { - args + args.move_iter().collect() }; - let n = from_str::<uint>(args[1]).unwrap(); + let n = from_str::<uint>(*args.get(1)).unwrap(); for i in range(0u, n) { let x = i.to_str(); diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index ea07320dd94..ff7ef27e1b9 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -24,6 +24,7 @@ use std::comm; use std::os; use std::task; use std::uint; +use std::vec_ng::Vec; fn move_out<T>(_x: T) {} @@ -100,9 +101,9 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"10000", ~"4") } else { - args.clone() + args.clone().move_iter().collect() }; println!("{:?}", args); - run(args); + run(args.as_slice()); } diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 7e2c5ba46b2..0f0cb9c59d5 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -19,6 +19,7 @@ extern crate time; use std::os; use std::task; use std::uint; +use std::vec_ng::Vec; fn move_out<T>(_x: T) {} @@ -110,9 +111,9 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"10000", ~"4") } else { - args.clone() + args.clone().move_iter().collect() }; println!("{:?}", args); - run(args); + run(args.as_slice()); } diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 7cd904d7d14..a0758624042 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -23,6 +23,7 @@ use sync::MutexArc; use sync::Future; use std::os; use std::uint; +use std::vec_ng::Vec; // A poor man's pipe. type pipe = MutexArc<Vec<uint> >; @@ -75,11 +76,11 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"10", ~"100") } else { - args.clone() + args.clone().move_iter().collect() }; - let num_tasks = from_str::<uint>(args[1]).unwrap(); - let msg_per_task = from_str::<uint>(args[2]).unwrap(); + let num_tasks = from_str::<uint>(*args.get(1)).unwrap(); + let msg_per_task = from_str::<uint>(*args.get(2)).unwrap(); let (mut num_chan, num_port) = init(); diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index c615c510465..de5dff89bad 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -22,6 +22,7 @@ use sync::RWArc; use sync::Future; use std::os; use std::uint; +use std::vec_ng::Vec; // A poor man's pipe. type pipe = RWArc<Vec<uint> >; @@ -70,11 +71,11 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"10", ~"100") } else { - args.clone() + args.clone().move_iter().collect() }; - let num_tasks = from_str::<uint>(args[1]).unwrap(); - let msg_per_task = from_str::<uint>(args[2]).unwrap(); + let num_tasks = from_str::<uint>(*args.get(1)).unwrap(); + let msg_per_task = from_str::<uint>(*args.get(2)).unwrap(); let (mut num_chan, num_port) = init(); diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index 00075415f49..72df2e7b86f 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::os; +use std::vec_ng::Vec; fn ack(m: int, n: int) -> int { if m == 0 { @@ -29,8 +30,8 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"8") } else { - args + args.move_iter().collect() }; - let n = from_str::<int>(args[1]).unwrap(); + let n = from_str::<int>(*args.get(1)).unwrap(); println!("Ack(3,{}): {}\n", n, ack(3, n)); } diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index c4671b4203f..29513d87153 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -13,6 +13,7 @@ use std::option; use std::os; use std::task; +use std::vec_ng::Vec; fn print_complements() { let all = [Blue, Red, Yellow]; @@ -39,7 +40,7 @@ fn show_color(cc: color) -> ~str { } } -fn show_color_list(set: vec!(color)) -> ~str { +fn show_color_list(set: Vec<color>) -> ~str { let mut out = ~""; for col in set.iter() { out.push_char(' '); @@ -132,7 +133,7 @@ fn creature( } } -fn rendezvous(nn: uint, set: vec!(color)) { +fn rendezvous(nn: uint, set: Vec<color>) { // these ports will allow us to hear from the creatures let (to_rendezvous, from_creatures) = channel::<CreatureInfo>(); @@ -141,7 +142,7 @@ fn rendezvous(nn: uint, set: vec!(color)) { // these channels will be passed to the creatures so they can talk to us // these channels will allow us to talk to each creature by 'name'/index - let to_creature: Vec<Sender<Option<CreatureInfo>>> = + let mut to_creature: Vec<Sender<Option<CreatureInfo>>> = set.iter().enumerate().map(|(ii, col)| { // create each creature as a listener with a port, and // give us a channel to talk to each @@ -164,13 +165,13 @@ fn rendezvous(nn: uint, set: vec!(color)) { // set up meetings... for _ in range(0, nn) { - let fst_creature: CreatureInfo = from_creatures.recv(); - let snd_creature: CreatureInfo = from_creatures.recv(); + let mut fst_creature: CreatureInfo = from_creatures.recv(); + let mut snd_creature: CreatureInfo = from_creatures.recv(); creatures_met += 2; - to_creature[fst_creature.name].send(Some(snd_creature)); - to_creature[snd_creature.name].send(Some(fst_creature)); + to_creature.get_mut(fst_creature.name).send(Some(snd_creature)); + to_creature.get_mut(snd_creature.name).send(Some(fst_creature)); } // tell each creature to stop @@ -203,10 +204,10 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"600") } else { - args + args.move_iter().collect() }; - let nn = from_str::<uint>(args[1]).unwrap(); + let nn = from_str::<uint>(*args.get(1)).unwrap(); print_complements(); println!(""); diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index a21963ee0a9..f05f80a20d7 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -68,7 +68,8 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> { a_i.p = p * LOOKUP_SCALE; result.push(a_i); } - result[result.len() - 1].p = LOOKUP_SCALE; + let result_len = result.len(); + result.get_mut(result_len - 1).p = LOOKUP_SCALE; result } @@ -193,12 +194,12 @@ fn main() { out.write_line(">TWO IUB ambiguity codes").unwrap(); let iub = sum_and_scale(IUB); - let mut random = RandomFasta::new(&mut out, iub); + let mut random = RandomFasta::new(&mut out, iub.as_slice()); random.make(n * 3).unwrap(); random.out.write_line(">THREE Homo sapiens frequency").unwrap(); let homo_sapiens = sum_and_scale(HOMO_SAPIENS); - random.lookup = make_lookup(homo_sapiens); + random.lookup = make_lookup(homo_sapiens.as_slice()); random.make(n * 5).unwrap(); random.out.write_str("\n").unwrap(); diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 76ac8407d60..017099bbafa 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -18,6 +18,7 @@ use std::io; use std::io::{BufferedWriter, File}; use std::cmp::min; use std::os; +use std::vec_ng::Vec; static LINE_LENGTH: uint = 60; static IM: u32 = 139968; diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index eec54198c04..a363d19b328 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::os; +use std::vec_ng::Vec; fn fib(n: int) -> int { if n < 2 { @@ -25,8 +26,8 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"30") } else { - args + args.move_iter().collect() }; - let n = from_str::<int>(args[1]).unwrap(); + let n = from_str::<int>(*args.get(1)).unwrap(); println!("{}\n", fib(n)); } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 1b1a41e610c..fd5e5ca2eed 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -68,7 +68,10 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> ~str { for &(ref k, v) in pairs_sorted.iter() { unsafe { buffer.push_str(format!("{} {:0.3f}\n", - k.to_ascii().to_upper().into_str(), v)); + k.as_slice() + .to_ascii() + .to_upper() + .into_str(), v)); } } @@ -86,7 +89,7 @@ fn find(mm: &HashMap<Vec<u8> , uint>, key: ~str) -> uint { // given a map, increment the counter for a key fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) { - let key = key.to_owned(); + let key = Vec::from_slice(key); let newval = match mm.pop(&key) { Some(v) => v + 1, None => 1 @@ -94,7 +97,7 @@ fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) { mm.insert(key, newval); } -// given a ~[u8], for each window call a function +// given a Vec<u8>, for each window call a function // i.e., for "hello" and windows of size four, // run it("hell") and it("ello"), then return "llo" fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> { @@ -106,7 +109,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> { ii += 1u; } - return bb.slice(len - (nn - 1u), len).to_owned(); + return Vec::from_slice(bb.slice(len - (nn - 1u), len)); } fn make_sequence_processor(sz: uint, @@ -116,14 +119,17 @@ fn make_sequence_processor(sz: uint, let mut carry = Vec::new(); let mut total: uint = 0u; - let mut line: Vec<u8> ; + let mut line: Vec<u8>; loop { line = from_parent.recv(); if line == Vec::new() { break; } - carry = windows_with_carry(carry + line, sz, |window| { + carry = windows_with_carry(vec::append(carry, + line.as_slice()).as_slice(), + sz, + |window| { update_freq(&mut freqs, window); total += 1u; }); @@ -203,8 +209,8 @@ fn main() { let line_bytes = line.as_bytes(); for (ii, _sz) in sizes.iter().enumerate() { - let lb = line_bytes.to_owned(); - to_child[ii].send(lb); + let lb = Vec::from_slice(line_bytes); + to_child.get(ii).send(lb); } } @@ -215,11 +221,11 @@ fn main() { // finish... for (ii, _sz) in sizes.iter().enumerate() { - to_child[ii].send(Vec::new()); + to_child.get(ii).send(Vec::new()); } // now fetch and print result messages for (ii, _sz) in sizes.iter().enumerate() { - println!("{}", from_child[ii].recv()); + println!("{}", from_child.get(ii).recv()); } } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index d2cf4599df2..1b9d0e03431 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -57,7 +57,7 @@ impl Code { } result.reverse(); - str::from_utf8_owned(result).unwrap() + str::from_utf8_owned(result.move_iter().collect()).unwrap() } } @@ -103,7 +103,7 @@ impl Table { fn new() -> Table { Table { count: 0, - items: slice::from_fn(TABLE_SIZE, |_| None), + items: Vec::from_fn(TABLE_SIZE, |_| None), } } @@ -133,20 +133,20 @@ impl Table { let index = key.hash() % (TABLE_SIZE as u64); { - if self.items[index].is_none() { + if self.items.get(index as uint).is_none() { let mut entry = ~Entry { code: key, count: 0, next: None, }; c.f(entry); - self.items[index] = Some(entry); + *self.items.get_mut(index as uint) = Some(entry); return; } } { - let entry = &mut *self.items[index].get_mut_ref(); + let entry = &mut *self.items.get_mut(index as uint).get_mut_ref(); if entry.code == key { c.f(*entry); return; @@ -240,7 +240,7 @@ fn print_frequencies(frequencies: &Table, frame: i32) { for entry in frequencies.iter() { vector.push((entry.code, entry.count)); } - vector.sort(); + vector.as_mut_slice().sort(); let mut total_count = 0; for &(_, count) in vector.iter() { diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 81b712cf9c6..fbe19af27fd 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -12,6 +12,8 @@ // Utilities. // +use std::vec_ng::Vec; + // returns an infinite iterator of repeated applications of f to x, // i.e. [x, f(x), f(f(x)), ...], as haskell iterate function. fn iterate<'a, T>(x: T, f: 'a |&T| -> T) -> Iterate<'a, T> { @@ -63,8 +65,8 @@ impl<'a, T> Iterator<&'a T> for ListIterator<'a, T> { // corresponding mirrored piece), with, as minimum coordinates, (0, // 0). If all is false, only generate half of the possibilities (used // to break the symetry of the board). -fn transform(piece: Vec<(int, int)> , all: bool) -> vec!(Vec<(int, int)> ) { - let mut res = +fn transform(piece: Vec<(int, int)> , all: bool) -> Vec<Vec<(int, int)>> { + let mut res: Vec<Vec<(int, int)>> = // rotations iterate(piece, |rot| rot.iter().map(|&(y, x)| (x + y, -y)).collect()) .take(if all {6} else {3}) @@ -72,7 +74,7 @@ fn transform(piece: Vec<(int, int)> , all: bool) -> vec!(Vec<(int, int)> ) { .flat_map(|cur_piece| { iterate(cur_piece, |mir| mir.iter().map(|&(y, x)| (x, y)).collect()) .take(2) - }).to_owned_vec(); + }).collect(); // translating to (0, 0) as minimum coordinates. for cur_piece in res.mut_iter() { @@ -130,7 +132,7 @@ fn make_masks() -> Vec<Vec<Vec<u64> > > { for dx in range(0, 5) { let masks = trans.iter() - .filter_map(|t| mask(dy, dx, id, *t)) + .filter_map(|t| mask(dy, dx, id, t.as_slice())) .collect(); cur_piece.push(masks); } @@ -147,7 +149,7 @@ fn is_board_unfeasible(board: u64, masks: &[Vec<Vec<u64> > ]) -> bool { for i in range(0, 50).filter(|&i| board & 1 << i == 0) { for (cur_id, pos_masks) in masks.iter().enumerate() { if board & 1 << (50 + cur_id) != 0 {continue;} - for &cur_m in pos_masks[i].iter() { + for &cur_m in pos_masks.get(i as uint).iter() { if cur_m & board == 0 {coverable |= cur_m;} } } @@ -184,10 +186,12 @@ fn to_utf8(raw_sol: &List<u64>) -> ~str { for &m in raw_sol.iter() { let id = get_id(m); for i in range(0, 50) { - if m & 1 << i != 0 {sol[i] = '0' as u8 + id;} + if m & 1 << i != 0 { + *sol.get_mut(i as uint) = '0' as u8 + id; + } } } - std::str::from_utf8_owned(sol).unwrap() + std::str::from_utf8_owned(sol.move_iter().collect()).unwrap() } // Prints a solution in ~str form. @@ -252,7 +256,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][i].iter().filter(|&m| board & *m == 0) { + for &m in masks[id].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) { @@ -271,9 +277,9 @@ fn main () { from_str(args[1]).unwrap() }; let masks = make_masks(); - let masks = filter_masks(masks); + let masks = filter_masks(masks.as_slice()); let mut data = Data {stop_after: stop_after, nb: 0, min: ~"", max: ~""}; - search(masks, 0, 0, Nil, &mut data); + search(masks.as_slice(), 0, 0, Nil, &mut data); println!("{} solutions found", data.nb); print_sol(data.min); print_sol(data.max); diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 72ae6c4d014..b4c96a48ded 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::os; +use std::vec_ng::Vec; static PI: f64 = 3.141592653589793; static SOLAR_MASS: f64 = 4.0 * PI * PI; @@ -152,10 +153,10 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"1000") } else { - args + args.move_iter().collect() }; - let n: i32 = from_str::<i32>(args[1]).unwrap(); + let n: i32 = from_str::<i32>(*args.get(1)).unwrap(); let mut bodies = BODIES; offset_momentum(&mut bodies); diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 6c3b75ef473..2fbc544a8a9 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -25,6 +25,7 @@ use std::os; use std::result::{Ok, Err}; use std::task; use std::uint; +use std::vec_ng::Vec; fn fib(n: int) -> int { fn pfib(tx: &Sender<int>, n: int) { @@ -56,7 +57,7 @@ fn parse_opts(argv: Vec<~str> ) -> Config { let opt_args = argv.slice(1, argv.len()); - match getopts::getopts(opt_args, opts) { + match getopts::getopts(opt_args, opts.as_slice()) { Ok(ref m) => { return Config {stress: m.opt_present("stress")} } @@ -95,7 +96,7 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"8") } else { - args + args.move_iter().collect() }; let opts = parse_opts(args.clone()); @@ -103,7 +104,8 @@ fn main() { if opts.stress { stress(2); } else { - let max = uint::parse_bytes(args[1].as_bytes(), 10u).unwrap() as int; + let max = uint::parse_bytes(args.get(1).as_bytes(), 10u).unwrap() as + int; let num_trials = 10; diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index cfb950090a2..7ee294b8e63 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -56,18 +56,17 @@ fn main() { let args = if os::getenv("RUST_BENCH").is_some() { vec!(~"", ~"2000000", ~"503") - } - else { - os::args() + } else { + os::args().move_iter().collect() }; let token = if args.len() > 1u { - FromStr::from_str(args[1]).unwrap() + FromStr::from_str(*args.get(1)).unwrap() } else { 1000 }; let n_tasks = if args.len() > 2u { - FromStr::from_str(args[2]).unwrap() + FromStr::from_str(*args.get(2)).unwrap() } else { 503 diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 674b6a8b36a..7bafdd81b7c 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -16,6 +16,7 @@ extern crate time; use collections::SmallIntMap; use std::os; use std::uint; +use std::vec_ng::Vec; fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) { for i in range(min, max) { @@ -36,10 +37,10 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"10000", ~"50") } else { - args + args.move_iter().collect() }; - let max = from_str::<uint>(args[1]).unwrap(); - let rep = from_str::<uint>(args[2]).unwrap(); + let max = from_str::<uint>(*args.get(1)).unwrap(); + let rep = from_str::<uint>(*args.get(2)).unwrap(); let mut checkf = 0.0; let mut appendf = 0.0; diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 79eee4006ce..d41a19c60a1 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -17,7 +17,6 @@ use std::io::stdio::StdReader; use std::io::BufferedReader; use std::os; use std::intrinsics::cttz16; -use std::slice; // Computes a single solution to a given 9x9 sudoku // @@ -48,8 +47,8 @@ impl Sudoku { } pub fn from_vec(vec: &[[u8, ..9], ..9]) -> Sudoku { - let g = slice::from_fn(9u, |i| { - slice::from_fn(9u, |j| { vec[i][j] }) + let g = Vec::from_fn(9u, |i| { + Vec::from_fn(9u, |j| { vec[i][j] }) }); return Sudoku::new(g) } @@ -57,7 +56,8 @@ impl Sudoku { pub fn equal(&self, other: &Sudoku) -> bool { for row in range(0u8, 9u8) { for col in range(0u8, 9u8) { - if self.grid[row][col] != other.grid[row][col] { + if *self.grid.get(row as uint).get(col as uint) != + *other.grid.get(row as uint).get(col as uint) { return false; } } @@ -68,14 +68,15 @@ impl Sudoku { pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku { assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */ - let mut g = slice::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) }); + let mut g = Vec::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) }); for line in reader.lines() { let comps: Vec<&str> = line.trim().split(',').collect(); if comps.len() == 3u { - let row = from_str::<uint>(comps[0]).unwrap() as u8; - let col = from_str::<uint>(comps[1]).unwrap() as u8; - g[row][col] = from_str::<uint>(comps[2]).unwrap() as u8; + let row = from_str::<uint>(*comps.get(0)).unwrap() as u8; + let col = from_str::<uint>(*comps.get(1)).unwrap() as u8; + *g.get_mut(row as uint).get_mut(col as uint) = + from_str::<uint>(*comps.get(2)).unwrap() as u8; } else { fail!("Invalid sudoku file"); @@ -86,9 +87,11 @@ impl Sudoku { pub fn write(&self, writer: &mut io::Writer) { for row in range(0u8, 9u8) { - write!(writer, "{}", self.grid[row][0]); + write!(writer, "{}", *self.grid.get(row as uint).get(0)); for col in range(1u8, 9u8) { - write!(writer, " {}", self.grid[row][col]); + write!(writer, " {}", *self.grid + .get(row as uint) + .get(col as uint)); } write!(writer, "\n"); } @@ -99,7 +102,7 @@ impl Sudoku { let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */ for row in range(0u8, 9u8) { for col in range(0u8, 9u8) { - let color = self.grid[row][col]; + let color = *self.grid.get(row as uint).get(col as uint); if color == 0u8 { work.push((row, col)); } @@ -109,9 +112,11 @@ impl Sudoku { let mut ptr = 0u; let end = work.len(); while ptr < end { - let (row, col) = work[ptr]; + let (row, col) = *work.get(ptr); // is there another color to try? - if self.next_color(row, col, self.grid[row][col] + (1 as u8)) { + let the_color = *self.grid.get(row as uint).get(col as uint) + + (1 as u8); + if self.next_color(row, col, the_color) { // yes: advance work list ptr = ptr + 1u; } else { @@ -132,18 +137,22 @@ impl Sudoku { // find first remaining color that is available let next = avail.next(); - self.grid[row][col] = next; + *self.grid.get_mut(row as uint).get_mut(col as uint) = next; return 0u8 != next; } - self.grid[row][col] = 0u8; + *self.grid.get_mut(row as uint).get_mut(col as uint) = 0u8; return false; } // find colors available in neighbourhood of (row, col) fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) { for idx in range(0u8, 9u8) { - avail.remove(self.grid[idx][col]); /* check same column fields */ - avail.remove(self.grid[row][idx]); /* check same row fields */ + avail.remove(*self.grid + .get(idx as uint) + .get(col as uint)); /* check same column fields */ + avail.remove(*self.grid + .get(row as uint) + .get(idx as uint)); /* check same row fields */ } // check same block fields @@ -151,7 +160,9 @@ impl Sudoku { let col0 = (col / 3u8) * 3u8; for alt_row in range(row0, row0 + 3u8) { for alt_col in range(col0, col0 + 3u8) { - avail.remove(self.grid[alt_row][alt_col]); + avail.remove(*self.grid + .get(alt_row as uint) + .get(alt_col as uint)); } } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 1a33391a3d2..4c8379ee059 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -17,6 +17,8 @@ use collections::list::{List, Cons, Nil}; use time::precise_time_s; use std::os; use std::task; +use std::vec_ng::Vec; +use std::vec_ng; enum UniqueList { ULNil, ULCons(~UniqueList) @@ -50,7 +52,7 @@ struct State { managed: @nillist, unique: ~nillist, tuple: (@nillist, ~nillist), - vec: vec!(@nillist), + vec: Vec<@nillist>, res: r } @@ -92,7 +94,8 @@ fn recurse_or_fail(depth: int, st: Option<State>) { unique: ~Cons((), @*st.unique), tuple: (@Cons((), st.tuple.ref0().clone()), ~Cons((), @*st.tuple.ref1().clone())), - vec: st.vec + &[@Cons((), *st.vec.last().unwrap())], + vec: vec::append(st.vec.clone(), + &[@Cons((), *st.vec.last().unwrap())]), res: r(@Cons((), st.res._l)) } } diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 9a57be54362..0199798273e 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -21,6 +21,7 @@ use std::comm; use std::os; use std::task; use std::uint; +use std::vec_ng::Vec; fn child_generation(gens_left: uint, tx: comm::Sender<()>) { // This used to be O(n^2) in the number of generations that ever existed. @@ -45,11 +46,11 @@ fn main() { } else if args.len() <= 1 { vec!(~"", ~"100") } else { - args.clone() + args.clone().move_iter().collect() }; let (tx, rx) = channel(); - child_generation(from_str::<uint>(args[1]).unwrap(), tx); + child_generation(from_str::<uint>(*args.get(1)).unwrap(), tx); if rx.recv_opt().is_none() { fail!("it happened when we slumbered"); } diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index 3a45e88b81a..c5da4a43593 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -11,6 +11,7 @@ use std::os; use std::task; use std::uint; +use std::vec_ng::Vec; fn f(n: uint) { let mut i = 0u; @@ -29,9 +30,9 @@ fn main() { } else if args.len() <= 1u { vec!(~"", ~"10") } else { - args + args.move_iter().collect() }; - let n = from_str::<uint>(args[1]).unwrap(); + let n = from_str::<uint>(*args.get(1)).unwrap(); let mut i = 0u; while i < n { task::spawn(proc() f(n) ); i += 1u; } } diff --git a/src/test/compile-fail/access-mode-in-closures.rs b/src/test/compile-fail/access-mode-in-closures.rs index e1696f0e63e..8dbf292277b 100644 --- a/src/test/compile-fail/access-mode-in-closures.rs +++ b/src/test/compile-fail/access-mode-in-closures.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; struct sty(Vec<int> ); diff --git a/src/test/compile-fail/ambig_impl_unify.rs b/src/test/compile-fail/ambig_impl_unify.rs index 7d842e3d5ab..24a4c9863f7 100644 --- a/src/test/compile-fail/ambig_impl_unify.rs +++ b/src/test/compile-fail/ambig_impl_unify.rs @@ -8,16 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + trait foo { fn foo(&self) -> int; } impl foo for Vec<uint> { - fn foo(&self) -> int {1} //~ NOTE candidate #1 is `~[uint].foo::foo` + fn foo(&self) -> int {1} //~ NOTE candidate #1 is `Vec<uint>.foo::foo` } impl foo for Vec<int> { - fn foo(&self) -> int {2} //~ NOTE candidate #2 is `~[int].foo::foo` + fn foo(&self) -> int {2} //~ NOTE candidate #2 is `Vec<int>.foo::foo` } fn main() { diff --git a/src/test/compile-fail/bad-expr-path.rs b/src/test/compile-fail/bad-expr-path.rs index 6ba5a3333c5..6e73427f80f 100644 --- a/src/test/compile-fail/bad-expr-path.rs +++ b/src/test/compile-fail/bad-expr-path.rs @@ -12,4 +12,4 @@ mod m1 {} -fn main(args: vec!(str)) { log(debug, m1::a); } +fn main(args: Vec<~str>) { log(debug, m1::a); } diff --git a/src/test/compile-fail/bad-expr-path2.rs b/src/test/compile-fail/bad-expr-path2.rs index 4c85ba07637..d2b3a578686 100644 --- a/src/test/compile-fail/bad-expr-path2.rs +++ b/src/test/compile-fail/bad-expr-path2.rs @@ -14,4 +14,6 @@ mod m1 { pub mod a {} } -fn main(args: vec!(str)) { log(debug, m1::a); } +fn main(args: Vec<~str>) { + log(debug, m1::a); +} diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 2377870c647..143ebdaa773 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -17,9 +17,9 @@ fn a() { let mut p = vec!(1); // Create an immutable pointer into p's contents: - let q: &int = &p[0]; + let q: &int = p.get(0); - p[0] = 5; //~ ERROR cannot assign + *p.get_mut(0) = 5; //~ ERROR cannot borrow println!("{}", *q); } @@ -33,16 +33,16 @@ fn b() { let mut p = vec!(1); borrow( - p, - || p[0] = 5); //~ ERROR cannot borrow `p` as mutable + p.as_slice(), + || *p.get_mut(0) = 5); //~ ERROR cannot borrow `p` as mutable } fn c() { // Legal because the scope of the borrow does not include the // modification: let mut p = vec!(1); - borrow(p, ||{}); - p[0] = 5; + borrow(p.as_slice(), ||{}); + *p.get_mut(0) = 5; } fn main() { diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs index a9c4fa9a4b5..ef9bee80c2b 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs @@ -28,6 +28,7 @@ fn defer<'r>(x: &'r [&'r str]) -> defer<'r> { } fn main() { - let x = defer(vec!("Goodbye", "world!")); //~ ERROR borrowed value does not live long enough + let x = defer(vec!("Goodbye", "world!").as_slice()); + //~^ ERROR borrowed value does not live long enough x.x[0]; } diff --git a/src/test/compile-fail/borrowck-init-op-equal.rs b/src/test/compile-fail/borrowck-init-op-equal.rs index cbe805551c2..8d4cb6714bc 100644 --- a/src/test/compile-fail/borrowck-init-op-equal.rs +++ b/src/test/compile-fail/borrowck-init-op-equal.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn test() { let v: int; v += 1; //~ ERROR use of possibly uninitialized variable: `v` diff --git a/src/test/compile-fail/borrowck-loan-vec-content.rs b/src/test/compile-fail/borrowck-loan-vec-content.rs index 200d208d140..393b528869a 100644 --- a/src/test/compile-fail/borrowck-loan-vec-content.rs +++ b/src/test/compile-fail/borrowck-loan-vec-content.rs @@ -18,15 +18,15 @@ fn takes_imm_elt(_v: &int, f: ||) { fn has_mut_vec_and_does_not_try_to_change_it() { let mut v = vec!(1, 2, 3); - takes_imm_elt(&v[0], || {}) + takes_imm_elt(v.get(0), || {}) } fn has_mut_vec_but_tries_to_change_it() { let mut v = vec!(1, 2, 3); takes_imm_elt( - &v[0], + v.get(0), || { //~ ERROR cannot borrow `v` as mutable - v[1] = 4; + *v.get_mut(1) = 4; }) } diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index 30ab71ad105..6724d76d0dc 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -21,7 +21,7 @@ pub fn main() { Foo { string: ~"bar" }, Foo { string: ~"baz" } ); - let x: &[Foo] = x; + let x: &[Foo] = x.as_slice(); match x { [_, ..tail] => { match tail { diff --git a/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs b/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs index b1ca61ebbcf..283d6398e9a 100644 --- a/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs +++ b/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs @@ -14,5 +14,5 @@ fn write(v: &mut [int]) { fn main() { let v = vec!(1, 2, 3); - write(v); //~ ERROR cannot borrow + write(v.as_mut_slice()); //~ ERROR cannot borrow } diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index 22e35e4a84c..3da28417554 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -10,7 +10,7 @@ fn a() -> &[int] { let vec = vec!(1, 2, 3, 4); - let vec: &[int] = vec; //~ ERROR does not live long enough + let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let tail = match vec { [_, ..tail] => tail, _ => fail!("a") @@ -20,7 +20,7 @@ fn a() -> &[int] { fn b() -> &[int] { let vec = vec!(1, 2, 3, 4); - let vec: &[int] = vec; //~ ERROR does not live long enough + let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let init = match vec { [..init, _] => init, _ => fail!("b") @@ -30,7 +30,7 @@ fn b() -> &[int] { fn c() -> &[int] { let vec = vec!(1, 2, 3, 4); - let vec: &[int] = vec; //~ ERROR does not live long enough + let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let slice = match vec { [_, ..slice, _] => slice, _ => fail!("c") diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs index ca28b3cfd45..393ec8b0b1b 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs @@ -10,7 +10,7 @@ fn a() { let mut v = vec!(1, 2, 3); - let vb: &mut [int] = v; + let vb: &mut [int] = v.as_mut_slice(); match vb { [_a, ..tail] => { v.push(tail[0] + tail[1]); //~ ERROR cannot borrow diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index a3b0c0ea359..e96ccd2aa8b 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -19,7 +19,7 @@ fn a() { fn b() { let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec; + let vec: &mut [~int] = vec.as_mut_slice(); match vec { [.._b] => { vec[0] = ~4; //~ ERROR cannot assign @@ -29,7 +29,7 @@ fn b() { fn c() { let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec; + let vec: &mut [~int] = vec.as_mut_slice(); match vec { [_a, .._b] => { //~^ ERROR cannot move out @@ -47,7 +47,7 @@ fn c() { fn d() { let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec; + let vec: &mut [~int] = vec.as_mut_slice(); match vec { [.._a, _b] => { //~^ ERROR cannot move out @@ -59,7 +59,7 @@ fn d() { fn e() { let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec; + let vec: &mut [~int] = vec.as_mut_slice(); match vec { [_a, _b, _c] => {} //~ ERROR cannot move out //~^ ERROR cannot move out diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index 7b3db0151f6..26dc853859c 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -10,7 +10,7 @@ fn a() -> &int { let vec = vec!(1, 2, 3, 4); - let vec: &[int] = vec; //~ ERROR `vec[..]` does not live long enough + let vec: &[int] = vec.as_slice(); //~ ERROR `vec` does not live long enough let tail = match vec { [_a, ..tail] => &tail[0], _ => fail!("foo") diff --git a/src/test/compile-fail/drop-on-non-struct.rs b/src/test/compile-fail/drop-on-non-struct.rs index 8ab78648ff5..09274aaa504 100644 --- a/src/test/compile-fail/drop-on-non-struct.rs +++ b/src/test/compile-fail/drop-on-non-struct.rs @@ -10,10 +10,13 @@ #[feature(managed_boxes)]; -type Foo = Vec<u8> ; +use std::vec_ng::Vec; -impl Drop for Foo { //~ ERROR the Drop trait may only be implemented +type Foo = Vec<u8>; + +impl Drop for Foo { //~ ERROR conflicting implementations //~^ ERROR cannot provide an extension implementation +//~^^ ERROR multiple applicable methods fn drop(&mut self) { println!("kaboom"); } diff --git a/src/test/compile-fail/empty-vec-trailing-comma.rs b/src/test/compile-fail/empty-vec-trailing-comma.rs deleted file mode 100644 index 41cb351cdcd..00000000000 --- a/src/test/compile-fail/empty-vec-trailing-comma.rs +++ /dev/null @@ -1,13 +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. - -fn main() { - let v = vec!(); //~ ERROR unexpected token: `,` -} diff --git a/src/test/compile-fail/evec-subtyping.rs b/src/test/compile-fail/evec-subtyping.rs deleted file mode 100644 index 562a5580c00..00000000000 --- a/src/test/compile-fail/evec-subtyping.rs +++ /dev/null @@ -1,32 +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. - -#[feature(managed_boxes)]; - -fn wants_uniq(x: Vec<uint> ) { } -fn wants_three(x: [uint, ..3]) { } - -fn has_uniq(x: Vec<uint> ) { - wants_uniq(x); - wants_three(x); //~ ERROR [] storage differs: expected `3` but found `~` -} - -fn has_three(x: [uint, ..3]) { - wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `3` - wants_three(x); -} - -fn has_four(x: [uint, ..4]) { - wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `4` - wants_three(x); //~ ERROR [] storage differs: expected `3` but found `4` -} - -fn main() { -} diff --git a/src/test/compile-fail/import.rs b/src/test/compile-fail/import.rs index c5c6a375959..35a17f7e017 100644 --- a/src/test/compile-fail/import.rs +++ b/src/test/compile-fail/import.rs @@ -11,7 +11,10 @@ // error-pattern:failed to resolve import use zed::bar; use zed::baz; + +use std::vec_ng::Vec; + mod zed { pub fn bar() { println!("bar"); } } -fn main(args: vec!(str)) { bar(); } +fn main(args: Vec<~str>) { bar(); } diff --git a/src/test/compile-fail/import2.rs b/src/test/compile-fail/import2.rs index 0024f78009d..759e0c56f51 100644 --- a/src/test/compile-fail/import2.rs +++ b/src/test/compile-fail/import2.rs @@ -11,8 +11,10 @@ use baz::zed::bar; //~ ERROR unresolved import //~^ ERROR failed to resolve import +use std::vec_ng::Vec; + mod baz {} mod zed { pub fn bar() { println!("bar3"); } } -fn main(args: vec!(str)) { bar(); } +fn main(args: Vec<~str>) { bar(); } diff --git a/src/test/compile-fail/import4.rs b/src/test/compile-fail/import4.rs index feb94708520..8920349a27a 100644 --- a/src/test/compile-fail/import4.rs +++ b/src/test/compile-fail/import4.rs @@ -10,6 +10,8 @@ // error-pattern: import +use std::vec_ng::Vec; + mod a { pub use b::foo; } mod b { pub use a::foo; } diff --git a/src/test/compile-fail/infinite-vec-type-recursion.rs b/src/test/compile-fail/infinite-vec-type-recursion.rs index 409a5e72fed..c52199ecedd 100644 --- a/src/test/compile-fail/infinite-vec-type-recursion.rs +++ b/src/test/compile-fail/infinite-vec-type-recursion.rs @@ -10,6 +10,8 @@ // error-pattern: illegal recursive type -type x = vec!(x); +use std::vec_ng::Vec; + +type x = Vec<x>; fn main() { let b: x = Vec::new(); } diff --git a/src/test/compile-fail/issue-10487.rs b/src/test/compile-fail/issue-10487.rs deleted file mode 100644 index c2f40f56948..00000000000 --- a/src/test/compile-fail/issue-10487.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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. - -#[feature(managed_boxes)]; - -static x: Vec<int> = vec!(123, 456); //~ ERROR: static items are not allowed to have owned pointers - -fn main() {} diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index ed35f3b306b..29f7e344b30 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + trait vec_monad<A> { fn bind<B>(&self, f: |A| -> Vec<B> ); } diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index ca49bd1a48a..69dd24522fb 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -13,6 +13,8 @@ #[allow(dead_code)]; #[allow(deprecated_owned_vector)]; +use std::vec_ng::Vec; + fn fail_len(v: Vec<int> ) -> uint { let mut i = 3; fail!(); diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs deleted file mode 100644 index c2f48b7ca5b..00000000000 --- a/src/test/compile-fail/issue-2548.rs +++ /dev/null @@ -1,47 +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. - -#[feature(managed_boxes)]; - -// A test case for #2548. - -use std::cell::Cell; - -struct foo { - x: @Cell<int>, -} - -#[unsafe_destructor] -impl Drop for foo { - fn drop(&mut self) { - unsafe { - println!("Goodbye, World!"); - self.x.set(self.x.get() + 1); - } - } -} - -fn foo(x: @Cell<int>) -> foo { - foo { x: x } -} - -fn main() { - let x = @Cell::new(0); - - { - let mut res = foo(x); - - let mut v = Vec::new(); - v = vec!((res)) + v; //~ failed to find an implementation of trait - assert_eq!(v.len(), 2); - } - - assert_eq!(x.get(), 1); -} diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs index 94c155fce9b..a3f2da150a3 100644 --- a/src/test/compile-fail/issue-2590.rs +++ b/src/test/compile-fail/issue-2590.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct parser { tokens: Vec<int> , } diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs index 3b1bceb453a..076c6015268 100644 --- a/src/test/compile-fail/issue-3044.rs +++ b/src/test/compile-fail/issue-3044.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn main() { let needlesArr: Vec<char> = vec!('a', 'f'); needlesArr.iter().fold(|x, y| { diff --git a/src/test/compile-fail/issue-7573.rs b/src/test/compile-fail/issue-7573.rs index c78e1a15058..633be15ef99 100644 --- a/src/test/compile-fail/issue-7573.rs +++ b/src/test/compile-fail/issue-7573.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + pub struct CrateId { local_path: ~str, junk: ~str diff --git a/src/test/compile-fail/issue-8727.rs b/src/test/compile-fail/issue-8727.rs index 4c9f4039723..9d7edefbf02 100644 --- a/src/test/compile-fail/issue-8727.rs +++ b/src/test/compile-fail/issue-8727.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[allow(deprecated_owned_vector)]; - // Verify the compiler fails with an error on infinite function // recursions. diff --git a/src/test/compile-fail/kindck-freeze.rs b/src/test/compile-fail/kindck-freeze.rs index bf10a029024..c5977678aba 100644 --- a/src/test/compile-fail/kindck-freeze.rs +++ b/src/test/compile-fail/kindck-freeze.rs @@ -10,6 +10,8 @@ // Test which of the builtin types are considered freezeable. +use std::vec_ng::Vec; + fn assert_freeze<T:Freeze>() { } trait Dummy { } diff --git a/src/test/compile-fail/kindck-pod.rs b/src/test/compile-fail/kindck-pod.rs index 94902d4e68e..bc4ee14d89e 100644 --- a/src/test/compile-fail/kindck-pod.rs +++ b/src/test/compile-fail/kindck-pod.rs @@ -13,6 +13,7 @@ #[feature(managed_boxes)]; use std::rc::Rc; +use std::vec_ng::Vec; fn assert_pod<T:Pod>() { } trait Dummy { } diff --git a/src/test/compile-fail/kindck-send.rs b/src/test/compile-fail/kindck-send.rs index 829bdaa5332..0eb3656cea7 100644 --- a/src/test/compile-fail/kindck-send.rs +++ b/src/test/compile-fail/kindck-send.rs @@ -10,6 +10,8 @@ // Test which of the builtin types are considered sendable. +use std::vec_ng::Vec; + fn assert_send<T:Send>() { } trait Dummy { } diff --git a/src/test/compile-fail/lint-heap-memory.rs b/src/test/compile-fail/lint-heap-memory.rs index 5391cd475aa..f4588801075 100644 --- a/src/test/compile-fail/lint-heap-memory.rs +++ b/src/test/compile-fail/lint-heap-memory.rs @@ -25,8 +25,6 @@ fn main() { @2; //~ ERROR type uses managed ~2; //~ ERROR type uses owned - vec!(1); //~ ERROR type uses owned - //~^ ERROR type uses owned fn g(_: ~Clone) {} //~ ERROR type uses owned ~""; //~ ERROR type uses owned //~^ ERROR type uses owned diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs index 275b37d9b7e..2adf833e4e4 100644 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ b/src/test/compile-fail/lint-unused-mut-variables.rs @@ -16,6 +16,8 @@ #[allow(deprecated_owned_vector)]; #[deny(unused_mut)]; +use std::vec_ng::Vec; + fn main() { // negative cases let mut a = 3; //~ ERROR: variable does not need to be mutable diff --git a/src/test/compile-fail/lint-unused-unsafe.rs b/src/test/compile-fail/lint-unused-unsafe.rs index 2bf784faf00..81e8c39a28c 100644 --- a/src/test/compile-fail/lint-unused-unsafe.rs +++ b/src/test/compile-fail/lint-unused-unsafe.rs @@ -14,6 +14,8 @@ #[deny(unused_unsafe)]; #[allow(deprecated_owned_vector)]; +use std::vec_ng::Vec; + mod foo { extern { pub fn bar(); diff --git a/src/test/compile-fail/liveness-issue-2163.rs b/src/test/compile-fail/liveness-issue-2163.rs index 3d601957754..4bfa614063b 100644 --- a/src/test/compile-fail/liveness-issue-2163.rs +++ b/src/test/compile-fail/liveness-issue-2163.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::slice; +use std::vec::Vec; fn main() { let a: Vec<int> = Vec::new(); diff --git a/src/test/compile-fail/match-vec-unreachable.rs b/src/test/compile-fail/match-vec-unreachable.rs index 31fdb220263..2112af7cd04 100644 --- a/src/test/compile-fail/match-vec-unreachable.rs +++ b/src/test/compile-fail/match-vec-unreachable.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn main() { let x: Vec<(int, int)> = Vec::new(); - let x: &[(int, int)] = x; + let x: &[(int, int)] = x.as_slice(); match x { [a, (2, 3), _] => (), [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern @@ -18,7 +20,7 @@ fn main() { } let x: Vec<~str> = vec!(~"foo", ~"bar", ~"baz"); - let x: &[~str] = x; + let x: &[~str] = x.as_slice(); match x { [a, _, _, ..] => { println!("{}", a); } [_, _, _, _, _] => { } //~ ERROR unreachable pattern @@ -26,7 +28,7 @@ fn main() { } let x: Vec<char> = vec!('a', 'b', 'c'); - let x: &[char] = x; + let x: &[char] = x.as_slice(); match x { ['a', 'b', 'c', .._tail] => {} ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index 59bdc0b8a4d..657d5ad03e8 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -23,8 +23,8 @@ fn f10() { fn f20() { let x = vec!(~"hi"); - consume(x[0]); - touch(&x[0]); //~ ERROR use of partially moved value: `x` + consume(x.move_iter().next().unwrap()); + touch(x.get(0)); //~ ERROR use of moved value: `x` } fn main() {} diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index cfc57af092c..967612e7c50 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -31,7 +31,7 @@ fn f20() { fn f21() { let x = vec!(1, 2, 3); - let _y = (x[0], 3); + let _y = (*x.get(0), 3); touch(&x); } @@ -84,21 +84,21 @@ fn f80() { fn f100() { let x = vec!(~"hi"); - let _y = x[0]; - touch(&x); //~ ERROR use of partially moved value: `x` + let _y = x.move_iter().next().unwrap(); + touch(&x); //~ ERROR use of moved value: `x` } fn f110() { let x = vec!(~"hi"); - let _y = [x[0], ..1]; - touch(&x); //~ ERROR use of partially moved value: `x` + let _y = [x.move_iter().next().unwrap(), ..1]; + touch(&x); //~ ERROR use of moved value: `x` } fn f120() { let mut x = vec!(~"hi", ~"ho"); x.swap(0, 1); - touch(&x[0]); - touch(&x[1]); + touch(x.get(0)); + touch(x.get(1)); } fn main() {} diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index 7311a0d5302..e76c31469ea 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -21,10 +21,10 @@ fn main() { task::spawn(proc() { let v = arc_v.get(); - assert_eq!(v[3], 4); + assert_eq!(*v.get(3), 4); }); - assert_eq!((arc_v.get())[2], 3); + assert_eq!(*(arc_v.get()).get(2), 3); println!("{:?}", arc_v); } diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index 115be7e1485..29f62ff6e1b 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -19,10 +19,10 @@ fn main() { task::spawn(proc() { let v = arc_v.get(); - assert_eq!(v[3], 4); + assert_eq!(*v.get(3), 4); }); - assert_eq!((arc_v.get())[2], 3); //~ ERROR use of moved value: `arc_v` + assert_eq!(*(arc_v.get()).get(2), 3); //~ ERROR use of moved value: `arc_v` println!("{:?}", arc_v); //~ ERROR use of moved value: `arc_v` } diff --git a/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs b/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs index 162b84d6cec..fd857129c35 100644 --- a/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs @@ -11,6 +11,6 @@ enum State { ST_NULL, ST_WHITESPACE } fn main() { - vec!(ST_NULL, ..(ST_WHITESPACE as uint)); + [ST_NULL, ..(ST_WHITESPACE as uint)]; //~^ ERROR expected constant integer for repeat count but found variable } diff --git a/src/test/compile-fail/non-copyable-void.rs b/src/test/compile-fail/non-copyable-void.rs index bd9547d5e1c..2b3722196c1 100644 --- a/src/test/compile-fail/non-copyable-void.rs +++ b/src/test/compile-fail/non-copyable-void.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::libc; +use std::vec_ng::Vec; fn main() { let x : *Vec<int> = &vec!(1,2,3); diff --git a/src/test/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs index 3bed415600f..a07fec853fc 100644 --- a/src/test/compile-fail/non-exhaustive-match.rs +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -36,7 +36,7 @@ fn main() { (b, b) => {} } let vec = vec!(Some(42), None, Some(21)); - let vec: &[Option<int>] = vec; + let vec: &[Option<int>] = vec.as_slice(); match vec { //~^ ERROR non-exhaustive patterns: vectors of length 0 not covered [Some(..), None, ..tail] => {} @@ -44,13 +44,13 @@ fn main() { [None] => {} } let vec = vec!(1); - let vec: &[int] = vec; + let vec: &[int] = vec.as_slice(); match vec { [_, ..tail] => (), [] => () } let vec = vec!(0.5); - let vec: &[f32] = vec; + let vec: &[f32] = vec.as_slice(); match vec { //~ ERROR non-exhaustive patterns: vectors of length 4 not covered [0.1, 0.2, 0.3] => (), [0.1, 0.2] => (), @@ -58,7 +58,7 @@ fn main() { [] => () } let vec = vec!(Some(42), None, Some(21)); - let vec: &[Option<int>] = vec; + let vec: &[Option<int>] = vec.as_slice(); match vec { [Some(..), None, ..tail] => {} [Some(..), Some(..), ..tail] => {} diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index a7340df83b4..38669a99b49 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - enum bar { t1((), Option<Vec<int>>), t2, } // n.b. my change changes this error message, but I think it's right -- tjc diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 08c8eba696d..692c51b5b5f 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -12,5 +12,5 @@ fn main() { let n = 1; - let a = vec!(0, ..n); //~ ERROR expected constant integer for repeat count but found variable + let a = [0, ..n]; //~ ERROR expected constant integer for repeat count but found variable } diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index a135af29356..59c80474c4c 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -13,6 +13,8 @@ #[no_implicit_prelude]; +use std::vec_ng::Vec; + fn last<T>(v: Vec<&T> ) -> std::option::Option<T> { fail!(); } diff --git a/src/test/compile-fail/uninstantiable-fixed-length-vec.rs b/src/test/compile-fail/uninstantiable-fixed-length-vec.rs deleted file mode 100644 index a44010366c8..00000000000 --- a/src/test/compile-fail/uninstantiable-fixed-length-vec.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 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. - -// issue #11659, the compiler needs to know that a fixed length vector -// always requires instantiable contents to instantiable itself -// (unlike a ~[] vector which can have length zero). - -// ~ to avoid infinite size. -struct Uninstantiable { //~ ERROR cannot be instantiated without an instance of itself - p: vec!(Uninstantiable, .. 1) -} - -struct Instantiable { p: vec!(Instantiable, .. 0) } - - -fn main() { - let _ = None::<Uninstantiable>; - let _ = Instantiable { p: ~([]) }; -} diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index c76a6f2453e..e35a0c607c8 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -11,6 +11,7 @@ #[feature(managed_boxes)]; use std::cell::Cell; +use std::vec_ng::Vec; struct r { i: @Cell<int>, diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs index 4d57470a721..4dd3b26bad9 100644 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs @@ -11,6 +11,7 @@ // ignore-tidy-linelength use std::fmt; +use std::vec_ng::Vec; struct Number { n: i64 diff --git a/src/test/compile-fail/vector-no-ann.rs b/src/test/compile-fail/vector-no-ann.rs index be226b2e16e..985a094d5a8 100644 --- a/src/test/compile-fail/vector-no-ann.rs +++ b/src/test/compile-fail/vector-no-ann.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn main() { let _foo = Vec::new(); //~ ERROR unconstrained type } diff --git a/src/test/compile-fail/writing-to-immutable-vec.rs b/src/test/compile-fail/writing-to-immutable-vec.rs index 987a3c1674c..00d537f95bf 100644 --- a/src/test/compile-fail/writing-to-immutable-vec.rs +++ b/src/test/compile-fail/writing-to-immutable-vec.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn main() { let v: Vec<int> = vec!(1, 2, 3); - v[1] = 4; //~ ERROR cannot assign + *v.get(1) = 4; //~ ERROR cannot assign } diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 8e4427d9dd4..acc03831290 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -15,6 +15,7 @@ #[feature(managed_boxes)]; use std::cell::Cell; +use std::vec_ng::Vec; fn test1() { let val = @0; { } *val; } @@ -61,7 +62,7 @@ fn test9() { fn test10() -> int { let regs = @vec!(0); match true { true => { } _ => { } } - (*regs)[0] + *(*regs).get(0) } fn test11() -> Vec<int> { if true { } vec!(1, 2) } diff --git a/src/test/pretty/match-naked-expr-medium.rs b/src/test/pretty/match-naked-expr-medium.rs index 56ffc41c76c..5b52acdff50 100644 --- a/src/test/pretty/match-naked-expr-medium.rs +++ b/src/test/pretty/match-naked-expr-medium.rs @@ -14,7 +14,7 @@ fn main() { let x = Some(3); let _y = match x { - Some(_) => vec!(~"some(_)", ~"not", ~"SO", ~"long", ~"string"), - None => vec!(~"none") + Some(_) => [~"some(_)", ~"not", ~"SO", ~"long", ~"string"], + None => [~"none", ~"a", ~"a", ~"a", ~"a"] }; } diff --git a/src/test/pretty/vec-comments.pp b/src/test/pretty/vec-comments.pp index a09e341a940..dc2dae1044d 100644 --- a/src/test/pretty/vec-comments.pp +++ b/src/test/pretty/vec-comments.pp @@ -13,27 +13,27 @@ // pp-exact:vec-comments.pp fn main() { let _v1 = - ~[ - // Comment - 0, - // Comment - 1, - // Comment - 2]; + [ + // Comment + 0, + // Comment + 1, + // Comment + 2]; let _v2 = - ~[0, // Comment - 1, // Comment - 2]; // Comment + [0, // Comment + 1, // Comment + 2]; // Comment let _v3 = - ~[ - /* Comment */ - 0, - /* Comment */ - 1, - /* Comment */ - 2]; + [ + /* Comment */ + 0, + /* Comment */ + 1, + /* Comment */ + 2]; let _v4 = - ~[0, /* Comment */ - 1, /* Comment */ - 2]; /* Comment */ + [0, /* Comment */ + 1, /* Comment */ + 2]; /* Comment */ } diff --git a/src/test/pretty/vec-comments.rs b/src/test/pretty/vec-comments.rs index d685ad49a27..dc2dae1044d 100644 --- a/src/test/pretty/vec-comments.rs +++ b/src/test/pretty/vec-comments.rs @@ -13,27 +13,27 @@ // pp-exact:vec-comments.pp fn main() { let _v1 = - vec!( - // Comment - 0, - // Comment - 1, - // Comment - 2); + [ + // Comment + 0, + // Comment + 1, + // Comment + 2]; let _v2 = - vec!(0, // Comment - 1, // Comment - 2); // Comment + [0, // Comment + 1, // Comment + 2]; // Comment let _v3 = - vec!( - /* Comment */ - 0, - /* Comment */ - 1, - /* Comment */ - 2); + [ + /* Comment */ + 0, + /* Comment */ + 1, + /* Comment */ + 2]; let _v4 = - vec!(0, /* Comment */ - 1, /* Comment */ - 2); /* Comment */ + [0, /* Comment */ + 1, /* Comment */ + 2]; /* Comment */ } diff --git a/src/test/pretty/vec-type.pp b/src/test/pretty/vec-type.pp deleted file mode 100644 index d84f43d7005..00000000000 --- a/src/test/pretty/vec-type.pp +++ /dev/null @@ -1,15 +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. - -// pp-exact:vec-type.pp - -fn f1(_x: ~[int]) { } - -fn g1() { f1(~[1, 2, 3]); } diff --git a/src/test/pretty/vec-type.rs b/src/test/pretty/vec-type.rs deleted file mode 100644 index 5e37123023c..00000000000 --- a/src/test/pretty/vec-type.rs +++ /dev/null @@ -1,15 +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. - -// pp-exact:vec-type.pp - -fn f1(_x: Vec<int> ) { } - -fn g1() { f1(vec!(1, 2, 3)); } diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow.rs b/src/test/run-fail/bug-2470-bounds-check-overflow.rs index 29e57925af5..0e116bcede5 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow.rs @@ -31,5 +31,5 @@ fn main() { idx * mem::size_of::<uint>()); // This should fail. - println!("ov1 0x{:x}", x[idx]); + println!("ov1 0x{:x}", *x.get(idx)); } diff --git a/src/test/run-fail/issue-3029.rs b/src/test/run-fail/issue-3029.rs index d51865d782c..365be5b7527 100644 --- a/src/test/run-fail/issue-3029.rs +++ b/src/test/run-fail/issue-3029.rs @@ -12,6 +12,8 @@ #[allow(unreachable_code)]; #[allow(unused_variable)]; +use std::vec_ng::Vec; + // error-pattern:so long fn main() { let mut x = Vec::new(); diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs index 9fb53d0f9e8..545012d9322 100644 --- a/src/test/run-fail/unwind-misc-1.rs +++ b/src/test/run-fail/unwind-misc-1.rs @@ -15,13 +15,17 @@ extern crate collections; +use std::vec_ng::Vec; +use std::vec_ng; + fn main() { let _count = @0u; let mut map = collections::HashMap::new(); let mut arr = Vec::new(); for _i in range(0u, 10u) { arr.push(@~"key stuff"); - map.insert(arr.clone(), arr + &[@~"value stuff"]); + map.insert(arr.clone(), + vec::append(arr.clone(), &[@~"value stuff"])); if arr.len() == 5 { fail!(); } diff --git a/src/test/run-fail/unwind-partial-box.rs b/src/test/run-fail/unwind-partial-box.rs index e13c818ee44..80e1b60ee5a 100644 --- a/src/test/run-fail/unwind-partial-box.rs +++ b/src/test/run-fail/unwind-partial-box.rs @@ -12,6 +12,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + fn f() -> Vec<int> { fail!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might diff --git a/src/test/run-fail/unwind-partial-unique.rs b/src/test/run-fail/unwind-partial-unique.rs index 4dd2b35e2de..7f163a2a9e4 100644 --- a/src/test/run-fail/unwind-partial-unique.rs +++ b/src/test/run-fail/unwind-partial-unique.rs @@ -12,6 +12,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + fn f() -> Vec<int> { fail!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might diff --git a/src/test/run-fail/unwind-partial-vec.rs b/src/test/run-fail/unwind-partial-vec.rs index eac4bf54157..669edb4544b 100644 --- a/src/test/run-fail/unwind-partial-vec.rs +++ b/src/test/run-fail/unwind-partial-vec.rs @@ -12,6 +12,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + fn f() -> Vec<int> { fail!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might diff --git a/src/test/run-fail/unwind-rec.rs b/src/test/run-fail/unwind-rec.rs index 7604f568fe7..053bc0cb58c 100644 --- a/src/test/run-fail/unwind-rec.rs +++ b/src/test/run-fail/unwind-rec.rs @@ -10,6 +10,8 @@ // error-pattern:fail +use std::vec_ng::Vec; + fn build() -> Vec<int> { fail!(); } diff --git a/src/test/run-fail/unwind-rec2.rs b/src/test/run-fail/unwind-rec2.rs index 12990722d7b..7b18c678be6 100644 --- a/src/test/run-fail/unwind-rec2.rs +++ b/src/test/run-fail/unwind-rec2.rs @@ -10,6 +10,8 @@ // error-pattern:fail +use std::vec_ng::Vec; + fn build1() -> Vec<int> { vec!(0,0,0,0,0,0,0) } diff --git a/src/test/run-fail/unwind-tup.rs b/src/test/run-fail/unwind-tup.rs index 0d979233934..fd1c13a5018 100644 --- a/src/test/run-fail/unwind-tup.rs +++ b/src/test/run-fail/unwind-tup.rs @@ -10,6 +10,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + // error-pattern:fail fn fold_local() -> @Vec<int> { diff --git a/src/test/run-fail/unwind-tup2.rs b/src/test/run-fail/unwind-tup2.rs index 1112e108d2d..6735168e83a 100644 --- a/src/test/run-fail/unwind-tup2.rs +++ b/src/test/run-fail/unwind-tup2.rs @@ -10,6 +10,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + // error-pattern:fail fn fold_local() -> @Vec<int> { diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index 1542984c1d3..169c00182dd 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - // error-pattern:index out of bounds: the len is 1 but the index is 2 + +use std::vec_ng::Vec; + fn main() { let v: Vec<int> = vec!(10); - let x: int = 0; - assert_eq!(v[x], 10); + let x: uint = 0; + assert_eq!(*v.get(x), 10); // Bounds-check failure. - assert_eq!(v[x + 2], 20); + assert_eq!(*v.get(x + 2), 20); } diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs index eba7e8c7ffb..f9320f6b039 100644 --- a/src/test/run-pass/alloca-from-derived-tydesc.rs +++ b/src/test/run-pass/alloca-from-derived-tydesc.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + enum option<T> { some(T), none, } struct R<T> {v: Vec<option<T>> } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index aa3e28c875e..60a7101c820 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -12,6 +12,8 @@ // making method calls, but only if there aren't any matches without // it. +use std::vec_ng::Vec; + trait iterable<A> { fn iterate(&self, blk: |x: &A| -> bool) -> bool; } @@ -38,14 +40,14 @@ fn length<A, T: iterable<A>>(x: T) -> uint { } pub fn main() { - let x = vec!(0,1,2,3); + let x: Vec<int> = vec!(0,1,2,3); // Call a method - x.iterate(|y| { assert!(x[*y] == *y); true }); + x.iterate(|y| { assert!(*x.get(*y as uint) == *y); true }); // Call a parameterized function assert_eq!(length(x.clone()), x.len()); // Call a parameterized function, with type arguments that require // a borrow - assert_eq!(length::<int, &[int]>(x), x.len()); + assert_eq!(length::<int, &[int]>(x.as_slice()), x.len()); // Now try it with a type that *needs* to be borrowed let z = [0,1,2,3]; diff --git a/src/test/run-pass/auto-ref-slice-plus-ref.rs b/src/test/run-pass/auto-ref-slice-plus-ref.rs index 0cc02d7a28b..86e1b18a574 100644 --- a/src/test/run-pass/auto-ref-slice-plus-ref.rs +++ b/src/test/run-pass/auto-ref-slice-plus-ref.rs @@ -29,7 +29,7 @@ pub fn main() { // NB: Associativity of ~, etc. in this context is surprising. These must be parenthesized ([1]).test_imm(); - (vec!(1)).test_imm(); + (vec!(1)).as_slice().test_imm(); (&[1]).test_imm(); ("test").test_imm(); (~"test").test_imm(); diff --git a/src/test/run-pass/auto-ref-sliceable.rs b/src/test/run-pass/auto-ref-sliceable.rs index 6b36746d230..82d2a58a556 100644 --- a/src/test/run-pass/auto-ref-sliceable.rs +++ b/src/test/run-pass/auto-ref-sliceable.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + trait Pushable<T> { fn push_val(&mut self, t: T); } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 2fe5ce7a118..db528c4fd08 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f<T>(x: Vec<T> ) -> T { return x[0]; } +use std::vec_ng::Vec; + +fn f<T>(x: Vec<T>) -> T { return x.move_iter().next().unwrap(); } fn g(act: |Vec<int> | -> int) -> int { return act(vec!(1, 2, 3)); } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index ba6a94fa6ff..97ae7d8cdef 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -10,6 +10,8 @@ // ignore-fast +use std::vec_ng::Vec; + fn iter_vec<T>(v: Vec<T> , f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index ba4bdbe636c..a8d65dbdeca 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -10,6 +10,8 @@ // ignore-fast +use std::vec_ng::Vec; + fn iter_vec<T>(v: Vec<T> , f: |&T|) { for x in v.iter() { f(x); } } pub fn main() { diff --git a/src/test/run-pass/borrow-by-val-method-receiver.rs b/src/test/run-pass/borrow-by-val-method-receiver.rs index 374c3e7fc53..df334a6fcec 100644 --- a/src/test/run-pass/borrow-by-val-method-receiver.rs +++ b/src/test/run-pass/borrow-by-val-method-receiver.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + trait Foo { fn foo(self); } @@ -18,5 +20,5 @@ impl<'a> Foo for &'a [int] { pub fn main() { let items = vec!( 3, 5, 1, 2, 4 ); - items.foo(); + items.as_slice().foo(); } diff --git a/src/test/run-pass/borrowck-binding-mutbl.rs b/src/test/run-pass/borrowck-binding-mutbl.rs index 126f0fd7ac5..67233c29258 100644 --- a/src/test/run-pass/borrowck-binding-mutbl.rs +++ b/src/test/run-pass/borrowck-binding-mutbl.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct F { f: Vec<int> } fn impure(_v: &[int]) { @@ -18,7 +20,7 @@ pub fn main() { match x { F {f: ref mut v} => { - impure(*v); + impure(v.as_slice()); } } } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index ac6ea8dec05..88230cbb1c4 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::mem::swap; +use std::vec_ng::Vec; struct Ints {sum: ~int, values: Vec<int> } @@ -22,7 +23,7 @@ fn add_int(x: &mut Ints, v: int) { fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool { let l = x.values.len(); - range(0u, l).advance(|i| f(&x.values[i])) + range(0u, l).advance(|i| f(x.values.get(i))) } pub fn main() { diff --git a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs index e6fcb1ca951..0b46f49ad93 100644 --- a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs +++ b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn want_slice(v: &[int]) -> int { let mut sum = 0; for i in v.iter() { sum += *i; } @@ -15,7 +17,7 @@ fn want_slice(v: &[int]) -> int { } fn has_mut_vec(v: Vec<int> ) -> int { - want_slice(v) + want_slice(v.as_slice()) } pub fn main() { diff --git a/src/test/run-pass/borrowck-root-while-cond-2.rs b/src/test/run-pass/borrowck-root-while-cond-2.rs index 3b07ffa26da..bb346bccd51 100644 --- a/src/test/run-pass/borrowck-root-while-cond-2.rs +++ b/src/test/run-pass/borrowck-root-while-cond-2.rs @@ -10,6 +10,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + struct F { f: @G } struct G { g: Vec<int> } diff --git a/src/test/run-pass/borrowck-root-while-cond.rs b/src/test/run-pass/borrowck-root-while-cond.rs index a2d4991abc0..03ea9178eb9 100644 --- a/src/test/run-pass/borrowck-root-while-cond.rs +++ b/src/test/run-pass/borrowck-root-while-cond.rs @@ -10,6 +10,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + fn borrow<'r,T>(x: &'r T) -> &'r T {x} struct Rec { f: @int } diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs index d27dd8f92d1..34f6e5ab8fd 100644 --- a/src/test/run-pass/call-closure-from-overloaded-op.rs +++ b/src/test/run-pass/call-closure-from-overloaded-op.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn foo() -> int { 22 } pub fn main() { - let mut x: vec!(extern "Rust" fn() -> int) = Vec::new(); + let mut x: Vec<extern "Rust" fn() -> int> = Vec::new(); x.push(foo); - assert_eq!((x[0])(), 22); + assert_eq!((*x.get(0))(), 22); } diff --git a/src/test/run-pass/class-poly-methods.rs b/src/test/run-pass/class-poly-methods.rs index cddb5bb7e15..02ba8b900be 100644 --- a/src/test/run-pass/class-poly-methods.rs +++ b/src/test/run-pass/class-poly-methods.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct cat<U> { info : Vec<U> , meows : uint, diff --git a/src/test/run-pass/cleanup-rvalue-scopes.rs b/src/test/run-pass/cleanup-rvalue-scopes.rs index 6d1c3aab662..2911df412d8 100644 --- a/src/test/run-pass/cleanup-rvalue-scopes.rs +++ b/src/test/run-pass/cleanup-rvalue-scopes.rs @@ -15,6 +15,7 @@ #[feature(macro_rules)]; use std::ops::Drop; +use std::vec_ng::Vec; static mut FLAGS: u64 = 0; @@ -116,7 +117,6 @@ pub fn main() { end_of_block!(_, { { check_flags(0); &AddFlags(1) } }); end_of_block!(_, &((Box { f: AddFlags(1) }).f)); end_of_block!(_, &(([AddFlags(1)])[0])); - end_of_block!(_, &((&vec!(AddFlags(1)))[0])); // LHS does not create a ref binding, so temporary lives as long // as statement, and we do not move the AddFlags out: diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index b9587c57787..7bf7920fe07 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -25,6 +25,7 @@ // scenario worth testing. use std::task; +use std::vec_ng::Vec; enum Conzabble { Bickwick(Foo) @@ -41,7 +42,7 @@ fn get_bar(x: uint) -> Vec<uint> { vec!(x * 2) } pub fn fails() { let x = 2; let mut y = Vec::new(); - y.push(~Bickwick(do_it(get_bar(x)))); + y.push(~Bickwick(do_it(get_bar(x).as_slice()))); } pub fn main() { diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index ffac7cbdab0..937cb0f0dac 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -8,16 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn bar(v: &mut [uint]) -> Vec<uint> { - v.to_owned() + Vec::from_slice(v) } fn bip(v: &[uint]) -> Vec<uint> { - v.to_owned() + Vec::from_slice(v) } pub fn main() { let mut the_vec = vec!(1u, 2, 3, 100); - assert_eq!(the_vec.clone(), bar(the_vec)); - assert_eq!(the_vec.clone(), bip(the_vec)); + assert_eq!(the_vec.clone(), bar(the_vec.as_mut_slice())); + assert_eq!(the_vec.clone(), bip(the_vec.as_slice())); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs index 67d81ab8684..be8bb861345 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn reverse(v: &mut [uint]) { v.reverse(); } @@ -20,6 +22,6 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = vec!(1, 2, 3, 100); - bar(the_vec); + bar(the_vec.as_mut_slice()); assert_eq!(the_vec, vec!(100, 3, 2, 1)); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs index 31620973ce7..686b8545b5e 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn bar(v: &mut [uint]) { v.reverse(); v.reverse(); @@ -16,6 +18,6 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = vec!(1, 2, 3, 100); - bar(the_vec); + bar(the_vec.as_mut_slice()); assert_eq!(the_vec, vec!(100, 3, 2, 1)); } diff --git a/src/test/run-pass/const-enum-vec-repeat.rs b/src/test/run-pass/const-enum-vec-repeat.rs deleted file mode 100644 index 5470b1d6615..00000000000 --- a/src/test/run-pass/const-enum-vec-repeat.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 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. - -enum State { ST_NULL, ST_WHITESPACE = 1 } - -pub fn main() { - vec!(ST_NULL, ..(ST_WHITESPACE as uint)); -} diff --git a/src/test/run-pass/deep-vector.rs b/src/test/run-pass/deep-vector.rs index e6ae892093c..6a05dafb17c 100644 --- a/src/test/run-pass/deep-vector.rs +++ b/src/test/run-pass/deep-vector.rs @@ -8,8 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-test +// ignore-fast +// +// Too big for our poor macro infrastructure. + pub fn main() { - let _x = ~[ + let _x = vec!( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2008,5 +2013,5 @@ pub fn main() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; + ); } diff --git a/src/test/run-pass/deep-vector2.rs b/src/test/run-pass/deep-vector2.rs index b644d1a8b1f..615e94c3f4e 100644 --- a/src/test/run-pass/deep-vector2.rs +++ b/src/test/run-pass/deep-vector2.rs @@ -8,8 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-test +// ignore-fast +// +// Too big for our poor macro infrastructure. + pub fn main() { - let _x = ~[ + let _x = vec!( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8008,5 +8013,5 @@ pub fn main() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - ]; + ); } diff --git a/src/test/run-pass/empty-mutable-vec.rs b/src/test/run-pass/empty-mutable-vec.rs index f3d9eba87b6..aafea1ef1ef 100644 --- a/src/test/run-pass/empty-mutable-vec.rs +++ b/src/test/run-pass/empty-mutable-vec.rs @@ -10,4 +10,6 @@ #[allow(unused_mut)]; +use std::vec_ng::Vec; + pub fn main() { let mut _v: Vec<int> = Vec::new(); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index 25dae36bcb1..c8a207cd4bd 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn test_int() { fn f() -> int { 10 } assert_eq!(f(), 10); @@ -15,7 +17,8 @@ fn test_int() { fn test_vec() { fn f() -> Vec<int> { vec!(10, 11) } - assert_eq!(f()[1], 11); + let vect = f(); + assert_eq!(*vect.get(1), 11); } fn test_generic() { diff --git a/src/test/run-pass/expr-match-fail.rs b/src/test/run-pass/expr-match-fail.rs index 71306a43f23..46ba63e452d 100644 --- a/src/test/run-pass/expr-match-fail.rs +++ b/src/test/run-pass/expr-match-fail.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn test_simple() { let r = match true { true => { true } false => { fail!() } }; assert_eq!(r, true); @@ -15,7 +17,7 @@ fn test_simple() { fn test_box() { let r = match true { true => { vec!(10) } false => { fail!() } }; - assert_eq!(r[0], 10); + assert_eq!(*r.get(0), 10); } pub fn main() { test_simple(); test_box(); } diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs deleted file mode 100644 index a111a878ddd..00000000000 --- a/src/test/run-pass/expr-repeat-vstore.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 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. - -#[feature(managed_boxes)]; - -pub fn main() { - let v: Vec<int> = vec!( 1, ..5 ); - println!("{}", v[0]); - println!("{}", v[1]); - println!("{}", v[2]); - println!("{}", v[3]); - println!("{}", v[4]); -} diff --git a/src/test/run-pass/for-loop-fail.rs b/src/test/run-pass/for-loop-fail.rs index d93f90937a1..bc9f1f642d2 100644 --- a/src/test/run-pass/for-loop-fail.rs +++ b/src/test/run-pass/for-loop-fail.rs @@ -8,4 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + pub fn main() { let x: Vec<int> = Vec::new(); for _ in x.iter() { fail!("moop"); } } diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 26395ed51f6..9aed300c564 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - +use std::vec_ng::Vec; fn two(it: |int|) { it(0); it(1); } @@ -17,10 +16,10 @@ pub fn main() { let mut a: Vec<int> = vec!(-1, -1, -1, -1); let mut p: int = 0; two(|i| { - two(|j| { a[p] = 10 * i + j; p += 1; }) + two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; }) }); - assert_eq!(a[0], 0); - assert_eq!(a[1], 1); - assert_eq!(a[2], 10); - assert_eq!(a[3], 11); + assert_eq!(*a.get(0), 0); + assert_eq!(*a.get(1), 1); + assert_eq!(*a.get(2), 10); + assert_eq!(*a.get(3), 11); } diff --git a/src/test/run-pass/generic-static-methods.rs b/src/test/run-pass/generic-static-methods.rs index ccc1936fa99..f0dcc5e2809 100644 --- a/src/test/run-pass/generic-static-methods.rs +++ b/src/test/run-pass/generic-static-methods.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + trait vec_utils<T> { fn map_<U>(x: &Self, f: |&T| -> U) -> Vec<U> ; } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index 5dea08ce646..314d045145b 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -13,12 +13,13 @@ extern crate getopts; use getopts::{optopt, getopts}; +use std::vec_ng::Vec; pub fn main() { let args = Vec::new(); let opts = vec!(optopt("b", "", "something", "SMTHNG")); - match getopts(args, opts) { + match getopts(args.as_slice(), opts.as_slice()) { Ok(ref m) => assert!(!m.opt_present("b")), Err(ref f) => fail!("{:?}", (*f).clone().to_err_msg()) diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index a11e286b969..c6fa702aeca 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -14,6 +14,8 @@ extern crate collections; +use std::vec_ng::Vec; + /** A somewhat reduced test case to expose some Valgrind issues. @@ -26,6 +28,7 @@ mod map_reduce { use collections::HashMap; use std::str; use std::task; + use std::vec_ng::Vec; pub type putter<'a> = 'a |~str, ~str|; @@ -52,7 +55,7 @@ mod map_reduce { } let (tx, rx) = channel(); println!("sending find_reducer"); - ctrl.send(find_reducer(key.as_bytes().to_owned(), tx)); + ctrl.send(find_reducer(Vec::from_slice(key.as_bytes()), tx)); println!("receiving"); let c = rx.recv(); println!("{:?}", c); @@ -83,7 +86,8 @@ mod map_reduce { mapper_done => { num_mappers -= 1; } find_reducer(k, cc) => { let mut c; - match reducers.find(&str::from_utf8(k).unwrap().to_owned()) { + match reducers.find(&str::from_utf8(k.as_slice()).unwrap() + .to_owned()) { Some(&_c) => { c = _c; } None => { c = 0; } } diff --git a/src/test/run-pass/html-literals.rs b/src/test/run-pass/html-literals.rs index 5141be1f178..aadb372fa12 100644 --- a/src/test/run-pass/html-literals.rs +++ b/src/test/run-pass/html-literals.rs @@ -12,6 +12,8 @@ #[feature(macro_rules)]; +use std::vec_ng::Vec; + /* This is an HTML parser written as a macro. It's all CPS, and we have diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 753e98422b3..7e9afc4de56 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -182,7 +182,7 @@ fn test_write() { // can do with them just yet (to test the output) fn test_print() { print!("hi"); - print!("{:?}", ~[0u8]); + print!("{:?}", vec!(0u8)); println!("hello"); println!("this is a {}", "test"); println!("{foo}", foo="bar"); diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index e3ea5886fa3..aeb2fdae902 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -13,10 +13,12 @@ #[feature(globs)]; #[allow(dead_assignment)]; -use std::slice::*; +use std::mem::*; pub fn main() { - let mut v = from_elem(0u, 0); - v = append(v, [4, 2]); - assert_eq!(from_fn(2, |i| 2*(i+1)), vec!(2, 4)); + assert_eq!(size_of::<u8>(), 1); + let (mut x, mut y) = (1, 2); + swap(&mut x, &mut y); + assert_eq!(x, 2); + assert_eq!(x, 1); } diff --git a/src/test/run-pass/infer-fn-tail-expr.rs b/src/test/run-pass/infer-fn-tail-expr.rs index 6642d1a5a8e..a3d1be5b4f1 100644 --- a/src/test/run-pass/infer-fn-tail-expr.rs +++ b/src/test/run-pass/infer-fn-tail-expr.rs @@ -10,6 +10,8 @@ // issue #680 +use std::vec_ng::Vec; + fn f() -> Vec<int> { Vec::new() } pub fn main() { } diff --git a/src/test/run-pass/integral-indexing.rs b/src/test/run-pass/integral-indexing.rs index cbbe101c58a..e0d0f3409ee 100644 --- a/src/test/run-pass/integral-indexing.rs +++ b/src/test/run-pass/integral-indexing.rs @@ -8,19 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - +use std::vec_ng::Vec; // 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[3u], 3); - assert_eq!(v[3u8], 3); - assert_eq!(v[3i8], 3); - assert_eq!(v[3u32], 3); - assert_eq!(v[3i32], 3); - println!("{}", v[3u8]); + 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); diff --git a/src/test/run-pass/issue-1821.rs b/src/test/run-pass/issue-1821.rs index ccd2399a06d..ef66a1e3a67 100644 --- a/src/test/run-pass/issue-1821.rs +++ b/src/test/run-pass/issue-1821.rs @@ -9,7 +9,10 @@ // except according to those terms. // Issue #1821 - Don't recurse trying to typecheck this + +use std::vec_ng::Vec; + enum t { - foo(vec!(t)) + foo(Vec<t>) } pub fn main() {} diff --git a/src/test/run-pass/issue-2502.rs b/src/test/run-pass/issue-2502.rs index cfdd226ef5c..33cac672b39 100644 --- a/src/test/run-pass/issue-2502.rs +++ b/src/test/run-pass/issue-2502.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct font<'a> { fontbuf: &'a Vec<u8> , } diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index eeda79e1355..d5cf80d2440 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -16,6 +16,7 @@ extern crate serialize; use collections::HashMap; use serialize::json; use std::option; +use std::vec_ng::Vec; enum object { bool_value(bool), @@ -60,9 +61,9 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, json::Json { &json::List(ref interfaces) => { - interfaces.map(|interface| { + interfaces.iter().map(|interface| { add_interface(store, managed_ip.clone(), (*interface).clone()) - }) + }).collect() } _ => { diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 9ffe4bc4d7e..8093c088165 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -16,6 +16,7 @@ use std::io; use std::fmt; +use std::vec_ng::Vec; enum square { bot, @@ -60,7 +61,8 @@ fn square_from_char(c: char) -> square { } } -fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr) -> vec!(vec!(square)) { +fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr) + -> Vec<Vec<square>> { let mut input: &mut io::Reader = &mut input; let mut grid = Vec::new(); let mut line = [0, ..10]; @@ -70,7 +72,7 @@ fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr) -> vec!(vec!(square row.push(square_from_char(*c as char)) } grid.push(row); - let width = grid[0].len(); + let width = grid.get(0).len(); for row in grid.iter() { assert!(row.len() == width) } grid } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index d625f6bcf92..c88f8b42d42 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -24,7 +24,7 @@ fn to_bools(bitv: Storage) -> Vec<bool> { Vec::from_fn(8, |i| { let w = i / 64; let b = i % 64; - let x = 1u64 & (bitv.storage[w] >> b); + let x = 1u64 & (*bitv.storage.get(w) >> b); x == 1u64 }) } @@ -36,7 +36,7 @@ pub fn main() { let bools2 = to_bools(Storage{storage: vec!(0b01100100)}); for i in range(0u, 8) { - println!("{} => {} vs {}", i, bools[i], bools2[i]); + println!("{} => {} vs {}", i, *bools.get(i), *bools2.get(i)); } assert_eq!(bools, bools2); diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index bc33bb72aa8..d2acf66003d 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + type Connection = 'static |Vec<u8> |; fn f() -> Option<Connection> { diff --git a/src/test/run-pass/issue-3389.rs b/src/test/run-pass/issue-3389.rs index 96ecc81edcc..fb4d7cedd4b 100644 --- a/src/test/run-pass/issue-3389.rs +++ b/src/test/run-pass/issue-3389.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct trie_node { content: Vec<~str> , children: Vec<trie_node> , diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 330cfdba245..a107670075d 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -19,9 +19,11 @@ // Extern mod controls linkage. Use controls the visibility of names to modules that are // already linked in. Using WriterUtil allows us to use the write_line method. + use std::str; use std::slice; use std::fmt; +use std::vec_ng::Vec; // Represents a position on a canvas. struct Point { @@ -62,9 +64,10 @@ impl Drop for AsciiArt { fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { // Use an anonymous function to build a vector of vectors containing // blank characters for each position in our canvas. - let lines = slice::build(Some(height), |push| { - for _ in range(0, height) { push(slice::from_elem(width, '.')); } - }); + let mut lines = Vec::new(); + for _ in range(0, height) { + lines.push(Vec::from_elem(width, '.')); + } // Rust code often returns values by omitting the trailing semi-colon // instead of using an explicit return statement. @@ -85,8 +88,8 @@ impl AsciiArt { // element is: // 1) potentially large // 2) needs to be modified - let row = &mut self.lines[v]; - row[h] = self.fill; + let row = self.lines.get_mut(v); + *row.get_mut(h) = self.fill; } } } @@ -97,7 +100,7 @@ impl AsciiArt { impl fmt::Show for AsciiArt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Convert each line into a string. - let lines = self.lines.map(|line| str::from_chars(*line)); + let lines = self.lines.map(|line| str::from_chars(line.as_slice())); // Concatenate the lines together using a new-line. write!(f.buf, "{}", lines.connect("\n")) diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index c5ae1460a2c..d27de2ea0ca 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::task; +use std::vec_ng::Vec; type RingBuffer = Vec<f64> ; type SamplesFn = proc(samples: &RingBuffer); @@ -23,7 +24,7 @@ fn foo(name: ~str, samples_chan: Sender<Msg>) { let mut samples_chan = samples_chan; let callback: SamplesFn = proc(buffer) { for i in range(0u, buffer.len()) { - println!("{}: {}", i, buffer[i]) + println!("{}: {}", i, *buffer.get(i)) } }; samples_chan.send(GetSamples(name.clone(), callback)); diff --git a/src/test/run-pass/issue-3991.rs b/src/test/run-pass/issue-3991.rs index 07a520db20b..7fb6b466479 100644 --- a/src/test/run-pass/issue-3991.rs +++ b/src/test/run-pass/issue-3991.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct HasNested { nest: Vec<Vec<int> > , } impl HasNested { fn method_push_local(&mut self) { - self.nest[0].push(0); + self.nest.get_mut(0).push(0); } } diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass/issue-4036.rs index fbd4e2cd742..13285179df8 100644 --- a/src/test/run-pass/issue-4036.rs +++ b/src/test/run-pass/issue-4036.rs @@ -14,7 +14,9 @@ // byproducts in vtable records. extern crate serialize; + use serialize::{json, Decodable}; +use std::vec_ng::Vec; pub fn main() { let json = json::from_str("[1]").unwrap(); diff --git a/src/test/run-pass/issue-5708.rs b/src/test/run-pass/issue-5708.rs index 0a79b1335c8..56461b647d8 100644 --- a/src/test/run-pass/issue-5708.rs +++ b/src/test/run-pass/issue-5708.rs @@ -18,6 +18,8 @@ This does not occur with concrete types, only with references to traits. */ +use std::vec_ng::Vec; + // original trait Inner { fn print(&self); diff --git a/src/test/run-pass/issue-6153.rs b/src/test/run-pass/issue-6153.rs index 079c2d9a1c4..ce87b0adde5 100644 --- a/src/test/run-pass/issue-6153.rs +++ b/src/test/run-pass/issue-6153.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn swap(f: |Vec<int> | -> Vec<int> ) -> Vec<int> { let x = vec!(1, 2, 3); f(x) diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index b2918b3ea39..66ddc1118d0 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -11,7 +11,6 @@ #[feature(managed_boxes)]; fn assert_repr_eq<T>(obj : T, expected : ~str) { - assert_eq!(expected, format!("{:?}", obj)); } @@ -19,14 +18,12 @@ pub fn main() { let abc = [1, 2, 3]; let tf = [true, false]; let x = [(), ()]; - let y = vec!((), ()); let slice = x.slice(0,1); let z = @x; assert_repr_eq(abc, ~"[1, 2, 3]"); assert_repr_eq(tf, ~"[true, false]"); assert_repr_eq(x, ~"[(), ()]"); - assert_repr_eq(y, ~"~[(), ()]"); assert_repr_eq(slice, ~"&[()]"); assert_repr_eq(&x, ~"&[(), ()]"); assert_repr_eq(z, ~"@[(), ()]"); diff --git a/src/test/run-pass/issue-9382.rs b/src/test/run-pass/issue-9382.rs index 6926018bafa..32ec1e674db 100644 --- a/src/test/run-pass/issue-9382.rs +++ b/src/test/run-pass/issue-9382.rs @@ -16,6 +16,8 @@ // from a vector to a slice. The drop glue was being invoked on // the temporary slice with a wrong type, triggering an LLVM assert. +use std::vec_ng::Vec; + struct Thing1<'a> { baz: &'a [~int], bar: ~u64, @@ -32,7 +34,7 @@ pub fn main() { bar: ~32, }; Thing1 { - baz: Vec::new(), + baz: Vec::new().as_slice(), bar: ~32, }; let _t2_fixed = Thing2 { @@ -40,7 +42,7 @@ pub fn main() { bar: 32, }; Thing2 { - baz: Vec::new(), + baz: Vec::new().as_slice(), bar: 32, }; } diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs deleted file mode 100644 index f215958493f..00000000000 --- a/src/test/run-pass/ivec-add.rs +++ /dev/null @@ -1,23 +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. - -fn double<T:Clone>(a: T) -> Vec<T> { return vec!(a.clone()) + vec!(a); } - -fn double_int(a: int) -> Vec<int> { return vec!(a) + vec!(a); } - -pub fn main() { - let mut d = double(1); - assert_eq!(d[0], 1); - assert_eq!(d[1], 1); - - d = double_int(1); - assert_eq!(d[0], 1); - assert_eq!(d[1], 1); -} diff --git a/src/test/run-pass/ivec-pass-by-value.rs b/src/test/run-pass/ivec-pass-by-value.rs index cd58689a19e..9c8dd152e25 100644 --- a/src/test/run-pass/ivec-pass-by-value.rs +++ b/src/test/run-pass/ivec-pass-by-value.rs @@ -8,5 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn f(_a: Vec<int> ) { } pub fn main() { f(vec!(1, 2, 3, 4, 5)); } diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index 81ff6fd7adc..1d617de30ea 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::task; +use std::vec_ng::Vec; fn producer(tx: &Sender<Vec<u8>>) { tx.send( diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 39eef6526a6..05941b0142c 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -11,6 +11,8 @@ // This should typecheck even though the type of e is not fully // resolved when we finish typechecking the ||. +use std::vec_ng::Vec; + struct Refs { refs: Vec<int> , n: int } pub fn main() { diff --git a/src/test/run-pass/liveness-move-in-loop.rs b/src/test/run-pass/liveness-move-in-loop.rs index c04a595ac24..22a0c9005ba 100644 --- a/src/test/run-pass/liveness-move-in-loop.rs +++ b/src/test/run-pass/liveness-move-in-loop.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn take(x: int) -> int {x} fn the_loop() { diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs deleted file mode 100644 index c912fd68a6c..00000000000 --- a/src/test/run-pass/log-str.rs +++ /dev/null @@ -1,19 +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. - -use std::repr; - -pub fn main() { - let act = repr::repr_to_str(&vec!(1, 2, 3)); - assert_eq!(~"~[1, 2, 3]", act); - - let act = format!("{:?}/{:6?}", vec!(1, 2, 3), ~"hi"); - assert_eq!(act, ~"~[1, 2, 3]/~\"hi\" "); -} diff --git a/src/test/run-pass/match-vec-rvalue.rs b/src/test/run-pass/match-vec-rvalue.rs index ba8ba6263df..38952fc4daa 100644 --- a/src/test/run-pass/match-vec-rvalue.rs +++ b/src/test/run-pass/match-vec-rvalue.rs @@ -10,13 +10,15 @@ // Tests that matching rvalues with drops does not crash. +use std::vec_ng::Vec; + pub fn main() { match vec!(1, 2, 3) { x => { assert_eq!(x.len(), 3); - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); + assert_eq!(*x.get(0), 1); + assert_eq!(*x.get(1), 2); + assert_eq!(*x.get(2), 3); } } } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 5df6738797d..182aa947006 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -10,6 +10,8 @@ // ignore-fast +use std::vec_ng::Vec; + trait vec_monad<A> { fn bind<B>(&self, f: |&A| -> Vec<B> ) -> Vec<B> ; } diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index b27914fff80..34e169f3d61 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test(foo: ~Vec<int> ) { assert!((foo[0] == 10)); } +use std::vec_ng::Vec; + +fn test(foo: ~Vec<int> ) { assert!((*foo.get(0) == 10)); } pub fn main() { let x = ~vec!(10); diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index 2cc56ec9227..89316c37a3e 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -10,7 +10,9 @@ #[feature(managed_boxes)]; -fn test(foo: @Vec<int> ) { assert!((foo[0] == 10)); } +use std::vec_ng::Vec; + +fn test(foo: @Vec<int> ) { assert!((*foo.get(0) == 10)); } pub fn main() { let x = @vec!(10); diff --git a/src/test/run-pass/mutable-alias-vec.rs b/src/test/run-pass/mutable-alias-vec.rs index eb236b29263..28dd89edd62 100644 --- a/src/test/run-pass/mutable-alias-vec.rs +++ b/src/test/run-pass/mutable-alias-vec.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn grow(v: &mut Vec<int>) { +fn grow(v: &mut Vec<int> ) { v.push(1); } diff --git a/src/test/run-pass/mutable-vec-drop.rs b/src/test/run-pass/mutable-vec-drop.rs index 9a83907c66f..1f4196ef06f 100644 --- a/src/test/run-pass/mutable-vec-drop.rs +++ b/src/test/run-pass/mutable-vec-drop.rs @@ -11,6 +11,8 @@ #[feature(managed_boxes)]; #[allow(unused_mut)]; +use std::vec_ng::Vec; + struct Pair { a: int, b: int} pub fn main() { diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 20e2675fccf..3d4639b2506 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + #[deriving(Clone)] struct myvec<X>(Vec<X> ); @@ -18,13 +20,15 @@ fn myvec_deref<X:Clone>(mv: myvec<X>) -> Vec<X> { fn myvec_elt<X>(mv: myvec<X>) -> X { let myvec(v) = mv; - return v[0]; + return v.move_iter().next().unwrap(); } pub fn main() { let mv = myvec(vec!(1, 2, 3)); - assert_eq!(myvec_deref(mv.clone())[1], 2); + let mv_clone = mv.clone(); + let mv_clone = myvec_deref(mv_clone); + assert_eq!(*mv_clone.get(1), 2); assert_eq!(myvec_elt(mv.clone()), 1); let myvec(v) = mv; - assert_eq!(v[2], 3); + assert_eq!(*v.get(2), 3); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 117cd6d572e..c071983fdf3 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -11,6 +11,7 @@ #[feature(macro_rules)]; use std::{option, cast}; +use std::vec_ng::Vec; // Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions, // which "says that a destructor applied to an object built from a constructor diff --git a/src/test/run-pass/nullable-pointer-size.rs b/src/test/run-pass/nullable-pointer-size.rs index 9ce68fa8ffc..75a98913c97 100644 --- a/src/test/run-pass/nullable-pointer-size.rs +++ b/src/test/run-pass/nullable-pointer-size.rs @@ -11,6 +11,7 @@ #[feature(macro_rules)]; use std::mem; +use std::vec_ng::Vec; enum E<T> { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) } struct S<T>(int, T); @@ -41,6 +42,5 @@ pub fn main() { check_type!(~int); check_type!(@int); check_type!(~str); - check_type!(Vec<int> ); check_type!(extern fn()); } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs index 7a0c7b34d2f..ec284b24dbd 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs @@ -12,6 +12,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + // Test invoked `&self` methods on owned objects where the values // closed over contain managed values. This implies that the ~ boxes // will have headers that must be skipped over. @@ -31,13 +33,13 @@ impl FooTrait for BarStruct { } pub fn main() { - let foos: vec!( ~FooTrait: ) = vec!( + let foos: Vec<~FooTrait:> = vec!( ~BarStruct{ x: @0 } as ~FooTrait:, ~BarStruct{ x: @1 } as ~FooTrait:, ~BarStruct{ x: @2 } as ~FooTrait: ); for i in range(0u, foos.len()) { - assert_eq!(i, foos[i].foo()); + assert_eq!(i, foos.get(i).foo()); } } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index f9f59f88bf1..13258bed80f 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -12,6 +12,8 @@ // closed over do not contain managed values, and thus the ~ boxes do // not have headers. +use std::vec_ng::Vec; + trait FooTrait { fn foo(&self) -> uint; } @@ -27,13 +29,13 @@ impl FooTrait for BarStruct { } pub fn main() { - let foos: vec!( ~FooTrait ) = vec!( + let foos: Vec<~FooTrait> = vec!( ~BarStruct{ x: 0 } as ~FooTrait, ~BarStruct{ x: 1 } as ~FooTrait, ~BarStruct{ x: 2 } as ~FooTrait ); for i in range(0u, foos.len()) { - assert_eq!(i, foos[i].foo()); + assert_eq!(i, foos.get(i).foo()); } } diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index 865e1cc601b..c918202b31c 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -12,6 +12,7 @@ // takes its argument *by reference*. use std::ops::Index; +use std::vec_ng::Vec; struct AssociationList<K,V> { pairs: Vec<AssociationPair<K,V>> } diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index 0ff282b68f8..43f68b42329 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -10,6 +10,7 @@ use std::cell::RefCell; use std::rc::Rc; +use std::vec_ng::Vec; #[deriving(Eq, Show)] struct Point { @@ -43,7 +44,9 @@ pub fn main() { assert_eq!(*(*p).borrow(), Point {x: 3, y: 5}); let v = Rc::new(RefCell::new(vec!(1, 2, 3))); - (*(*v).borrow_mut())[0] = 3; - (*(*v).borrow_mut())[1] += 3; - assert_eq!(((*(*v).borrow())[0], (*(*v).borrow())[1], (*(*v).borrow())[2]), (3, 5, 3)); + *(*(*v).borrow_mut()).get_mut(0) = 3; + *(*(*v).borrow_mut()).get_mut(1) += 3; + assert_eq!((*(*(*v).borrow()).get(0), + *(*(*v).borrow()).get(1), + *(*(*v).borrow()).get(2)), (3, 5, 3)); } diff --git a/src/test/run-pass/packed-struct-generic-size.rs b/src/test/run-pass/packed-struct-generic-size.rs index b297fc7e13f..02c030f3845 100644 --- a/src/test/run-pass/packed-struct-generic-size.rs +++ b/src/test/run-pass/packed-struct-generic-size.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::mem; +use std::vec_ng::Vec; #[packed] struct S<T, S> { diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index d5f1caaf74d..cd5ce150bcb 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -10,11 +10,13 @@ // Check that functions can modify local state. +use std::vec_ng::Vec; + fn sums_to(v: Vec<int> , sum: int) -> bool { let mut i = 0u; let mut sum0 = 0; while i < v.len() { - sum0 += v[i]; + sum0 += *v.get(i); i += 1u; } return sum0 == sum; @@ -24,7 +26,7 @@ fn sums_to_using_uniq(v: Vec<int> , sum: int) -> bool { let mut i = 0u; let mut sum0 = ~0; while i < v.len() { - *sum0 += v[i]; + *sum0 += *v.get(i); i += 1u; } return *sum0 == sum; @@ -34,7 +36,7 @@ fn sums_to_using_rec(v: Vec<int> , sum: int) -> bool { let mut i = 0u; let mut sum0 = F {f: 0}; while i < v.len() { - sum0.f += v[i]; + sum0.f += *v.get(i); i += 1u; } return sum0.f == sum; @@ -46,7 +48,7 @@ fn sums_to_using_uniq_rec(v: Vec<int> , sum: int) -> bool { let mut i = 0u; let mut sum0 = F {f: ~0}; while i < v.len() { - *sum0.f += v[i]; + *sum0.f += *v.get(i); i += 1u; } return *sum0.f == sum; diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index 8597bf39e0e..9e2be517855 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + trait sum { fn sum_(self) -> int; } @@ -23,17 +25,17 @@ fn call_sum(x: &[int]) -> int { x.sum_() } pub fn main() { let x = vec!(1, 2, 3); - let y = call_sum(x); + let y = call_sum(x.as_slice()); println!("y=={}", y); assert_eq!(y, 6); let x = vec!(1, 2, 3); - let y = x.sum_(); + let y = x..as_slice().sum_(); println!("y=={}", y); assert_eq!(y, 6); let x = vec!(1, 2, 3); - let y = x.sum_(); + let y = x.as_slice().sum_(); println!("y=={}", y); assert_eq!(y, 6); } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 22f30141028..3b8f7c4ae61 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -11,6 +11,7 @@ #[feature(managed_boxes)]; use std::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque}; +use std::vec_ng::Vec; struct MyVisitor { types: Vec<~str> , @@ -151,10 +152,11 @@ pub fn main() { visit_ty::<int>(&mut v); visit_ty::<i8>(&mut v); visit_ty::<i16>(&mut v); - visit_ty::<Vec<int> >(&mut v); for s in v.types.iter() { println!("type: {}", (*s).clone()); } - assert_eq!(v.types.clone(), vec!(~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]")); + + let vec_types: Vec<~str> = v.types.clone().move_iter().collect(); + assert_eq!(vec_types, vec!(~"bool", ~"int", ~"i8", ~"i16")); } diff --git a/src/test/run-pass/regions-borrow-evec-uniq.rs b/src/test/run-pass/regions-borrow-evec-uniq.rs index b17b025eb58..f3f0724bd57 100644 --- a/src/test/run-pass/regions-borrow-evec-uniq.rs +++ b/src/test/run-pass/regions-borrow-evec-uniq.rs @@ -8,16 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn foo(x: &[int]) -> int { x[0] } pub fn main() { let p = vec!(1,2,3,4,5); - let r = foo(p); + let r = foo(p.as_slice()); assert_eq!(r, 1); let p = vec!(5,4,3,2,1); - let r = foo(p); + let r = foo(p.as_slice()); assert_eq!(r, 5); } diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index 3b5ff3f6092..3f86f8612ed 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -11,6 +11,8 @@ // Test lifetimes are linked properly when we create dependent region pointers. // Issue #3148. +use std::vec_ng::Vec; + struct A { value: B } @@ -41,7 +43,7 @@ fn get_v2<'v>(a: &'v A, i: uint) -> &'v int { fn get_v3<'v>(a: &'v A, i: uint) -> &'v int { let foo = &a.value; - &foo.v3[i] + foo.v3.get(i) } fn get_v4<'v>(a: &'v A, _i: uint) -> &'v int { @@ -96,7 +98,7 @@ pub fn main() { assert_eq!(*p, a.value.v2[1]); let p = get_v3(&a, 1); - assert_eq!(*p, a.value.v3[1]); + assert_eq!(*p, *a.value.v3.get(1)); let p = get_v4(&a, 1); assert_eq!(*p, a.value.v4.f); diff --git a/src/test/run-pass/regions-dependent-autoslice.rs b/src/test/run-pass/regions-dependent-autoslice.rs index 8cbdff6691a..3a472decc7c 100644 --- a/src/test/run-pass/regions-dependent-autoslice.rs +++ b/src/test/run-pass/regions-dependent-autoslice.rs @@ -11,6 +11,8 @@ // Test lifetimes are linked properly when we autoslice a vector. // Issue #3148. +use std::vec_ng::Vec; + fn subslice1<'r>(v: &'r [uint]) -> &'r [uint] { v } fn both<'r>(v: &'r [uint]) -> &'r [uint] { @@ -19,5 +21,5 @@ fn both<'r>(v: &'r [uint]) -> &'r [uint] { pub fn main() { let v = vec!(1,2,3); - both(v); + both(v.as_slice()); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index 67542a5ded1..b031cfea93e 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn view<'r, T>(x: &'r [T]) -> &'r [T] {x} pub fn main() { let v = vec!(1, 2, 3); - let x = view(v); - let y = view(x); - assert!((v[0] == x[0]) && (v[0] == y[0])); + let x = view(v.as_slice()); + let y = view(x.as_slice()); + assert!((*v.get(0) == x[0]) && (*v.get(0) == y[0])); } diff --git a/src/test/run-pass/regions-mock-tcx.rs b/src/test/run-pass/regions-mock-tcx.rs index 7c87c858d42..fa2050c69f2 100644 --- a/src/test/run-pass/regions-mock-tcx.rs +++ b/src/test/run-pass/regions-mock-tcx.rs @@ -24,6 +24,7 @@ use collections::HashMap; use std::cast; use std::libc; use std::mem; +use std::vec_ng::Vec; type Type<'tcx> = &'tcx TypeStructure<'tcx>; diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index ddb34edad98..8694040269c 100644 --- a/src/test/run-pass/seq-compare.rs +++ b/src/test/run-pass/seq-compare.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - +use std::vec_ng::Vec; pub fn main() { assert!((~"hello" < ~"hellr")); diff --git a/src/test/run-pass/shadow.rs b/src/test/run-pass/shadow.rs index e4b96856560..02ea8f61938 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + fn foo(c: Vec<int> ) { let a: int = 5; let mut b: Vec<int> = Vec::new(); diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index 058041ff710..c52a0e54279 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -15,6 +15,8 @@ // interior record which is then itself interior to // something else, shape calculations were off. +use std::vec_ng::Vec; + #[deriving(Clone)] enum opt_span { //hack (as opposed to option), to make `span` compile @@ -41,7 +43,7 @@ type ty_ = uint; struct Path_ { global: bool, idents: Vec<~str> , - types: vec!(@ty), + types: Vec<@ty>, } type path = Spanned<Path_>; @@ -56,7 +58,11 @@ struct X { pub fn main() { let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none}; let t: @ty = @Spanned { data: 3u, span: sp }; - let p_: Path_ = Path_ { global: true, idents: vec!(~"hi"), types: Vec<t> }; + let p_: Path_ = Path_ { + global: true, + idents: vec!(~"hi"), + types: vec!(t), + }; let p: path = Spanned { data: p_, span: sp }; let x = X { sp: sp, path: p }; println!("{:?}", x.path.clone()); diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index f43011df4c2..9b06e175886 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - +use std::vec_ng::Vec; enum clam<T> { a(T, int), b, } fn uhoh<T>(v: Vec<clam<T>> ) { - match v[1] { + match *v.get(1) { a::<T>(ref _t, ref u) => { println!("incorrect"); println!("{:?}", u); diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index d727f66d948..5a5e9f7353d 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -10,6 +10,8 @@ // ignore-fast +use std::vec_ng::Vec; + pub trait plus { fn plus(&self) -> int; } @@ -60,8 +62,10 @@ pub fn main() { assert_eq!((~"hi").plus(), 200); assert_eq!((vec!(1)).length_().str(), ~"1"); - assert_eq!((vec!(3, 4)).map_(|a| *a + 4 )[0], 7); - assert_eq!((vec!(3, 4)).map_::<uint>(|a| *a as uint + 4u )[0], 7u); + let vect = vec!(3, 4).map_(|a| *a + 4); + assert_eq!(*vect.get(0), 7); + let vect = (vec!(3, 4)).map_::<uint>(|a| *a as uint + 4u); + assert_eq!(*vect.get(0), 7u); let mut x = 0u; 10u.multi(|_n| x += 2u ); assert_eq!(x, 20u); diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs index 1dbd29a781e..1a844061888 100644 --- a/src/test/run-pass/swap-2.rs +++ b/src/test/run-pass/swap-2.rs @@ -9,14 +9,15 @@ // except according to those terms. use std::mem::swap; +use std::vec_ng::Vec; pub fn main() { let mut a: Vec<int> = vec!(0, 1, 2, 3, 4, 5, 6); a.swap(2, 4); - assert_eq!(a[2], 4); - assert_eq!(a[4], 2); + assert_eq!(*a.get(2), 4); + assert_eq!(*a.get(4), 2); let mut n = 42; - swap(&mut n, &mut a[0]); - assert_eq!(a[0], 42); + swap(&mut n, a.get_mut(0)); + assert_eq!(*a.get(0), 42); assert_eq!(n, 0); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 416aaec40f1..69ede9b4d05 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -9,6 +9,7 @@ // except according to those terms. use std::cmp; +use std::vec_ng::Vec; // Tests of ports and channels on various types fn test_rec() { @@ -29,9 +30,9 @@ fn test_vec() { let v0: Vec<int> = vec!(0, 1, 2); tx.send(v0); let v1 = rx.recv(); - assert_eq!(v1[0], 0); - assert_eq!(v1[1], 1); - assert_eq!(v1[2], 2); + assert_eq!(*v1.get(0), 0); + assert_eq!(*v1.get(1), 1); + assert_eq!(*v1.get(2), 2); } fn test_str() { diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index a239a2de78a..471a55ee418 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -11,6 +11,7 @@ // ignore-fast use std::task; +use std::vec_ng::Vec; pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 7d37993ad75..40d0f401758 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -19,6 +19,7 @@ extern crate sync; use sync::Arc; use std::task; +use std::vec_ng::Vec; trait Pet { fn name(&self, blk: |&str|); @@ -90,22 +91,14 @@ fn check_legs(arc: Arc<Vec<~Pet:Share+Send>>) { } assert!(legs == 12); } -<<<<<<< HEAD -fn check_names(arc: Arc<~[~Pet:Share+Send]>) { -======= -fn check_names(arc: Arc<Vec<~Pet:Freeze+Send> >) { ->>>>>>> test: Automatically remove all `~[T]` from tests. +fn check_names(arc: Arc<Vec<~Pet:Share+Send>>) { for pet in arc.get().iter() { pet.name(|name| { assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8); }) } } -<<<<<<< HEAD -fn check_pedigree(arc: Arc<~[~Pet:Share+Send]>) { -======= -fn check_pedigree(arc: Arc<Vec<~Pet:Freeze+Send> >) { ->>>>>>> test: Automatically remove all `~[T]` from tests. +fn check_pedigree(arc: Arc<Vec<~Pet:Share+Send>>) { for pet in arc.get().iter() { assert!(pet.of_good_pedigree()); } diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index a75a1b61c59..5cc40f2dd37 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -10,6 +10,8 @@ // ignore-fast +use std::vec_ng::Vec; + trait to_str { fn to_string(&self) -> ~str; } @@ -31,7 +33,7 @@ impl<T> map<T> for Vec<T> { let mut r = Vec::new(); // FIXME: #7355 generates bad code with VecIterator for i in range(0u, self.len()) { - r.push(f(&self[i])); + r.push(f(self.get(i))); } r } @@ -48,5 +50,5 @@ pub fn main() { assert_eq!(foo(vec!(1)), vec!(~"hi")); assert_eq!(bar::<int, Vec<int> >(vec!(4, 5)), vec!(~"4", ~"5")); assert_eq!(bar::<~str, Vec<~str> >(vec!(~"x", ~"y")), vec!(~"x", ~"y")); - assert_eq!(bar::<(), vec!(())>(vec!(())), vec!(~"()")); + assert_eq!(bar::<(), Vec<()>>(vec!(())), vec!(~"()")); } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index f16f5c1a419..fa320bba982 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -10,6 +10,8 @@ // ignore-fast +use std::vec_ng::Vec; + trait to_str { fn to_string(&self) -> ~str; } diff --git a/src/test/run-pass/tydesc-name.rs b/src/test/run-pass/tydesc-name.rs index f37bfe19ad3..42ce18dccaf 100644 --- a/src/test/run-pass/tydesc-name.rs +++ b/src/test/run-pass/tydesc-name.rs @@ -19,7 +19,6 @@ struct Foo<T> { pub fn main() { unsafe { assert_eq!((*get_tydesc::<int>()).name, "int"); - assert_eq!((*get_tydesc::<Vec<int> >()).name, "~[int]"); assert_eq!((*get_tydesc::<Foo<uint>>()).name, "Foo<uint>"); } } diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index b8312bcb282..c0a22bacfd2 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + struct S<T> { a: T, b: uint, diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index 1c026bf91d1..87ce07c596c 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + pub fn main() { let i = ~vec!(100); - assert_eq!(i[0], 100); + assert_eq!(*i.get(0), 100); } diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index 762afbe15e8..9e73039a0a7 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -8,16 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; + pub fn main() { let mut a = vec!(~10); let b = a.clone(); - assert_eq!(*a[0], 10); - assert_eq!(*b[0], 10); + assert_eq!(**a.get(0), 10); + assert_eq!(**b.get(0), 10); // This should only modify the value in a, not b - *a[0] = 20; + **a.get_mut(0) = 20; - assert_eq!(*a[0], 20); - assert_eq!(*b[0], 10); + assert_eq!(**a.get(0), 20); + assert_eq!(**b.get(0), 10); } diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 7f0aa93042a..82d3a29d901 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -9,5 +9,6 @@ // except according to those terms. pub fn main() { - assert!((vec!(~100))[0] == ~100); + let vect = vec!(~100); + assert!(*vect.get(0) == ~100); } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 0e85c67edb7..f6393415955 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -9,17 +9,18 @@ // except according to those terms. use std::str; +use std::vec_ng::Vec; pub fn main() { // Chars of 1, 2, 3, and 4 bytes - let chs: ~[char] = ~['e', 'é', '€', '\U00010000']; - let s: ~str = str::from_chars(chs); - let schs: ~[char] = s.chars().collect(); + let chs: Vec<char> = vec!('e', 'é', '€', '\U00010000'); + let s: ~str = str::from_chars(chs.as_slice()); + let schs: Vec<char> = s.chars().collect(); assert!(s.len() == 10u); assert!(s.char_len() == 4u); assert!(schs.len() == 4u); - assert!(str::from_chars(schs) == s); + assert!(str::from_chars(schs.as_slice()) == s); assert!(s.char_at(0u) == 'e'); assert!(s.char_at(1u) == 'é'); diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index 9b42a25956e..0a9a65ac0e7 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec; + pub fn main() { - let a: ~[int] = ~[1, 2, 3, 4, 5]; - let b: ~[int] = ~[6, 7, 8, 9, 0]; - let v: ~[int] = a + b; + let a: Vec<int> = vec!(1, 2, 3, 4, 5); + let b: Vec<int> = vec!(6, 7, 8, 9, 0); + let v: Vec<int> = vec::append(a, b.as_slice()); println!("{}", v[9]); - assert_eq!(v[0], 1); - assert_eq!(v[7], 8); - assert_eq!(v[9], 0); + assert_eq!(*v.get(0), 1); + assert_eq!(*v.get(7), 8); + assert_eq!(*v.get(9), 0); } diff --git a/src/test/run-pass/vec-drop.rs b/src/test/run-pass/vec-drop.rs index 270b1cb895d..675c06c2570 100644 --- a/src/test/run-pass/vec-drop.rs +++ b/src/test/run-pass/vec-drop.rs @@ -10,6 +10,8 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + struct Pair { x: int, y: int } pub fn main() { diff --git a/src/test/run-pass/vec-growth.rs b/src/test/run-pass/vec-growth.rs index e51d898e1d4..4414da91ce7 100644 --- a/src/test/run-pass/vec-growth.rs +++ b/src/test/run-pass/vec-growth.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - +use std::vec_ng::Vec; pub fn main() { let mut v = vec!(1); @@ -16,9 +16,9 @@ pub fn main() { v.push(3); v.push(4); v.push(5); - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); - assert_eq!(v[3], 4); - assert_eq!(v[4], 5); + assert_eq!(*v.get(0), 1); + assert_eq!(*v.get(1), 2); + assert_eq!(*v.get(2), 3); + assert_eq!(*v.get(3), 4); + assert_eq!(*v.get(4), 5); } diff --git a/src/test/run-pass/vec-ivec-deadlock.rs b/src/test/run-pass/vec-ivec-deadlock.rs deleted file mode 100644 index fc9ab277aa1..00000000000 --- a/src/test/run-pass/vec-ivec-deadlock.rs +++ /dev/null @@ -1,17 +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. - -#[allow(dead_assignment)]; - -pub fn main() { - let a = vec!(1, 2, 3, 4, 5); - let mut b = vec!(a.clone(), a.clone()); - b = b + b; // FIXME(#3387)---can't write b += b -} diff --git a/src/test/run-pass/vec-late-init.rs b/src/test/run-pass/vec-late-init.rs index 7239ae8a1d6..815235ef980 100644 --- a/src/test/run-pass/vec-late-init.rs +++ b/src/test/run-pass/vec-late-init.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - +use std::vec_ng::Vec; pub fn main() { let mut later: Vec<int> ; if true { later = vec!(1); } else { later = vec!(2); } - println!("{}", later[0]); + println!("{}", *later.get(0)); } diff --git a/src/test/run-pass/vec-trailing-comma.rs b/src/test/run-pass/vec-trailing-comma.rs deleted file mode 100644 index 683161178f2..00000000000 --- a/src/test/run-pass/vec-trailing-comma.rs +++ /dev/null @@ -1,20 +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. - -// Issue #2482. - -pub fn main() { - let v1: Vec<int> = vec!(10, 20, 30); - let v2: Vec<int> = vec!(10, 20, 30); - assert_eq!(v1[2], v2[2]); - let v3: Vec<int> = vec!(10); - let v4: Vec<int> = vec!(10); - assert_eq!(v3[0], v4[0]); -} diff --git a/src/test/run-pass/vec.rs b/src/test/run-pass/vec.rs index 06869bcb76e..7fd3b57b0e5 100644 --- a/src/test/run-pass/vec.rs +++ b/src/test/run-pass/vec.rs @@ -8,17 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - +use std::vec_ng::Vec; pub fn main() { let v: Vec<int> = vec!(10, 20); - assert_eq!(v[0], 10); - assert_eq!(v[1], 20); - let mut x: int = 0; - assert_eq!(v[x], 10); - assert_eq!(v[x + 1], 20); + assert_eq!(*v.get(0), 10); + assert_eq!(*v.get(1), 20); + let mut x: uint = 0; + assert_eq!(*v.get(x), 10); + assert_eq!(*v.get(x + 1), 20); x = x + 1; - assert_eq!(v[x], 20); - assert_eq!(v[x - 1], 10); + assert_eq!(*v.get(x), 20); + assert_eq!(*v.get(x - 1), 10); } diff --git a/src/test/run-pass/vector-no-ann-2.rs b/src/test/run-pass/vector-no-ann-2.rs index 72e1676bccb..56624cecdca 100644 --- a/src/test/run-pass/vector-no-ann-2.rs +++ b/src/test/run-pass/vector-no-ann-2.rs @@ -10,4 +10,6 @@ #[feature(managed_boxes)]; +use std::vec_ng::Vec; + pub fn main() { let _quux: @Vec<uint> = @Vec::new(); } diff --git a/src/test/run-pass/while-with-break.rs b/src/test/run-pass/while-with-break.rs index a7328267541..9b3baf80f8f 100644 --- a/src/test/run-pass/while-with-break.rs +++ b/src/test/run-pass/while-with-break.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::vec_ng::Vec; pub fn main() { let mut i: int = 90; |
