test: Automatically remove all ~[T] from tests.

This commit is contained in:
Patrick Walton 2014-03-05 14:02:44 -08:00 committed by Huon Wilson
parent 0b714b4ba6
commit 579eb2400b
247 changed files with 626 additions and 640 deletions

View File

@ -12,6 +12,7 @@
use std::libc; use std::libc;
use std::vec_ng::Vec;
#[link(name="rustrt")] #[link(name="rustrt")]
extern { extern {
pub fn rust_get_test_int() -> libc::intptr_t; pub fn rust_get_test_int() -> libc::intptr_t;

View File

@ -10,21 +10,21 @@
pub mod kitties { pub mod kitties {
pub struct cat<U> { pub struct cat<U> {
priv info : ~[U], priv info : Vec<U> ,
priv meows : uint, priv meows : uint,
how_hungry : int, how_hungry : int,
} }
impl<U> cat<U> { impl<U> cat<U> {
pub fn speak<T>(&mut self, stuff: ~[T]) { pub fn speak<T>(&mut self, stuff: Vec<T> ) {
self.meows += stuff.len(); self.meows += stuff.len();
} }
pub fn meow_count(&mut self) -> uint { self.meows } pub fn meow_count(&mut self) -> uint { self.meows }
} }
pub fn cat<U>(in_x : uint, in_y : int, in_info: ~[U]) -> cat<U> { pub fn cat<U>(in_x : uint, in_y : int, in_info: Vec<U> ) -> cat<U> {
cat { cat {
meows: in_x, meows: in_x,
how_hungry: in_y, how_hungry: in_y,

View File

@ -19,7 +19,7 @@ pub struct Entry<A,B> {
pub struct alist<A,B> { pub struct alist<A,B> {
eq_fn: extern "Rust" fn(A,A) -> bool, eq_fn: extern "Rust" fn(A,A) -> bool,
data: @RefCell<~[Entry<A,B>]>, data: @RefCell<Vec<Entry<A,B>> >,
} }
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) { pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
@ -47,7 +47,7 @@ pub fn new_int_alist<B:'static>() -> alist<int, B> {
fn eq_int(a: int, b: int) -> bool { a == b } fn eq_int(a: int, b: int) -> bool { a == b }
return alist { return alist {
eq_fn: eq_int, eq_fn: eq_int,
data: @RefCell::new(~[]), data: @RefCell::new(Vec::new()),
}; };
} }
@ -57,6 +57,6 @@ pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
fn eq_int(a: int, b: int) -> bool { a == b } fn eq_int(a: int, b: int) -> bool { a == b }
return alist { return alist {
eq_fn: eq_int, eq_fn: eq_int,
data: @RefCell::new(~[]), data: @RefCell::new(Vec::new()),
}; };
} }

View File

@ -11,7 +11,7 @@
#[crate_id="cci_no_inline_lib"]; #[crate_id="cci_no_inline_lib"];
// same as cci_iter_lib, more-or-less, but not marked inline // same as cci_iter_lib, more-or-less, but not marked inline
pub fn iter(v: ~[uint], f: |uint|) { pub fn iter(v: Vec<uint> , f: |uint|) {
let mut i = 0u; let mut i = 0u;
let n = v.len(); let n = v.len();
while i < n { while i < n {

View File

@ -17,7 +17,7 @@ extern crate collections;
use std::cell::RefCell; use std::cell::RefCell;
use collections::HashMap; use collections::HashMap;
pub type header_map = HashMap<~str, @RefCell<~[@~str]>>; pub type header_map = HashMap<~str, @RefCell<vec!(@~str)>>;
// the unused ty param is necessary so this gets monomorphized // the unused ty param is necessary so this gets monomorphized
pub fn request<T>(req: &header_map) { pub fn request<T>(req: &header_map) {

View File

@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
pub unsafe fn f(xs: ~[int]) { pub unsafe fn f(xs: Vec<int> ) {
xs.map(|_x| { unsafe fn q() { fail!(); } }); xs.map(|_x| { unsafe fn q() { fail!(); } });
} }

View File

@ -21,6 +21,7 @@ use std::mem::swap;
use std::os; use std::os;
use std::str; use std::str;
use std::slice; use std::slice;
use std::vec;
use std::io::File; use std::io::File;
macro_rules! bench ( macro_rules! bench (
@ -61,8 +62,8 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: ||) {
} }
fn shift_push() { fn shift_push() {
let mut v1 = slice::from_elem(30000, 1); let mut v1 = Vec::from_elem(30000, 1);
let mut v2 = ~[]; let mut v2 = Vec::new();
while v1.len() > 0 { while v1.len() > 0 {
v2.push(v1.shift().unwrap()); v2.push(v1.shift().unwrap());
@ -85,7 +86,7 @@ fn read_line() {
fn vec_plus() { fn vec_plus() {
let mut r = rand::task_rng(); let mut r = rand::task_rng();
let mut v = ~[]; let mut v = Vec::new();
let mut i = 0; let mut i = 0;
while i < 1500 { while i < 1500 {
let rv = slice::from_elem(r.gen_range(0u, i + 1), i); let rv = slice::from_elem(r.gen_range(0u, i + 1), i);
@ -101,15 +102,15 @@ fn vec_plus() {
fn vec_append() { fn vec_append() {
let mut r = rand::task_rng(); let mut r = rand::task_rng();
let mut v = ~[]; let mut v = Vec::new();
let mut i = 0; let mut i = 0;
while i < 1500 { while i < 1500 {
let rv = slice::from_elem(r.gen_range(0u, i + 1), i); let rv = slice::from_elem(r.gen_range(0u, i + 1), i);
if r.gen() { if r.gen() {
v = slice::append(v, rv); v = vec::append(v, rv);
} }
else { else {
v = slice::append(rv, v); v = vec::append(rv, v);
} }
i += 1; i += 1;
} }
@ -118,7 +119,7 @@ fn vec_append() {
fn vec_push_all() { fn vec_push_all() {
let mut r = rand::task_rng(); let mut r = rand::task_rng();
let mut v = ~[]; let mut v = Vec::new();
for i in range(0u, 1500) { for i in range(0u, 1500) {
let mut rv = slice::from_elem(r.gen_range(0u, i + 1), i); let mut rv = slice::from_elem(r.gen_range(0u, i + 1), i);
if r.gen() { if r.gen() {
@ -132,7 +133,7 @@ fn vec_push_all() {
} }
fn is_utf8_ascii() { fn is_utf8_ascii() {
let mut v : ~[u8] = ~[]; let mut v : Vec<u8> = Vec::new();
for _ in range(0u, 20000) { for _ in range(0u, 20000) {
v.push('b' as u8); v.push('b' as u8);
if !str::is_utf8(v) { if !str::is_utf8(v) {
@ -143,7 +144,7 @@ fn is_utf8_ascii() {
fn is_utf8_multibyte() { fn is_utf8_multibyte() {
let s = "b¢€𤭢"; let s = "b¢€𤭢";
let mut v : ~[u8]= ~[]; let mut v : Vec<u8> = Vec::new();
for _ in range(0u, 5000) { for _ in range(0u, 5000) {
v.push_all(s.as_bytes()); v.push_all(s.as_bytes());
if !str::is_utf8(v) { if !str::is_utf8(v) {

View File

@ -14,9 +14,9 @@ use std::uint;
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"10000000"] vec!(~"", ~"10000000")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"100000"] vec!(~"", ~"100000")
} else { } else {
args args
}; };

View File

@ -59,7 +59,7 @@ fn run(args: &[~str]) {
let workers = from_str::<uint>(args[2]).unwrap(); let workers = from_str::<uint>(args[2]).unwrap();
let num_bytes = 100; let num_bytes = 100;
let start = time::precise_time_s(); let start = time::precise_time_s();
let mut worker_results = ~[]; let mut worker_results = Vec::new();
for _ in range(0u, workers) { for _ in range(0u, workers) {
let to_child = to_child.clone(); let to_child = to_child.clone();
let mut builder = task::task(); let mut builder = task::task();
@ -96,9 +96,9 @@ fn run(args: &[~str]) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"10000"] vec!(~"", ~"1000000", ~"10000")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10000", ~"4"] vec!(~"", ~"10000", ~"4")
} else { } else {
args.clone() args.clone()
}; };

View File

@ -53,7 +53,7 @@ fn run(args: &[~str]) {
let workers = from_str::<uint>(args[2]).unwrap(); let workers = from_str::<uint>(args[2]).unwrap();
let num_bytes = 100; let num_bytes = 100;
let start = time::precise_time_s(); let start = time::precise_time_s();
let mut worker_results = ~[]; let mut worker_results = Vec::new();
let from_parent = if workers == 1 { let from_parent = if workers == 1 {
let (to_child, from_parent) = channel(); let (to_child, from_parent) = channel();
let mut builder = task::task(); let mut builder = task::task();
@ -106,9 +106,9 @@ fn run(args: &[~str]) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"8"] vec!(~"", ~"1000000", ~"8")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10000", ~"4"] vec!(~"", ~"10000", ~"4")
} else { } else {
args.clone() args.clone()
}; };

View File

@ -25,7 +25,7 @@ use std::os;
use std::uint; use std::uint;
// A poor man's pipe. // A poor man's pipe.
type pipe = MutexArc<~[uint]>; type pipe = MutexArc<Vec<uint> >;
fn send(p: &pipe, msg: uint) { fn send(p: &pipe, msg: uint) {
unsafe { unsafe {
@ -47,7 +47,7 @@ fn recv(p: &pipe) -> uint {
} }
fn init() -> (pipe,pipe) { fn init() -> (pipe,pipe) {
let m = MutexArc::new(~[]); let m = MutexArc::new(Vec::new());
((&m).clone(), m) ((&m).clone(), m)
} }
@ -71,9 +71,9 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"] vec!(~"", ~"100", ~"10000")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10", ~"100"] vec!(~"", ~"10", ~"100")
} else { } else {
args.clone() args.clone()
}; };
@ -86,7 +86,7 @@ fn main() {
let start = time::precise_time_s(); let start = time::precise_time_s();
// create the ring // create the ring
let mut futures = ~[]; let mut futures = Vec::new();
for i in range(1u, num_tasks) { for i in range(1u, num_tasks) {
//println!("spawning %?", i); //println!("spawning %?", i);

View File

@ -24,7 +24,7 @@ use std::os;
use std::uint; use std::uint;
// A poor man's pipe. // A poor man's pipe.
type pipe = RWArc<~[uint]>; type pipe = RWArc<Vec<uint> >;
fn send(p: &pipe, msg: uint) { fn send(p: &pipe, msg: uint) {
p.write_cond(|state, cond| { p.write_cond(|state, cond| {
@ -42,7 +42,7 @@ fn recv(p: &pipe) -> uint {
} }
fn init() -> (pipe,pipe) { fn init() -> (pipe,pipe) {
let x = RWArc::new(~[]); let x = RWArc::new(Vec::new());
((&x).clone(), x) ((&x).clone(), x)
} }
@ -66,9 +66,9 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"] vec!(~"", ~"100", ~"10000")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10", ~"100"] vec!(~"", ~"10", ~"100")
} else { } else {
args.clone() args.clone()
}; };
@ -81,7 +81,7 @@ fn main() {
let start = time::precise_time_s(); let start = time::precise_time_s();
// create the ring // create the ring
let mut futures = ~[]; let mut futures = Vec::new();
for i in range(1u, num_tasks) { for i in range(1u, num_tasks) {
//println!("spawning %?", i); //println!("spawning %?", i);

View File

@ -25,9 +25,9 @@ fn ack(m: int, n: int) -> int {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"12"] vec!(~"", ~"12")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"8"] vec!(~"", ~"8")
} else { } else {
args args
}; };

View File

@ -39,7 +39,7 @@ fn show_color(cc: color) -> ~str {
} }
} }
fn show_color_list(set: ~[color]) -> ~str { fn show_color_list(set: vec!(color)) -> ~str {
let mut out = ~""; let mut out = ~"";
for col in set.iter() { for col in set.iter() {
out.push_char(' '); out.push_char(' ');
@ -132,7 +132,7 @@ fn creature(
} }
} }
fn rendezvous(nn: uint, set: ~[color]) { fn rendezvous(nn: uint, set: vec!(color)) {
// these ports will allow us to hear from the creatures // these ports will allow us to hear from the creatures
let (to_rendezvous, from_creatures) = channel::<CreatureInfo>(); let (to_rendezvous, from_creatures) = channel::<CreatureInfo>();
@ -141,7 +141,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
// these channels will be passed to the creatures so they can talk to us // 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 // these channels will allow us to talk to each creature by 'name'/index
let to_creature: ~[Sender<Option<CreatureInfo>>] = let to_creature: Vec<Sender<Option<CreatureInfo>>> =
set.iter().enumerate().map(|(ii, col)| { set.iter().enumerate().map(|(ii, col)| {
// create each creature as a listener with a port, and // create each creature as a listener with a port, and
// give us a channel to talk to each // give us a channel to talk to each
@ -179,7 +179,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
} }
// save each creature's meeting stats // save each creature's meeting stats
let mut report = ~[]; let mut report = Vec::new();
for _to_one in to_creature.iter() { for _to_one in to_creature.iter() {
report.push(from_creatures_log.recv()); report.push(from_creatures_log.recv());
} }
@ -199,9 +199,9 @@ fn rendezvous(nn: uint, set: ~[color]) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"200000"] vec!(~"", ~"200000")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"600"] vec!(~"", ~"600")
} else { } else {
args args
}; };
@ -211,9 +211,9 @@ fn main() {
print_complements(); print_complements();
println!(""); println!("");
rendezvous(nn, ~[Blue, Red, Yellow]); rendezvous(nn, vec!(Blue, Red, Yellow));
println!(""); println!("");
rendezvous(nn, rendezvous(nn,
~[Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue]); vec!(Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue));
} }

View File

@ -59,8 +59,8 @@ static HOMO_SAPIENS: [AminoAcid, ..4] = [
]; ];
// FIXME: Use map(). // FIXME: Use map().
fn sum_and_scale(a: &'static [AminoAcid]) -> ~[AminoAcid] { fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
let mut result = ~[]; let mut result = Vec::new();
let mut p = 0f32; let mut p = 0f32;
for a_i in a.iter() { for a_i in a.iter() {
let mut a_i = *a_i; let mut a_i = *a_i;

View File

@ -36,8 +36,7 @@ impl MyRandom {
struct AAGen<'a> { struct AAGen<'a> {
rng: &'a mut MyRandom, rng: &'a mut MyRandom,
data: ~[(u32, u8)] data: Vec<(u32, u8)> }
}
impl<'a> AAGen<'a> { impl<'a> AAGen<'a> {
fn new<'b>(rng: &'b mut MyRandom, aa: &[(char, f32)]) -> AAGen<'b> { fn new<'b>(rng: &'b mut MyRandom, aa: &[(char, f32)]) -> AAGen<'b> {
let mut cum = 0.; let mut cum = 0.;

View File

@ -21,9 +21,9 @@ fn fib(n: int) -> int {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"40"] vec!(~"", ~"40")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"30"] vec!(~"", ~"30")
} else { } else {
args args
}; };

View File

@ -42,19 +42,19 @@ fn f64_cmp(x: f64, y: f64) -> Ordering {
} }
// given a map, print a sorted version of it // given a map, print a sorted version of it
fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> ~str {
fn pct(xx: uint, yy: uint) -> f64 { fn pct(xx: uint, yy: uint) -> f64 {
return (xx as f64) * 100.0 / (yy as f64); return (xx as f64) * 100.0 / (yy as f64);
} }
// sort by key, then by value // sort by key, then by value
fn sortKV(mut orig: ~[(~[u8],f64)]) -> ~[(~[u8],f64)] { fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
orig.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b)); orig.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b));
orig.sort_by(|&(_, a), &(_, b)| f64_cmp(b, a)); orig.sort_by(|&(_, a), &(_, b)| f64_cmp(b, a));
orig orig
} }
let mut pairs = ~[]; let mut pairs = Vec::new();
// map -> [(k,%)] // map -> [(k,%)]
for (key, &val) in mm.iter() { for (key, &val) in mm.iter() {
@ -76,7 +76,7 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
} }
// given a map, search for the frequency of a pattern // given a map, search for the frequency of a pattern
fn find(mm: &HashMap<~[u8], uint>, key: ~str) -> uint { fn find(mm: &HashMap<Vec<u8> , uint>, key: ~str) -> uint {
let key = key.into_ascii().to_lower().into_str(); let key = key.into_ascii().to_lower().into_str();
match mm.find_equiv(&key.as_bytes()) { match mm.find_equiv(&key.as_bytes()) {
option::None => { return 0u; } option::None => { return 0u; }
@ -85,7 +85,7 @@ fn find(mm: &HashMap<~[u8], uint>, key: ~str) -> uint {
} }
// given a map, increment the counter for a key // given a map, increment the counter for a key
fn update_freq(mm: &mut HashMap<~[u8], uint>, key: &[u8]) { fn update_freq(mm: &mut HashMap<Vec<u8> , uint>, key: &[u8]) {
let key = key.to_owned(); let key = key.to_owned();
let newval = match mm.pop(&key) { let newval = match mm.pop(&key) {
Some(v) => v + 1, Some(v) => v + 1,
@ -97,7 +97,7 @@ fn update_freq(mm: &mut HashMap<~[u8], uint>, key: &[u8]) {
// given a ~[u8], for each window call a function // given a ~[u8], for each window call a function
// i.e., for "hello" and windows of size four, // i.e., for "hello" and windows of size four,
// run it("hell") and it("ello"), then return "llo" // run it("hell") and it("ello"), then return "llo"
fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> ~[u8] { fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec<u8> {
let mut ii = 0u; let mut ii = 0u;
let len = bb.len(); let len = bb.len();
@ -110,18 +110,18 @@ fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> ~[u8] {
} }
fn make_sequence_processor(sz: uint, fn make_sequence_processor(sz: uint,
from_parent: &Receiver<~[u8]>, from_parent: &Receiver<Vec<u8>>,
to_parent: &Sender<~str>) { to_parent: &Sender<~str>) {
let mut freqs: HashMap<~[u8], uint> = HashMap::new(); let mut freqs: HashMap<Vec<u8>, uint> = HashMap::new();
let mut carry: ~[u8] = ~[]; let mut carry = Vec::new();
let mut total: uint = 0u; let mut total: uint = 0u;
let mut line: ~[u8]; let mut line: Vec<u8> ;
loop { loop {
line = from_parent.recv(); line = from_parent.recv();
if line == ~[] { break; } if line == Vec::new() { break; }
carry = windows_with_carry(carry + line, sz, |window| { carry = windows_with_carry(carry + line, sz, |window| {
update_freq(&mut freqs, window); update_freq(&mut freqs, window);
@ -156,9 +156,9 @@ fn main() {
let mut rdr = BufferedReader::new(rdr); let mut rdr = BufferedReader::new(rdr);
// initialize each sequence sorter // initialize each sequence sorter
let sizes = ~[1u,2,3,4,6,12,18]; let sizes = vec!(1u,2,3,4,6,12,18);
let mut streams = slice::from_fn(sizes.len(), |_| Some(channel::<~str>())); let mut streams = Vec::from_fn(sizes.len(), |_| Some(channel::<~str>()));
let mut from_child = ~[]; let mut from_child = Vec::new();
let to_child = sizes.iter().zip(streams.mut_iter()).map(|(sz, stream_ref)| { let to_child = sizes.iter().zip(streams.mut_iter()).map(|(sz, stream_ref)| {
let sz = *sz; let sz = *sz;
let stream = replace(stream_ref, None); let stream = replace(stream_ref, None);
@ -173,7 +173,7 @@ fn main() {
}); });
to_child to_child
}).collect::<~[Sender<~[u8]>]>(); }).collect::<Vec<Sender<Vec<u8> >> >();
// latch stores true after we've started // latch stores true after we've started
@ -215,7 +215,7 @@ fn main() {
// finish... // finish...
for (ii, _sz) in sizes.iter().enumerate() { for (ii, _sz) in sizes.iter().enumerate() {
to_child[ii].send(~[]); to_child[ii].send(Vec::new());
} }
// now fetch and print result messages // now fetch and print result messages

View File

@ -50,7 +50,7 @@ impl Code {
// FIXME: Inefficient. // FIXME: Inefficient.
fn unpack(&self, frame: i32) -> ~str { fn unpack(&self, frame: i32) -> ~str {
let mut key = self.hash(); let mut key = self.hash();
let mut result = ~[]; let mut result = Vec::new();
for _ in range(0, frame) { for _ in range(0, frame) {
result.push(unpack_symbol((key as u8) & 3)); result.push(unpack_symbol((key as u8) & 3));
key >>= 2; key >>= 2;
@ -92,8 +92,7 @@ struct Entry {
struct Table { struct Table {
count: i32, count: i32,
items: ~[Option<~Entry>] items: Vec<Option<~Entry>> }
}
struct Items<'a> { struct Items<'a> {
cur: Option<&'a Entry>, cur: Option<&'a Entry>,
@ -237,7 +236,7 @@ fn generate_frequencies(frequencies: &mut Table,
} }
fn print_frequencies(frequencies: &Table, frame: i32) { fn print_frequencies(frequencies: &Table, frame: i32) {
let mut vector = ~[]; let mut vector = Vec::new();
for entry in frequencies.iter() { for entry in frequencies.iter() {
vector.push((entry.code, entry.count)); vector.push((entry.code, entry.count));
} }

View File

@ -63,7 +63,7 @@ impl<'a, T> Iterator<&'a T> for ListIterator<'a, T> {
// corresponding mirrored piece), with, as minimum coordinates, (0, // corresponding mirrored piece), with, as minimum coordinates, (0,
// 0). If all is false, only generate half of the possibilities (used // 0). If all is false, only generate half of the possibilities (used
// to break the symetry of the board). // to break the symetry of the board).
fn transform(piece: ~[(int, int)], all: bool) -> ~[~[(int, int)]] { fn transform(piece: Vec<(int, int)> , all: bool) -> vec!(Vec<(int, int)> ) {
let mut res = let mut res =
// rotations // rotations
iterate(piece, |rot| rot.iter().map(|&(y, x)| (x + y, -y)).collect()) iterate(piece, |rot| rot.iter().map(|&(y, x)| (x + y, -y)).collect())
@ -107,25 +107,25 @@ fn mask(dy: int, dx: int, id: uint, p: &[(int, int)]) -> Option<u64> {
// Makes every possible masks. masks[id][i] correspond to every // Makes every possible masks. masks[id][i] correspond to every
// possible masks for piece with identifier id with minimum coordinate // possible masks for piece with identifier id with minimum coordinate
// (i/5, i%5). // (i/5, i%5).
fn make_masks() -> ~[~[~[u64]]] { fn make_masks() -> Vec<Vec<Vec<u64> > > {
let pieces = ~[ let pieces = vec!(
~[(0,0),(0,1),(0,2),(0,3),(1,3)], vec!((0,0),(0,1),(0,2),(0,3),(1,3)),
~[(0,0),(0,2),(0,3),(1,0),(1,1)], vec!((0,0),(0,2),(0,3),(1,0),(1,1)),
~[(0,0),(0,1),(0,2),(1,2),(2,1)], vec!((0,0),(0,1),(0,2),(1,2),(2,1)),
~[(0,0),(0,1),(0,2),(1,1),(2,1)], vec!((0,0),(0,1),(0,2),(1,1),(2,1)),
~[(0,0),(0,2),(1,0),(1,1),(2,1)], vec!((0,0),(0,2),(1,0),(1,1),(2,1)),
~[(0,0),(0,1),(0,2),(1,1),(1,2)], vec!((0,0),(0,1),(0,2),(1,1),(1,2)),
~[(0,0),(0,1),(1,1),(1,2),(2,1)], vec!((0,0),(0,1),(1,1),(1,2),(2,1)),
~[(0,0),(0,1),(0,2),(1,0),(1,2)], vec!((0,0),(0,1),(0,2),(1,0),(1,2)),
~[(0,0),(0,1),(0,2),(1,2),(1,3)], vec!((0,0),(0,1),(0,2),(1,2),(1,3)),
~[(0,0),(0,1),(0,2),(0,3),(1,2)]]; vec!((0,0),(0,1),(0,2),(0,3),(1,2)));
let mut res = ~[]; let mut res = Vec::new();
for (id, p) in pieces.move_iter().enumerate() { for (id, p) in pieces.move_iter().enumerate() {
// To break the central symetry of the problem, every // To break the central symetry of the problem, every
// transformation must be taken except for one piece (piece 3 // transformation must be taken except for one piece (piece 3
// here). // here).
let trans = transform(p, id != 3); let trans = transform(p, id != 3);
let mut cur_piece = ~[]; let mut cur_piece = Vec::new();
for dy in range(0, 10) { for dy in range(0, 10) {
for dx in range(0, 5) { for dx in range(0, 5) {
let masks = let masks =
@ -142,7 +142,7 @@ fn make_masks() -> ~[~[~[u64]]] {
// Check if all coordinates can be covered by an unused piece and that // Check if all coordinates can be covered by an unused piece and that
// all unused piece can be placed on the board. // all unused piece can be placed on the board.
fn is_board_unfeasible(board: u64, masks: &[~[~[u64]]]) -> bool { fn is_board_unfeasible(board: u64, masks: &[Vec<Vec<u64> > ]) -> bool {
let mut coverable = board; let mut coverable = board;
for i in range(0, 50).filter(|&i| board & 1 << i == 0) { for i in range(0, 50).filter(|&i| board & 1 << i == 0) {
for (cur_id, pos_masks) in masks.iter().enumerate() { for (cur_id, pos_masks) in masks.iter().enumerate() {
@ -159,7 +159,7 @@ fn is_board_unfeasible(board: u64, masks: &[~[~[u64]]]) -> bool {
} }
// Filter the masks that we can prove to result to unfeasible board. // Filter the masks that we can prove to result to unfeasible board.
fn filter_masks(masks: &[~[~[u64]]]) -> ~[~[~[u64]]] { fn filter_masks(masks: &[Vec<Vec<u64> > ]) -> Vec<Vec<Vec<u64> > > {
masks.iter().map( masks.iter().map(
|p| p.iter().map( |p| p.iter().map(
|p| p.iter() |p| p.iter()
@ -180,7 +180,7 @@ fn get_id(m: u64) -> u8 {
// Converts a list of mask to a ~str. // Converts a list of mask to a ~str.
fn to_utf8(raw_sol: &List<u64>) -> ~str { fn to_utf8(raw_sol: &List<u64>) -> ~str {
let mut sol: ~[u8] = std::slice::from_elem(50, '.' as u8); let mut sol: Vec<u8> = Vec::from_elem(50, '.' as u8);
for &m in raw_sol.iter() { for &m in raw_sol.iter() {
let id = get_id(m); let id = get_id(m);
for i in range(0, 50) { for i in range(0, 50) {
@ -237,7 +237,7 @@ fn handle_sol(raw_sol: &List<u64>, data: &mut Data) -> bool {
// Search for every solutions. Returns false if the search was // Search for every solutions. Returns false if the search was
// stopped before the end. // stopped before the end.
fn search( fn search(
masks: &[~[~[u64]]], masks: &[Vec<Vec<u64> > ],
board: u64, board: u64,
mut i: int, mut i: int,
cur: List<u64>, cur: List<u64>,

View File

@ -148,9 +148,9 @@ fn offset_momentum(bodies: &mut [Planet, ..N_BODIES]) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"1000"] vec!(~"", ~"1000")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"1000"] vec!(~"", ~"1000")
} else { } else {
args args
}; };

View File

@ -51,8 +51,8 @@ struct Config {
stress: bool stress: bool
} }
fn parse_opts(argv: ~[~str]) -> Config { fn parse_opts(argv: Vec<~str> ) -> Config {
let opts = ~[getopts::optflag("", "stress", "")]; let opts = vec!(getopts::optflag("", "stress", ""));
let opt_args = argv.slice(1, argv.len()); let opt_args = argv.slice(1, argv.len());
@ -75,7 +75,7 @@ fn stress_task(id: int) {
} }
fn stress(num_tasks: int) { fn stress(num_tasks: int) {
let mut results = ~[]; let mut results = Vec::new();
for i in range(0, num_tasks) { for i in range(0, num_tasks) {
let mut builder = task::task(); let mut builder = task::task();
results.push(builder.future_result()); results.push(builder.future_result());
@ -91,9 +91,9 @@ fn stress(num_tasks: int) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"20"] vec!(~"", ~"20")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"8"] vec!(~"", ~"8")
} else { } else {
args args
}; };

View File

@ -29,8 +29,10 @@ fn dot(v: &[f64], u: &[f64]) -> f64 {
sum sum
} }
fn mult(v: RWArc<~[f64]>, out: RWArc<~[f64]>, f: fn(&~[f64], uint) -> f64) { fn mult(v: RWArc<Vec<f64>>,
// We lanch in different tasks the work to be done. To finish out: RWArc<Vec<f64>>,
f: fn(&Vec<f64>, uint) -> f64) {
// We launch in different tasks the work to be done. To finish
// this fuction, we need to wait for the completion of every // this fuction, we need to wait for the completion of every
// tasks. To do that, we give to each tasks a wait_chan that we // tasks. To do that, we give to each tasks a wait_chan that we
// drop at the end of the work. At the end of this function, we // drop at the end of the work. At the end of this function, we
@ -58,7 +60,7 @@ fn mult(v: RWArc<~[f64]>, out: RWArc<~[f64]>, f: fn(&~[f64], uint) -> f64) {
for () in rx.iter() {} for () in rx.iter() {}
} }
fn mult_Av_impl(v: &~[f64], i: uint) -> f64 { fn mult_Av_impl(v: &Vec<f64> , i: uint) -> f64 {
let mut sum = 0.; let mut sum = 0.;
for (j, &v_j) in v.iter().enumerate() { for (j, &v_j) in v.iter().enumerate() {
sum += v_j / A(i, j); sum += v_j / A(i, j);
@ -66,11 +68,11 @@ fn mult_Av_impl(v: &~[f64], i: uint) -> f64 {
sum sum
} }
fn mult_Av(v: RWArc<~[f64]>, out: RWArc<~[f64]>) { fn mult_Av(v: RWArc<Vec<f64> >, out: RWArc<Vec<f64> >) {
mult(v, out, mult_Av_impl); mult(v, out, mult_Av_impl);
} }
fn mult_Atv_impl(v: &~[f64], i: uint) -> f64 { fn mult_Atv_impl(v: &Vec<f64> , i: uint) -> f64 {
let mut sum = 0.; let mut sum = 0.;
for (j, &v_j) in v.iter().enumerate() { for (j, &v_j) in v.iter().enumerate() {
sum += v_j / A(j, i); sum += v_j / A(j, i);
@ -78,11 +80,11 @@ fn mult_Atv_impl(v: &~[f64], i: uint) -> f64 {
sum sum
} }
fn mult_Atv(v: RWArc<~[f64]>, out: RWArc<~[f64]>) { fn mult_Atv(v: RWArc<Vec<f64> >, out: RWArc<Vec<f64> >) {
mult(v, out, mult_Atv_impl); mult(v, out, mult_Atv_impl);
} }
fn mult_AtAv(v: RWArc<~[f64]>, out: RWArc<~[f64]>, tmp: RWArc<~[f64]>) { fn mult_AtAv(v: RWArc<Vec<f64> >, out: RWArc<Vec<f64> >, tmp: RWArc<Vec<f64> >) {
mult_Av(v, tmp.clone()); mult_Av(v, tmp.clone());
mult_Atv(tmp, out); mult_Atv(tmp, out);
} }

View File

@ -55,7 +55,7 @@ fn main() {
use std::from_str::FromStr; use std::from_str::FromStr;
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"2000000", ~"503"] vec!(~"", ~"2000000", ~"503")
} }
else { else {
os::args() os::args()

View File

@ -32,9 +32,9 @@ fn check_sequential(min: uint, max: uint, map: &SmallIntMap<uint>) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"100000", ~"100"] vec!(~"", ~"100000", ~"100")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10000", ~"50"] vec!(~"", ~"10000", ~"50")
} else { } else {
args args
}; };

View File

@ -36,7 +36,7 @@ use std::slice;
// //
// internal type of sudoku grids // internal type of sudoku grids
type grid = ~[~[u8]]; type grid = Vec<Vec<u8> > ;
struct Sudoku { struct Sudoku {
grid: grid grid: grid
@ -68,9 +68,9 @@ impl Sudoku {
pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku { pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku {
assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */ assert!(reader.read_line().unwrap() == ~"9,9"); /* assert first line is exactly "9,9" */
let mut g = slice::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] }); let mut g = slice::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) });
for line in reader.lines() { for line in reader.lines() {
let comps: ~[&str] = line.unwrap().trim().split(',').collect(); let comps: Vec<&str> = line.trim().split(',').collect();
if comps.len() == 3u { if comps.len() == 3u {
let row = from_str::<uint>(comps[0]).unwrap() as u8; let row = from_str::<uint>(comps[0]).unwrap() as u8;
@ -96,7 +96,7 @@ impl Sudoku {
// solve sudoku grid // solve sudoku grid
pub fn solve(&mut self) { pub fn solve(&mut self) {
let mut work: ~[(u8, u8)] = ~[]; /* queue of uncolored fields */ let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */
for row in range(0u8, 9u8) { for row in range(0u8, 9u8) {
for col in range(0u8, 9u8) { for col in range(0u8, 9u8) {
let color = self.grid[row][col]; let color = self.grid[row][col];

View File

@ -50,7 +50,7 @@ struct State {
managed: @nillist, managed: @nillist,
unique: ~nillist, unique: ~nillist,
tuple: (@nillist, ~nillist), tuple: (@nillist, ~nillist),
vec: ~[@nillist], vec: vec!(@nillist),
res: r res: r
} }
@ -82,7 +82,7 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
managed: @Nil, managed: @Nil,
unique: ~Nil, unique: ~Nil,
tuple: (@Nil, ~Nil), tuple: (@Nil, ~Nil),
vec: ~[@Nil], vec: vec!(@Nil),
res: r(@Nil) res: r(@Nil)
} }
} }

View File

@ -41,9 +41,9 @@ fn child_generation(gens_left: uint, tx: comm::Sender<()>) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"100000"] vec!(~"", ~"100000")
} else if args.len() <= 1 { } else if args.len() <= 1 {
~[~"", ~"100"] vec!(~"", ~"100")
} else { } else {
args.clone() args.clone()
}; };

View File

@ -19,7 +19,7 @@ use std::slice;
fn calc(children: uint, parent_wait_chan: &Sender<Sender<Sender<int>>>) { fn calc(children: uint, parent_wait_chan: &Sender<Sender<Sender<int>>>) {
let wait_ports: ~[Receiver<Sender<Sender<int>>>] = slice::from_fn(children, |_| { let wait_ports: Vec<Reciever<Sender<Sender<int>>>> = vec::from_fn(children, |_| {
let (wait_port, wait_chan) = stream::<Sender<Sender<int>>>(); let (wait_port, wait_chan) = stream::<Sender<Sender<int>>>();
task::spawn(proc() { task::spawn(proc() {
calc(children / 2, &wait_chan); calc(children / 2, &wait_chan);
@ -27,14 +27,14 @@ fn calc(children: uint, parent_wait_chan: &Sender<Sender<Sender<int>>>) {
wait_port wait_port
}); });
let child_start_chans: ~[Sender<Sender<int>>] = let child_start_chans: Vec<Sender<Sender<int>>> =
wait_ports.move_iter().map(|port| port.recv()).collect(); wait_ports.move_iter().map(|port| port.recv()).collect();
let (start_port, start_chan) = stream::<Sender<int>>(); let (start_port, start_chan) = stream::<Sender<int>>();
parent_wait_chan.send(start_chan); parent_wait_chan.send(start_chan);
let parent_result_chan: Sender<int> = start_port.recv(); let parent_result_chan: Sender<int> = start_port.recv();
let child_sum_ports: ~[Receiver<int>] = let child_sum_ports: Vec<Reciever<int>> =
child_start_chans.move_iter().map(|child_start_chan| { child_start_chans.move_iter().map(|child_start_chan| {
let (child_sum_port, child_sum_chan) = stream::<int>(); let (child_sum_port, child_sum_chan) = stream::<int>();
child_start_chan.send(child_sum_chan); child_start_chan.send(child_sum_chan);
@ -49,9 +49,9 @@ fn calc(children: uint, parent_wait_chan: &Sender<Sender<Sender<int>>>) {
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"30"] vec!(~"", ~"30")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10"] vec!(~"", ~"10")
} else { } else {
args args
}; };

View File

@ -25,9 +25,9 @@ fn g() { }
fn main() { fn main() {
let args = os::args(); let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() { let args = if os::getenv("RUST_BENCH").is_some() {
~[~"", ~"400"] vec!(~"", ~"400")
} else if args.len() <= 1u { } else if args.len() <= 1u {
~[~"", ~"10"] vec!(~"", ~"10")
} else { } else {
args args
}; };

View File

@ -9,9 +9,9 @@
// except according to those terms. // except according to those terms.
struct sty(~[int]); struct sty(Vec<int> );
fn unpack(_unpack: |v: &sty| -> ~[int]) {} fn unpack(_unpack: |v: &sty| -> Vec<int> ) {}
fn main() { fn main() {
let _foo = unpack(|s| { let _foo = unpack(|s| {

View File

@ -12,15 +12,15 @@ trait foo {
fn foo(&self) -> int; fn foo(&self) -> int;
} }
impl foo for ~[uint] { 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 `~[uint].foo::foo`
} }
impl foo for ~[int] { 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 `~[int].foo::foo`
} }
fn main() { fn main() {
let x = ~[]; let x = Vec::new();
x.foo(); //~ ERROR multiple applicable methods in scope x.foo(); //~ ERROR multiple applicable methods in scope
} }

View File

@ -17,7 +17,7 @@ fn main() {
// reference. That would allow creating a mutable pointer to a // reference. That would allow creating a mutable pointer to a
// temporary, which would be a source of confusion // temporary, which would be a source of confusion
let mut a = ~[0]; let mut a = vec!(0);
a.test_mut(); //~ ERROR does not implement any method in scope named `test_mut` a.test_mut(); //~ ERROR does not implement any method in scope named `test_mut`
} }

View File

@ -12,4 +12,4 @@
mod m1 {} mod m1 {}
fn main(args: ~[str]) { log(debug, m1::a); } fn main(args: vec!(str)) { log(debug, m1::a); }

View File

@ -14,4 +14,4 @@ mod m1 {
pub mod a {} pub mod a {}
} }
fn main(args: ~[str]) { log(debug, m1::a); } fn main(args: vec!(str)) { log(debug, m1::a); }

View File

@ -10,4 +10,4 @@
// error-pattern: unresolved name // error-pattern: unresolved name
fn main() { let foo = thing::len(~[]); } fn main() { let foo = thing::len(Vec::new()); }

View File

@ -14,7 +14,7 @@ struct Point {
} }
fn a() { fn a() {
let mut p = ~[1]; let mut p = vec!(1);
// Create an immutable pointer into p's contents: // Create an immutable pointer into p's contents:
let q: &int = &p[0]; let q: &int = &p[0];
@ -30,7 +30,7 @@ fn b() {
// here we alias the mutable vector into an imm slice and try to // here we alias the mutable vector into an imm slice and try to
// modify the original: // modify the original:
let mut p = ~[1]; let mut p = vec!(1);
borrow( borrow(
p, p,
@ -40,7 +40,7 @@ fn b() {
fn c() { fn c() {
// Legal because the scope of the borrow does not include the // Legal because the scope of the borrow does not include the
// modification: // modification:
let mut p = ~[1]; let mut p = vec!(1);
borrow(p, ||{}); borrow(p, ||{});
p[0] = 5; p[0] = 5;
} }

View File

@ -28,6 +28,6 @@ fn defer<'r>(x: &'r [&'r str]) -> defer<'r> {
} }
fn main() { fn main() {
let x = defer(~["Goodbye", "world!"]); //~ ERROR borrowed value does not live long enough let x = defer(vec!("Goodbye", "world!")); //~ ERROR borrowed value does not live long enough
x.x[0]; x.x[0];
} }

View File

@ -17,12 +17,12 @@ fn takes_imm_elt(_v: &int, f: ||) {
} }
fn has_mut_vec_and_does_not_try_to_change_it() { fn has_mut_vec_and_does_not_try_to_change_it() {
let mut v = ~[1, 2, 3]; let mut v = vec!(1, 2, 3);
takes_imm_elt(&v[0], || {}) takes_imm_elt(&v[0], || {})
} }
fn has_mut_vec_but_tries_to_change_it() { fn has_mut_vec_but_tries_to_change_it() {
let mut v = ~[1, 2, 3]; let mut v = vec!(1, 2, 3);
takes_imm_elt( takes_imm_elt(
&v[0], &v[0],
|| { //~ ERROR cannot borrow `v` as mutable || { //~ ERROR cannot borrow `v` as mutable

View File

@ -16,11 +16,11 @@ struct Foo {
} }
pub fn main() { pub fn main() {
let x = ~[ let x = vec!(
Foo { string: ~"foo" }, Foo { string: ~"foo" },
Foo { string: ~"bar" }, Foo { string: ~"bar" },
Foo { string: ~"baz" } Foo { string: ~"baz" }
]; );
let x: &[Foo] = x; let x: &[Foo] = x;
match x { match x {
[_, ..tail] => { [_, ..tail] => {

View File

@ -13,6 +13,6 @@ fn write(v: &mut [int]) {
} }
fn main() { fn main() {
let v = ~[1, 2, 3]; let v = vec!(1, 2, 3);
write(v); //~ ERROR cannot borrow write(v); //~ ERROR cannot borrow
} }

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn a() -> &[int] { fn a() -> &[int] {
let vec = ~[1, 2, 3, 4]; let vec = vec!(1, 2, 3, 4);
let vec: &[int] = vec; //~ ERROR does not live long enough let vec: &[int] = vec; //~ ERROR does not live long enough
let tail = match vec { let tail = match vec {
[_, ..tail] => tail, [_, ..tail] => tail,
@ -19,7 +19,7 @@ fn a() -> &[int] {
} }
fn b() -> &[int] { fn b() -> &[int] {
let vec = ~[1, 2, 3, 4]; let vec = vec!(1, 2, 3, 4);
let vec: &[int] = vec; //~ ERROR does not live long enough let vec: &[int] = vec; //~ ERROR does not live long enough
let init = match vec { let init = match vec {
[..init, _] => init, [..init, _] => init,
@ -29,7 +29,7 @@ fn b() -> &[int] {
} }
fn c() -> &[int] { fn c() -> &[int] {
let vec = ~[1, 2, 3, 4]; let vec = vec!(1, 2, 3, 4);
let vec: &[int] = vec; //~ ERROR does not live long enough let vec: &[int] = vec; //~ ERROR does not live long enough
let slice = match vec { let slice = match vec {
[_, ..slice, _] => slice, [_, ..slice, _] => slice,

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn a() { fn a() {
let mut v = ~[1, 2, 3]; let mut v = vec!(1, 2, 3);
let vb: &mut [int] = v; let vb: &mut [int] = v;
match vb { match vb {
[_a, ..tail] => { [_a, ..tail] => {

View File

@ -18,7 +18,7 @@ fn a() {
} }
fn b() { fn b() {
let mut vec = ~[~1, ~2, ~3]; let mut vec = vec!(~1, ~2, ~3);
let vec: &mut [~int] = vec; let vec: &mut [~int] = vec;
match vec { match vec {
[.._b] => { [.._b] => {
@ -28,7 +28,7 @@ fn b() {
} }
fn c() { fn c() {
let mut vec = ~[~1, ~2, ~3]; let mut vec = vec!(~1, ~2, ~3);
let vec: &mut [~int] = vec; let vec: &mut [~int] = vec;
match vec { match vec {
[_a, .._b] => { [_a, .._b] => {
@ -46,7 +46,7 @@ fn c() {
} }
fn d() { fn d() {
let mut vec = ~[~1, ~2, ~3]; let mut vec = vec!(~1, ~2, ~3);
let vec: &mut [~int] = vec; let vec: &mut [~int] = vec;
match vec { match vec {
[.._a, _b] => { [.._a, _b] => {
@ -58,7 +58,7 @@ fn d() {
} }
fn e() { fn e() {
let mut vec = ~[~1, ~2, ~3]; let mut vec = vec!(~1, ~2, ~3);
let vec: &mut [~int] = vec; let vec: &mut [~int] = vec;
match vec { match vec {
[_a, _b, _c] => {} //~ ERROR cannot move out [_a, _b, _c] => {} //~ ERROR cannot move out

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn a() -> &int { fn a() -> &int {
let vec = ~[1, 2, 3, 4]; let vec = vec!(1, 2, 3, 4);
let vec: &[int] = vec; //~ ERROR `vec[..]` does not live long enough let vec: &[int] = vec; //~ ERROR `vec[..]` does not live long enough
let tail = match vec { let tail = match vec {
[_a, ..tail] => &tail[0], [_a, ..tail] => &tail[0],

View File

@ -10,7 +10,7 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
type Foo = ~[u8]; type Foo = Vec<u8> ;
impl Drop for Foo { //~ ERROR the Drop trait may only be implemented impl Drop for Foo { //~ ERROR the Drop trait may only be implemented
//~^ ERROR cannot provide an extension implementation //~^ ERROR cannot provide an extension implementation

View File

@ -9,5 +9,5 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let v = ~[,]; //~ ERROR unexpected token: `,` let v = vec!(); //~ ERROR unexpected token: `,`
} }

View File

@ -10,10 +10,10 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
fn wants_uniq(x: ~[uint]) { } fn wants_uniq(x: Vec<uint> ) { }
fn wants_three(x: [uint, ..3]) { } fn wants_three(x: [uint, ..3]) { }
fn has_uniq(x: ~[uint]) { fn has_uniq(x: Vec<uint> ) {
wants_uniq(x); wants_uniq(x);
wants_three(x); //~ ERROR [] storage differs: expected `3` but found `~` wants_three(x); //~ ERROR [] storage differs: expected `3` but found `~`
} }

View File

@ -14,4 +14,4 @@ use zed::baz;
mod zed { mod zed {
pub fn bar() { println!("bar"); } pub fn bar() { println!("bar"); }
} }
fn main(args: ~[str]) { bar(); } fn main(args: vec!(str)) { bar(); }

View File

@ -15,4 +15,4 @@ mod baz {}
mod zed { mod zed {
pub fn bar() { println!("bar3"); } pub fn bar() { println!("bar3"); }
} }
fn main(args: ~[str]) { bar(); } fn main(args: vec!(str)) { bar(); }

View File

@ -11,4 +11,4 @@
// error-pattern: unresolved // error-pattern: unresolved
use main::bar; use main::bar;
fn main(args: ~[str]) { println!("foo"); } fn main() { println!("foo"); }

View File

@ -13,4 +13,4 @@
mod a { pub use b::foo; } mod a { pub use b::foo; }
mod b { pub use a::foo; } mod b { pub use a::foo; }
fn main(args: ~[str]) { println!("loop"); } fn main() { println!("loop"); }

View File

@ -10,6 +10,6 @@
// error-pattern: illegal recursive type // error-pattern: illegal recursive type
type x = ~[x]; type x = vec!(x);
fn main() { let b: x = ~[]; } fn main() { let b: x = Vec::new(); }

View File

@ -10,13 +10,13 @@
trait Serializable<'self, T> { //~ ERROR: no longer a special lifetime trait Serializable<'self, T> { //~ ERROR: no longer a special lifetime
fn serialize(val : &'self T) -> ~[u8]; fn serialize(val : &'self T) -> Vec<u8> ;
fn deserialize(repr : &[u8]) -> &'self T; fn deserialize(repr : &[u8]) -> &'self T;
} }
impl<'self> Serializable<str> for &'self str { impl<'self> Serializable<str> for &'self str {
fn serialize(val : &'self str) -> ~[u8] { fn serialize(val : &'self str) -> Vec<u8> {
~[1] vec!(1)
} }
fn deserialize(repr: &[u8]) -> &'self str { fn deserialize(repr: &[u8]) -> &'self str {
"hi" "hi"

View File

@ -10,6 +10,6 @@
#[feature(managed_boxes)]; #[feature(managed_boxes)];
static x: ~[int] = ~[123, 456]; //~ ERROR: static items are not allowed to have owned pointers static x: Vec<int> = vec!(123, 456); //~ ERROR: static items are not allowed to have owned pointers
fn main() {} fn main() {}

View File

@ -10,12 +10,12 @@
// error-pattern:expected `[` but found `~` // error-pattern:expected `[` but found `~`
mod blade_runner { mod blade_runner {
#~[doc( #vec!(doc(
brief = "Blade Runner is probably the best movie ever", brief = "Blade Runner is probably the best movie ever",
desc = "I like that in the world of Blade Runner it is always desc = "I like that in the world of Blade Runner it is always
raining, and that it's always night time. And Aliens raining, and that it's always night time. And Aliens
was also a really good movie. was also a really good movie.
Alien 3 was crap though." Alien 3 was crap though."
)] ))
} }

View File

@ -9,11 +9,11 @@
// except according to those terms. // except according to those terms.
trait vec_monad<A> { trait vec_monad<A> {
fn bind<B>(&self, f: |A| -> ~[B]); fn bind<B>(&self, f: |A| -> Vec<B> );
} }
impl<A> vec_monad<A> for ~[A] { impl<A> vec_monad<A> for Vec<A> {
fn bind<B>(&self, f: |A| -> ~[B]) { fn bind<B>(&self, f: |A| -> Vec<B> ) {
let mut r = fail!(); let mut r = fail!();
for elt in self.iter() { r = r + f(*elt); } for elt in self.iter() { r = r + f(*elt); }
//~^ ERROR the type of this value must be known //~^ ERROR the type of this value must be known

View File

@ -13,7 +13,7 @@
#[allow(dead_code)]; #[allow(dead_code)];
#[allow(deprecated_owned_vector)]; #[allow(deprecated_owned_vector)];
fn fail_len(v: ~[int]) -> uint { fn fail_len(v: Vec<int> ) -> uint {
let mut i = 3; let mut i = 3;
fail!(); fail!();
for x in v.iter() { i += 1u; } for x in v.iter() { i += 1u; }

View File

@ -10,4 +10,4 @@
// error-pattern: unresolved name `foobar`. // error-pattern: unresolved name `foobar`.
fn main(args: ~[str]) { println!("{:?}", foobar); } fn main() { println!("{:?}", foobar); }

View File

@ -38,8 +38,8 @@ fn main() {
{ {
let mut res = foo(x); let mut res = foo(x);
let mut v = ~[]; let mut v = Vec::new();
v = ~[(res)] + v; //~ failed to find an implementation of trait v = vec!((res)) + v; //~ failed to find an implementation of trait
assert_eq!(v.len(), 2); assert_eq!(v.len(), 2);
} }

View File

@ -9,15 +9,15 @@
// except according to those terms. // except according to those terms.
struct parser { struct parser {
tokens: ~[int], tokens: Vec<int> ,
} }
trait parse { trait parse {
fn parse(&self) -> ~[int]; fn parse(&self) -> Vec<int> ;
} }
impl parse for parser { impl parse for parser {
fn parse(&self) -> ~[int] { fn parse(&self) -> Vec<int> {
self.tokens //~ ERROR cannot move out of dereference of `&`-pointer self.tokens //~ ERROR cannot move out of dereference of `&`-pointer
} }
} }

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let needlesArr: ~[char] = ~['a', 'f']; let needlesArr: Vec<char> = vec!('a', 'f');
needlesArr.iter().fold(|x, y| { needlesArr.iter().fold(|x, y| {
}); });
//~^^ ERROR this function takes 2 parameters but 1 parameter was supplied //~^^ ERROR this function takes 2 parameters but 1 parameter was supplied

View File

@ -23,7 +23,7 @@ impl CrateId {
} }
pub fn remove_package_from_database() { pub fn remove_package_from_database() {
let mut lines_to_use: ~[&CrateId] = ~[]; //~ ERROR cannot infer an appropriate lifetime let mut lines_to_use: Vec<&CrateId> = Vec::new(); //~ ERROR cannot infer an appropriate lifetime
let push_id = |installed_id: &CrateId| { let push_id = |installed_id: &CrateId| {
lines_to_use.push(installed_id); lines_to_use.push(installed_id);
}; };

View File

@ -15,15 +15,15 @@
struct Data(~Option<Data>); struct Data(~Option<Data>);
fn generic<T>( _ : ~[(Data,T)] ) { fn generic<T>( _ : Vec<(Data,T)> ) {
//~^ ERROR reached the recursion limit during monomorphization //~^ ERROR reached the recursion limit during monomorphization
let rec : ~[(Data,(bool,T))] = ~[]; let rec : Vec<(Data,(bool,T))> = Vec::new();
generic( rec ); generic( rec );
} }
fn main () { fn main () {
// Use generic<T> at least once to trigger instantiation. // Use generic<T> at least once to trigger instantiation.
let input : ~[(Data,())] = ~[]; let input : Vec<(Data,())> = Vec::new();
generic(input); generic(input);
} }

View File

@ -27,7 +27,7 @@ fn test<'a,T,U:Freeze>(_: &'a int) {
// ~ pointers are ok // ~ pointers are ok
assert_freeze::<~int>(); assert_freeze::<~int>();
assert_freeze::<~str>(); assert_freeze::<~str>();
assert_freeze::<~[int]>(); assert_freeze::<Vec<int> >();
// but not if they own a bad thing // but not if they own a bad thing
assert_freeze::<~&'a mut int>(); //~ ERROR does not fulfill `Freeze` assert_freeze::<~&'a mut int>(); //~ ERROR does not fulfill `Freeze`

View File

@ -40,7 +40,7 @@ fn test<'a,T,U:Pod>(_: &'a int) {
// ~ pointers are not ok // ~ pointers are not ok
assert_pod::<~int>(); //~ ERROR does not fulfill `Pod` assert_pod::<~int>(); //~ ERROR does not fulfill `Pod`
assert_pod::<~str>(); //~ ERROR does not fulfill `Pod` assert_pod::<~str>(); //~ ERROR does not fulfill `Pod`
assert_pod::<~[int]>(); //~ ERROR does not fulfill `Pod` assert_pod::<Vec<int> >(); //~ ERROR does not fulfill `Pod`
assert_pod::<~&'a mut int>(); //~ ERROR does not fulfill `Pod` assert_pod::<~&'a mut int>(); //~ ERROR does not fulfill `Pod`
// borrowed object types are generally ok // borrowed object types are generally ok

View File

@ -30,7 +30,7 @@ fn test<'a,T,U:Send>(_: &'a int) {
// ~ pointers are ok // ~ pointers are ok
assert_send::<~int>(); assert_send::<~int>();
assert_send::<~str>(); assert_send::<~str>();
assert_send::<~[int]>(); assert_send::<Vec<int> >();
// but not if they own a bad thing // but not if they own a bad thing
assert_send::<~&'a int>(); //~ ERROR does not fulfill `Send` assert_send::<~&'a int>(); //~ ERROR does not fulfill `Send`

View File

@ -25,7 +25,7 @@ fn main() {
@2; //~ ERROR type uses managed @2; //~ ERROR type uses managed
~2; //~ ERROR type uses owned ~2; //~ ERROR type uses owned
~[1]; //~ ERROR type uses owned vec!(1); //~ ERROR type uses owned
//~^ ERROR type uses owned //~^ ERROR type uses owned
fn g(_: ~Clone) {} //~ ERROR type uses owned fn g(_: ~Clone) {} //~ ERROR type uses owned
~""; //~ ERROR type uses owned ~""; //~ ERROR type uses owned

View File

@ -21,7 +21,7 @@ fn main() {
let mut a = 3; //~ ERROR: variable does not need to be mutable let mut a = 3; //~ ERROR: variable does not need to be mutable
let mut a = 2; //~ ERROR: variable does not need to be mutable let mut a = 2; //~ ERROR: variable does not need to be mutable
let mut b = 3; //~ ERROR: variable does not need to be mutable let mut b = 3; //~ ERROR: variable does not need to be mutable
let mut a = ~[3]; //~ ERROR: variable does not need to be mutable let mut a = vec!(3); //~ ERROR: variable does not need to be mutable
let (mut a, b) = (1, 2); //~ ERROR: variable does not need to be mutable let (mut a, b) = (1, 2); //~ ERROR: variable does not need to be mutable
match 30 { match 30 {
@ -34,9 +34,9 @@ fn main() {
// positive cases // positive cases
let mut a = 2; let mut a = 2;
a = 3; a = 3;
let mut a = ~[]; let mut a = Vec::new();
a.push(3); a.push(3);
let mut a = ~[]; let mut a = Vec::new();
callback(|| { callback(|| {
a.push(3); a.push(3);
}); });
@ -63,5 +63,5 @@ fn callback(f: ||) {}
#[allow(unused_mut)] #[allow(unused_mut)]
fn foo(mut a: int) { fn foo(mut a: int) {
let mut a = 3; let mut a = 3;
let mut b = ~[2]; let mut b = vec!(2);
} }

View File

@ -50,7 +50,7 @@ fn good2() {
sure that when purity is inherited that the source of the unsafe-ness sure that when purity is inherited that the source of the unsafe-ness
is tracked correctly */ is tracked correctly */
unsafe { unsafe {
unsafe fn what() -> ~[~str] { fail!() } unsafe fn what() -> Vec<~str> { fail!() }
callback(|| { callback(|| {
what(); what();

View File

@ -11,7 +11,7 @@
use std::slice; use std::slice;
fn main() { fn main() {
let a: ~[int] = ~[]; let a: Vec<int> = Vec::new();
a.iter().advance(|_| -> bool { a.iter().advance(|_| -> bool {
//~^ ERROR mismatched types //~^ ERROR mismatched types
}); });

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let a = ~[]; let a = Vec::new();
match a { match a {
[1, ..tail, ..tail] => {}, //~ ERROR: unexpected token: `..` [1, ..tail, ..tail] => {}, //~ ERROR: unexpected token: `..`
_ => () _ => ()

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let x: ~[(int, int)] = ~[]; let x: Vec<(int, int)> = Vec::new();
let x: &[(int, int)] = x; let x: &[(int, int)] = x;
match x { match x {
[a, (2, 3), _] => (), [a, (2, 3), _] => (),
@ -17,7 +17,7 @@ fn main() {
_ => () _ => ()
} }
let x: ~[~str] = ~[~"foo", ~"bar", ~"baz"]; let x: Vec<~str> = vec!(~"foo", ~"bar", ~"baz");
let x: &[~str] = x; let x: &[~str] = x;
match x { match x {
[a, _, _, ..] => { println!("{}", a); } [a, _, _, ..] => { println!("{}", a); }
@ -25,7 +25,7 @@ fn main() {
_ => { } _ => { }
} }
let x: ~[char] = ~['a', 'b', 'c']; let x: Vec<char> = vec!('a', 'b', 'c');
let x: &[char] = x; let x: &[char] = x;
match x { match x {
['a', 'b', 'c', .._tail] => {} ['a', 'b', 'c', .._tail] => {}

View File

@ -22,7 +22,7 @@ fn f10() {
} }
fn f20() { fn f20() {
let x = ~[~"hi"]; let x = vec!(~"hi");
consume(x[0]); consume(x[0]);
touch(&x[0]); //~ ERROR use of partially moved value: `x` touch(&x[0]); //~ ERROR use of partially moved value: `x`
} }

View File

@ -30,7 +30,7 @@ fn f20() {
} }
fn f21() { fn f21() {
let x = ~[1, 2, 3]; let x = vec!(1, 2, 3);
let _y = (x[0], 3); let _y = (x[0], 3);
touch(&x); touch(&x);
} }
@ -78,24 +78,24 @@ fn f70() {
fn f80() { fn f80() {
let x = ~"hi"; let x = ~"hi";
let _y = ~[x]; let _y = vec!(x);
touch(&x); //~ ERROR use of moved value: `x` touch(&x); //~ ERROR use of moved value: `x`
} }
fn f100() { fn f100() {
let x = ~[~"hi"]; let x = vec!(~"hi");
let _y = x[0]; let _y = x[0];
touch(&x); //~ ERROR use of partially moved value: `x` touch(&x); //~ ERROR use of partially moved value: `x`
} }
fn f110() { fn f110() {
let x = ~[~"hi"]; let x = vec!(~"hi");
let _y = [x[0], ..1]; let _y = [x[0], ..1];
touch(&x); //~ ERROR use of partially moved value: `x` touch(&x); //~ ERROR use of partially moved value: `x`
} }
fn f120() { fn f120() {
let mut x = ~[~"hi", ~"ho"]; let mut x = vec!(~"hi", ~"ho");
x.swap(0, 1); x.swap(0, 1);
touch(&x[0]); touch(&x[0]);
touch(&x[1]); touch(&x[1]);

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
// error-pattern:attempt to use a type argument out of scope // error-pattern:attempt to use a type argument out of scope
fn hd<U>(v: ~[U]) -> U { fn hd<U>(v: Vec<U> ) -> U {
fn hd1(w: [U]) -> U { return w[0]; } fn hd1(w: [U]) -> U { return w[0]; }
return hd1(v); return hd1(v);

View File

@ -16,7 +16,7 @@ use sync::Arc;
use std::task; use std::task;
fn main() { fn main() {
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
let arc_v = Arc::new(v); let arc_v = Arc::new(v);
task::spawn(proc() { task::spawn(proc() {

View File

@ -14,7 +14,7 @@ use sync::Arc;
use std::task; use std::task;
fn main() { fn main() {
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let v = vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
let arc_v = Arc::new(v); let arc_v = Arc::new(v);
task::spawn(proc() { task::spawn(proc() {

View File

@ -11,6 +11,6 @@
enum State { ST_NULL, ST_WHITESPACE } enum State { ST_NULL, ST_WHITESPACE }
fn main() { fn main() {
~[ST_NULL, ..(ST_WHITESPACE as uint)]; vec!(ST_NULL, ..(ST_WHITESPACE as uint));
//~^ ERROR expected constant integer for repeat count but found variable //~^ ERROR expected constant integer for repeat count but found variable
} }

View File

@ -11,7 +11,7 @@
use std::libc; use std::libc;
fn main() { fn main() {
let x : *~[int] = &~[1,2,3]; let x : *Vec<int> = &vec!(1,2,3);
let y : *libc::c_void = x as *libc::c_void; let y : *libc::c_void = x as *libc::c_void;
unsafe { unsafe {
let _z = (*y).clone(); let _z = (*y).clone();

View File

@ -35,7 +35,7 @@ fn main() {
(_, a) => {} (_, a) => {}
(b, b) => {} (b, b) => {}
} }
let vec = ~[Some(42), None, Some(21)]; let vec = vec!(Some(42), None, Some(21));
let vec: &[Option<int>] = vec; let vec: &[Option<int>] = vec;
match vec { match vec {
//~^ ERROR non-exhaustive patterns: vectors of length 0 not covered //~^ ERROR non-exhaustive patterns: vectors of length 0 not covered
@ -43,13 +43,13 @@ fn main() {
[Some(..), Some(..), ..tail] => {} [Some(..), Some(..), ..tail] => {}
[None] => {} [None] => {}
} }
let vec = ~[1]; let vec = vec!(1);
let vec: &[int] = vec; let vec: &[int] = vec;
match vec { match vec {
[_, ..tail] => (), [_, ..tail] => (),
[] => () [] => ()
} }
let vec = ~[0.5]; let vec = vec!(0.5);
let vec: &[f32] = vec; let vec: &[f32] = vec;
match vec { //~ ERROR non-exhaustive patterns: vectors of length 4 not covered match vec { //~ ERROR non-exhaustive patterns: vectors of length 4 not covered
[0.1, 0.2, 0.3] => (), [0.1, 0.2, 0.3] => (),
@ -57,7 +57,7 @@ fn main() {
[0.1] => (), [0.1] => (),
[] => () [] => ()
} }
let vec = ~[Some(42), None, Some(21)]; let vec = vec!(Some(42), None, Some(21));
let vec: &[Option<int>] = vec; let vec: &[Option<int>] = vec;
match vec { match vec {
[Some(..), None, ..tail] => {} [Some(..), None, ..tail] => {}

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
enum bar { t1((), Option<~[int]>), t2, } enum bar { t1((), Option<Vec<int>>), t2, }
// n.b. my change changes this error message, but I think it's right -- tjc // n.b. my change changes this error message, but I think it's right -- tjc
fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } } fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } }

View File

@ -10,7 +10,7 @@
// error-pattern: mismatched types // error-pattern: mismatched types
enum bar { t1((), Option<~[int]>), t2, } enum bar { t1((), Option<Vec<int> >), t2, }
fn foo(t: bar) { fn foo(t: bar) {
match t { match t {

View File

@ -33,7 +33,7 @@ trait fake_ext_ctxt {
type fake_session = parse::parse_sess; type fake_session = parse::parse_sess;
impl fake_ext_ctxt for fake_session { impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::CrateConfig { ~[] } fn cfg() -> ast::CrateConfig { Vec::new() }
fn parse_sess() -> parse::parse_sess { self } fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span { fn call_site() -> span {
codemap::span { codemap::span {

View File

@ -30,7 +30,7 @@ trait fake_ext_ctxt {
type fake_session = parse::parse_sess; type fake_session = parse::parse_sess;
impl fake_ext_ctxt for fake_session { impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::CrateConfig { ~[] } fn cfg() -> ast::CrateConfig { Vec::new() }
fn parse_sess() -> parse::parse_sess { self } fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span { fn call_site() -> span {
codemap::span { codemap::span {

View File

@ -11,7 +11,7 @@
// The type of `y` ends up getting inferred to the type of the block. // The type of `y` ends up getting inferred to the type of the block.
fn broken() { fn broken() {
let mut x = 3; let mut x = 3;
let mut _y = ~[&mut x]; let mut _y = vec!(&mut x);
while x < 10 { while x < 10 {
let mut z = x; let mut z = x;
_y.push(&mut z); //~ ERROR `z` does not live long enough _y.push(&mut z); //~ ERROR `z` does not live long enough

View File

@ -12,5 +12,5 @@
fn main() { fn main() {
let n = 1; let n = 1;
let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable let a = vec!(0, ..n); //~ ERROR expected constant integer for repeat count but found variable
} }

View File

@ -11,7 +11,7 @@
fn main() { fn main() {
trait seq { } trait seq { }
impl<T> seq<T> for ~[T] { //~ ERROR wrong number of type arguments impl<T> seq<T> for Vec<T> { //~ ERROR wrong number of type arguments
/* ... */ /* ... */
} }
impl seq<bool> for u32 { impl seq<bool> for u32 {

View File

@ -13,7 +13,7 @@
#[no_implicit_prelude]; #[no_implicit_prelude];
fn last<T>(v: ~[&T]) -> std::option::Option<T> { fn last<T>(v: Vec<&T> ) -> std::option::Option<T> {
fail!(); fail!();
} }

View File

@ -14,10 +14,10 @@
// ~ to avoid infinite size. // ~ to avoid infinite size.
struct Uninstantiable { //~ ERROR cannot be instantiated without an instance of itself struct Uninstantiable { //~ ERROR cannot be instantiated without an instance of itself
p: ~[Uninstantiable, .. 1] p: vec!(Uninstantiable, .. 1)
} }
struct Instantiable { p: ~[Instantiable, .. 0] } struct Instantiable { p: vec!(Instantiable, .. 0) }
fn main() { fn main() {

View File

@ -25,14 +25,14 @@ impl Drop for r {
} }
} }
fn f<T>(_i: ~[T], _j: ~[T]) { fn f<T>(_i: Vec<T> , _j: Vec<T> ) {
} }
fn main() { fn main() {
let i1 = @Cell::new(0); let i1 = @Cell::new(0);
let i2 = @Cell::new(1); let i2 = @Cell::new(1);
let r1 = ~[~r { i: i1 }]; let r1 = vec!(~r { i: i1 });
let r2 = ~[~r { i: i2 }]; let r2 = vec!(~r { i: i2 });
f(r1.clone(), r2.clone()); f(r1.clone(), r2.clone());
//~^ ERROR failed to find an implementation of //~^ ERROR failed to find an implementation of
println!("{:?}", (r2, i1.get())); println!("{:?}", (r2, i1.get()));

View File

@ -23,8 +23,7 @@ impl fmt::Show for Number {
} }
struct List { struct List {
list: ~[~ToStr] list: Vec<~ToStr> }
}
impl List { impl List {
fn push(&mut self, n: ~ToStr) { fn push(&mut self, n: ~ToStr) {
@ -34,7 +33,7 @@ impl List {
fn main() { fn main() {
let n = ~Number { n: 42 }; let n = ~Number { n: 42 };
let mut l = ~List { list: ~[] }; let mut l = ~List { list: Vec::new() };
l.push(n); l.push(n);
let x = n.to_str(); let x = n.to_str();
//~^ ERROR: use of moved value: `n` //~^ ERROR: use of moved value: `n`

View File

@ -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.
// error-pattern:attempted access of field `some_field_name` on type `~[int]`
// issue #367
fn f() {
let v = ~[1i];
println!("{}", v.some_field_name); //type error
}
fn main() { }

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let mut xs = ~[1, 2, 3, 4]; let mut xs = vec!(1, 2, 3, 4);
for x in xs.mut_iter() { for x in xs.mut_iter() {
xs.push(1) //~ ERROR cannot borrow `xs` xs.push(1) //~ ERROR cannot borrow `xs`

View File

@ -22,8 +22,8 @@ impl Drop for r {
fn main() { fn main() {
// This can't make sense as it would copy the classes // This can't make sense as it would copy the classes
let i = ~[r(0)]; let i = vec!(r(0));
let j = ~[r(1)]; let j = vec!(r(1));
let k = i + j; let k = i + j;
println!("{}", j); println!("{}", j);
} }

View File

@ -9,5 +9,5 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let _foo = ~[]; //~ ERROR unconstrained type let _foo = Vec::new(); //~ ERROR unconstrained type
} }

View File

@ -9,6 +9,6 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let v: ~[int] = ~[1, 2, 3]; let v: Vec<int> = vec!(1, 2, 3);
v[1] = 4; //~ ERROR cannot assign v[1] = 4; //~ ERROR cannot assign
} }

View File

@ -26,7 +26,7 @@
fn main() { fn main() {
let unique: ~[i64] = ~[10, 11, 12, 13]; let unique: Vec<i64> = vec!(10, 11, 12, 13);
zzz(); zzz();
} }

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn main() { fn main() {
let args : ~[~str] = ::std::os::args(); let args : Vec<~str> = ::std::os::args();
::std::io::println(args[0]); ::std::io::println(args[0]);
} }

View File

@ -33,7 +33,7 @@
fn main() { fn main() {
let unique: ~[@i64] = ~[@10, @11, @12, @13]; let unique: Vec<@i64> = vec!(@10, @11, @12, @13);
zzz(); zzz();
} }

Some files were not shown because too many files have changed in this diff Show More