Merge remote-tracking branch 'original/incoming' into incoming

This commit is contained in:
Simon BD 2012-10-06 13:15:18 -05:00
commit 0e3bec0ced
222 changed files with 2009 additions and 1665 deletions

View file

@ -6,7 +6,7 @@ use comm::*;
fn foo<T: Send Copy>(x: T) -> Port<T> {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do task::spawn() |copy c, copy x| {
c.send(x);
}

View file

@ -142,7 +142,8 @@ fn empty_results() -> Results {
}
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let num_keys = {
if args.len() == 2 {
uint::from_str(args[1]).get()

View file

@ -8,7 +8,8 @@ use std::map::{Map, HashMap};
use io::{Reader, ReaderUtil};
fn main(++argv: ~[~str]) {
fn main() {
let argv = os::args();
#macro[
[#bench[id],
maybe_run_test(argv, #stringify(id), id)

View file

@ -1,4 +1,5 @@
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"10000000"]
} else if args.len() <= 1u {

View file

@ -20,7 +20,8 @@ fn collect_dvec(num: uint) -> ~[uint] {
return dvec::unwrap(move result);
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"50000000"]
} else if args.len() <= 1u {

View file

@ -384,7 +384,8 @@ fn validate(edges: ~[(node_id, node_id)],
true
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"15", ~"48"]
} else if args.len() <= 1u {

View file

@ -90,7 +90,8 @@ fn run(args: &[~str]) {
assert result == num_bytes * size;
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"10000"]
} else if args.len() <= 1u {

View file

@ -87,7 +87,8 @@ fn run(args: &[~str]) {
assert result == num_bytes * size;
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"8"]
} else if args.len() <= 1u {

View file

@ -56,7 +56,8 @@ fn thread_ring(i: uint,
};
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {

View file

@ -52,7 +52,8 @@ fn thread_ring(i: uint,
};
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {

View file

@ -56,7 +56,8 @@ fn thread_ring(i: uint,
};
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {

View file

@ -21,7 +21,8 @@ fn thread_ring(i: uint,
};
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100", ~"10000"]
} else if args.len() <= 1u {
@ -34,7 +35,7 @@ fn main(++args: ~[~str]) {
let msg_per_task = uint::from_str(args[2]).get();
let num_port = Port();
let mut num_chan = Chan(num_port);
let mut num_chan = Chan(&num_port);
let start = time::precise_time_s();
@ -43,12 +44,12 @@ fn main(++args: ~[~str]) {
for uint::range(1u, num_tasks) |i| {
let get_chan = Port();
let get_chan_chan = Chan(get_chan);
let get_chan_chan = Chan(&get_chan);
let new_future = do future::spawn
|copy num_chan, move get_chan_chan| {
let p = Port();
get_chan_chan.send(Chan(p));
get_chan_chan.send(Chan(&p));
thread_ring(i, msg_per_task, num_chan, p)
};
futures.push(new_future);

View file

@ -57,7 +57,8 @@ fn run(args: ~[~str]) {
io::stdout().write_str(fmt!("Throughput=%f per sec\n", thruput));
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"1000000", ~"10000"]
} else if args.len() <= 1u {

View file

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

View file

@ -25,7 +25,8 @@ fn bottom_up_tree(arena: &r/arena::Arena,
return arena.alloc(|| nil);
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"17"]
} else if args.len() <= 1u {

View file

@ -126,8 +126,8 @@ fn rendezvous(nn: uint, set: ~[color]) {
let from_creatures_log: comm::Port<~str> = comm::Port();
// these channels will be passed to the creatures so they can talk to us
let to_rendezvous = comm::Chan(from_creatures);
let to_rendezvous_log = comm::Chan(from_creatures_log);
let to_rendezvous = comm::Chan(&from_creatures);
let to_rendezvous_log = comm::Chan(&from_creatures_log);
// these channels will allow us to talk to each creature by 'name'/index
let to_creature: ~[comm::Chan<Option<creature_info>>] =
@ -178,7 +178,8 @@ fn rendezvous(nn: uint, set: ~[color]) {
io::println(show_number(creatures_met));
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"200000"]
} else if args.len() <= 1u {

View file

@ -56,7 +56,8 @@ fn fannkuch(n: int) -> int {
return flips;
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"10"]
} else if args.len() <= 1u {

View file

@ -70,7 +70,8 @@ fn make_repeat_fasta(wr: io::Writer, id: ~str, desc: ~str, s: ~str, n: int) unsa
fn acid(ch: char, prob: u32) -> aminoacids { return {ch: ch, prob: prob}; }
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
// alioth tests k-nucleotide with this data at 25,000,000
~[~"", ~"5000000"]

View file

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

View file

@ -128,7 +128,8 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::Port<~[u8]>,
}
// given a FASTA file on stdin, process sequence THREE
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
// FIXME: Using this compile-time env variable is a crummy way to
// get to this massive data set, but #include_bin chokes on it (#2598)

View file

@ -125,7 +125,8 @@ fn make_sequence_processor(sz: uint, from_parent: comm::Port<~[u8]>,
}
// given a FASTA file on stdin, process sequence THREE
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
// FIXME: Using this compile-time env variable is a crummy way to
// get to this massive data set, but #include_bin chokes on it (#2598)
@ -141,7 +142,7 @@ fn main(++args: ~[~str]) {
// initialize each sequence sorter
let sizes = ~[1u,2u,3u,4u,6u,12u,18u];
let from_child = vec::map (sizes, |_sz| comm::Port() );
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(from_child[ii]) );
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(&from_child[ii]) );
let to_child = vec::mapi(sizes, |ii, sz| {
let ii = ii;
let sz = *sz;

View file

@ -103,7 +103,7 @@ impl devnull: io::Writer {
fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
{
let p: comm::Port<line> = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
comm::send(writech, ch);
let cout: io::Writer = match path {
~"" => {
@ -151,7 +151,8 @@ fn writer(path: ~str, writech: comm::Chan<comm::Chan<line>>, size: uint)
}
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"4000", ~"10"]
} else {
@ -168,7 +169,7 @@ fn main(++args: ~[~str]) {
else { uint::from_str(args[1]).get() };
let writep = comm::Port();
let writech = comm::Chan(writep);
let writech = comm::Chan(&writep);
do task::spawn {
writer(path, writech, size);
};

View file

@ -14,7 +14,8 @@ extern mod libc {
fn sqrt(n: float) -> float;
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"4000000"]
} else if args.len() <= 1u {

View file

@ -81,7 +81,8 @@ fn stress(num_tasks: int) {
for results.each |r| { future::get(r); }
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"20"]
} else if args.len() <= 1u {

View file

@ -40,7 +40,8 @@ fn eval_AtA_times_u(u: ~[const float], AtAu: ~[mut float]) {
eval_At_times_u(v, AtAu);
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"2000"]
} else if args.len() <= 1u {

View file

@ -7,7 +7,7 @@ fn start(+token: int) {
use iter::*;
let p = comm::Port();
let mut ch = comm::Chan(p);
let mut ch = comm::Chan(&p);
for int::range(2, n_threads + 1) |i| {
let id = n_threads + 2 - i;
let to_child = do task::spawn_listener::<int> |p, copy ch| {
@ -37,7 +37,8 @@ fn roundtrip(id: int, p: comm::Port<int>, ch: comm::Chan<int>) {
}
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"2000000"]
} else if args.len() <= 1u {

View file

@ -17,7 +17,8 @@ fn check_sequential(min: uint, max: uint, map: SmallIntMap<uint>) {
}
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100000", ~"100"]
} else if args.len() <= 1u {

View file

@ -126,7 +126,8 @@ fn write_grid(f: io::Writer, g: grid_t) {
}
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let grid = if vec::len(args) == 1u {
// FIXME create sudoku inline since nested vec consts dont work yet
// (#571)

View file

@ -23,7 +23,8 @@ fn child_generation(gens_left: uint, -c: pipes::Chan<()>) {
}
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100000"]
} else if args.len() <= 1u {

View file

@ -11,7 +11,7 @@
// Doesn't return until all such tasks are ready, but doesn't block forever itself.
fn grandchild_group(num_tasks: uint) {
let po = comm::Port();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
for num_tasks.times {
do task::spawn { // linked
@ -37,7 +37,8 @@ fn spawn_supervised_blocking(myname: &str, +f: fn~()) {
assert x == task::Success;
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100000"]
} else if args.len() <= 1u {

View file

@ -8,7 +8,7 @@ enum msg {
fn calc(children: uint, parent_ch: comm::Chan<msg>) {
let port = comm::Port();
let chan = comm::Chan(port);
let chan = comm::Chan(&port);
let mut child_chs = ~[];
let mut sum = 0;
@ -48,7 +48,8 @@ fn calc(children: uint, parent_ch: comm::Chan<msg>) {
comm::send(parent_ch, done(sum + 1));
}
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"100000"]
} else if args.len() <= 1u {
@ -59,7 +60,7 @@ fn main(++args: ~[~str]) {
let children = uint::from_str(args[1]).get();
let port = comm::Port();
let chan = comm::Chan(port);
let chan = comm::Chan(&port);
do task::spawn {
calc(children, chan);
};

View file

@ -8,7 +8,8 @@ fn f(&&n: uint) {
fn g() { }
fn main(++args: ~[~str]) {
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
~[~"", ~"400"]
} else if args.len() <= 1u {

View file

@ -10,8 +10,6 @@
// xfail-pretty
#[legacy_modes];
extern mod std;
use option = option;
@ -43,7 +41,7 @@ trait word_reader {
type joinable_task = Port<()>;
fn spawn_joinable(+f: fn~()) -> joinable_task {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do task::spawn() |move f| {
f();
c.send(());
@ -70,18 +68,18 @@ fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) {
let f = f();
loop {
match f.read_word() {
Some(w) => { emit(w, 1); }
Some(w) => { emit(&w, 1); }
None => { break; }
}
}
}
fn reduce(&&word: ~str, get: map_reduce::getter<int>) {
fn reduce(word: &~str, get: map_reduce::getter<int>) {
let mut count = 0;
loop { match get() { Some(_) => { count += 1; } None => { break; } } }
io::println(fmt!("%s\t%?", word, count));
io::println(fmt!("%s\t%?", *word, count));
}
struct box<T> {
@ -116,13 +114,13 @@ mod map_reduce {
export reducer;
export map_reduce;
type putter<K: Send, V: Send> = fn(K, V);
type putter<K: Send, V: Send> = fn(&K, V);
type mapper<K1: Send, K2: Send, V: Send> = fn~(K1, putter<K2, V>);
type getter<V: Send> = fn() -> Option<V>;
type reducer<K: Copy Send, V: Copy Send> = fn~(K, getter<V>);
type reducer<K: Copy Send, V: Copy Send> = fn~(&K, getter<V>);
enum ctrl_proto<K: Copy Send, V: Copy Send> {
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
@ -145,9 +143,9 @@ mod map_reduce {
fn start_mappers<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send,
V: Copy Send>(
map: mapper<K1, K2, V>,
&ctrls: ~[ctrl_proto::server::open<K2, V>],
inputs: ~[K1])
map: &mapper<K1, K2, V>,
ctrls: &mut ~[ctrl_proto::server::open<K2, V>],
inputs: &~[K1])
-> ~[joinable_task]
{
let mut tasks = ~[];
@ -155,7 +153,8 @@ mod map_reduce {
let (ctrl, ctrl_server) = ctrl_proto::init();
let ctrl = box(ctrl);
let i = copy *i;
tasks.push(spawn_joinable(|move i| map_task(map, ctrl, i)));
let m = copy *map;
tasks.push(spawn_joinable(|move i| map_task(m, &ctrl, i)));
ctrls.push(ctrl_server);
}
return tasks;
@ -163,20 +162,22 @@ mod map_reduce {
fn map_task<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
map: mapper<K1, K2, V>,
ctrl: box<ctrl_proto::client::open<K2, V>>,
ctrl: &box<ctrl_proto::client::open<K2, V>>,
input: K1)
{
// log(error, "map_task " + input);
let intermediates = map::HashMap();
let intermediates: HashMap<K2, Chan<reduce_proto<V>>>
= map::HashMap();
do map(input) |key, val| {
do map(input) |key: &K2, val| {
let mut c = None;
let found = intermediates.find(key);
let found: Option<Chan<reduce_proto<V>>>
= intermediates.find(*key);
match found {
Some(_c) => { c = Some(_c); }
None => {
do ctrl.swap |ctrl| {
let ctrl = ctrl_proto::client::find_reducer(ctrl, key);
let ctrl = ctrl_proto::client::find_reducer(ctrl, *key);
match pipes::recv(ctrl) {
ctrl_proto::reducer(c_, ctrl) => {
c = Some(c_);
@ -184,7 +185,7 @@ mod map_reduce {
}
}
}
intermediates.insert(key, c.get());
intermediates.insert(*key, c.get());
send(c.get(), addref);
}
}
@ -200,21 +201,21 @@ mod map_reduce {
}
fn reduce_task<K: Copy Send, V: Copy Send>(
reduce: reducer<K, V>,
reduce: ~reducer<K, V>,
key: K,
out: Chan<Chan<reduce_proto<V>>>)
{
let p = Port();
send(out, Chan(p));
send(out, Chan(&p));
let mut ref_count = 0;
let mut is_done = false;
fn get<V: Copy Send>(p: Port<reduce_proto<V>>,
&ref_count: int, &is_done: bool)
ref_count: &mut int, is_done: &mut bool)
-> Option<V> {
while !is_done || ref_count > 0 {
while !*is_done || *ref_count > 0 {
match recv(p) {
emit_val(v) => {
// error!("received %d", v);
@ -222,16 +223,16 @@ mod map_reduce {
}
done => {
// error!("all done");
is_done = true;
*is_done = true;
}
addref => { ref_count += 1; }
release => { ref_count -= 1; }
addref => { *ref_count += 1; }
release => { *ref_count -= 1; }
}
}
return None;
}
reduce(key, || get(p, ref_count, is_done) );
(*reduce)(&key, || get(p, &mut ref_count, &mut is_done) );
}
fn map_reduce<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>(
@ -245,7 +246,7 @@ mod map_reduce {
// to do the rest.
let reducers = map::HashMap();
let mut tasks = start_mappers(map, ctrl, inputs);
let mut tasks = start_mappers(&map, &mut ctrl, &inputs);
let mut num_mappers = vec::len(inputs) as int;
while num_mappers > 0 {
@ -268,9 +269,9 @@ mod map_reduce {
None => {
// log(error, "creating new reducer for " + k);
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
let r = reduce, kk = k;
tasks.push(spawn_joinable(|| reduce_task(r, kk, ch) ));
tasks.push(spawn_joinable(|| reduce_task(~r, kk, ch) ));
c = recv(p);
reducers.insert(k, c);
}
@ -288,7 +289,8 @@ mod map_reduce {
}
}
fn main(++argv: ~[~str]) {
fn main() {
let argv = os::args();
if vec::len(argv) < 2u && !os::getenv(~"RUST_BENCH").is_some() {
let out = io::stdout();

View file

@ -1,3 +1,3 @@
// error-pattern:expected `extern fn(++v: ~[~str])
// error-pattern:expected `fn()
fn main(x: int) { }

View file

@ -4,8 +4,8 @@ fn borrow_from_arg_imm_ref(&&v: ~int) {
borrow(v);
}
fn borrow_from_arg_mut_ref(&v: ~int) {
borrow(v); //~ ERROR illegal borrow unless pure
fn borrow_from_arg_mut_ref(v: &mut ~int) {
borrow(*v); //~ ERROR illegal borrow unless pure
//~^ NOTE impure due to access to impure function
}

View file

@ -1,9 +1,9 @@
#[forbid(deprecated_mode)];
fn foo(_f: fn(&i: int)) { //~ ERROR explicit mode
fn foo(_f: fn(&i: int)) { //~ ERROR by-mutable-reference mode
}
type Bar = fn(&i: int); //~ ERROR explicit mode
type Bar = fn(&i: int); //~ ERROR by-mutable-reference mode
fn main() {
}

View file

@ -1,6 +1,6 @@
enum bottom { }
fn main() {
let x = ptr::p2::addr_of(&()) as *bottom;
let x = ptr::addr_of(&()) as *bottom;
match x { } //~ ERROR non-exhaustive patterns
}

View file

@ -1,11 +1,11 @@
extern mod std;
use cmp::Eq;
fn f<T:Eq>(&o: Option<T>) {
assert o == option::None;
fn f<T:Eq>(o: &mut Option<T>) {
assert *o == option::None;
}
fn main() {
f::<int>(option::None);
f::<int>(&mut option::None);
//~^ ERROR illegal borrow: creating mutable alias to static item
}

View file

@ -1,5 +1,5 @@
fn f1(&x: int) {
x = 1; // no error
fn f1(x: &mut int) {
*x = 1; // no error
}
fn f2() {

View file

@ -4,10 +4,6 @@ fn from_by_value_arg(++x: int) {
take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode
}
fn from_by_mut_ref_arg(&x: int) {
take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode
}
fn from_by_ref_arg(&&x: int) {
take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode
}

View file

@ -2,7 +2,7 @@ fn f1(x: int) {
//~^ WARNING unused variable: `x`
}
fn f1b(&x: int) {
fn f1b(x: &mut int) {
//~^ WARNING unused variable: `x`
}

View file

@ -1,28 +1,28 @@
// Note: it would be nice to give fewer warnings in these cases.
fn mutate_by_mut_ref(&x: uint) {
x = 0u;
fn mutate_by_mut_ref(x: &mut uint) {
*x = 0;
}
fn mutate_by_ref(&&x: uint) {
//~^ WARNING unused variable: `x`
x = 0u; //~ ERROR assigning to argument
x = 0; //~ ERROR assigning to argument
}
fn mutate_by_val(++x: uint) {
//~^ WARNING unused variable: `x`
x = 0u; //~ ERROR assigning to argument
x = 0; //~ ERROR assigning to argument
}
fn mutate_by_copy(+x: uint) {
//~^ WARNING unused variable: `x`
x = 0u; //~ ERROR assigning to argument
x = 0; //~ ERROR assigning to argument
//~^ WARNING value assigned to `x` is never read
}
fn mutate_by_move(-x: uint) {
//~^ WARNING unused variable: `x`
x = 0u; //~ ERROR assigning to argument
x = 0; //~ ERROR assigning to argument
//~^ WARNING value assigned to `x` is never read
}

View file

@ -1,5 +1,5 @@
fn main() {
let x : *~[int] = ptr::p2::addr_of(&~[1,2,3]);
let x : *~[int] = ptr::addr_of(&~[1,2,3]);
let y : *libc::c_void = x as *libc::c_void;
unsafe {
let _z = *y;

View file

@ -1,11 +1,8 @@
//error-pattern: mismatched types
//error-pattern: by-mutable-reference mode
fn bad(&a: int) {
}
// unnamed argument &int is now parsed x: &int
// it's not parsed &x: int anymore
fn called(f: fn(&int)) {
}

View file

@ -16,6 +16,6 @@ fn foo(i:int, j: @~str) -> foo {
fn main() {
let cat = ~"kitty";
let po = comm::Port(); //~ ERROR missing `send`
let ch = comm::Chan(po); //~ ERROR missing `send`
let ch = comm::Chan(&po); //~ ERROR missing `send`
comm::send(ch, foo(42, @cat)); //~ ERROR missing `send`
}

View file

@ -14,7 +14,7 @@ impl int: TraitB {
fn call_it<B: TraitB>(b: B) -> int {
let y = 4u;
b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait @TraitA for uint
b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait @TraitA
}
fn main() {

View file

@ -9,7 +9,7 @@ fn echo<T: Send>(c: Chan<T>, oc: Chan<Chan<T>>) {
// Tests that the type argument in port gets
// visited
let p = Port::<T>();
send(oc, Chan(p));
send(oc, Chan(&p));
let x = recv(p);
send(c, x);

View file

@ -1,10 +1,10 @@
// xfail-fast
#[legacy_modes];
fn f1(a: {mut x: int}, &b: int, -c: int) -> int {
let r = a.x + b + c;
fn f1(a: {mut x: int}, b: &mut int, -c: int) -> int {
let r = a.x + *b + c;
a.x = 0;
b = 10;
*b = 10;
return r;
}
@ -12,7 +12,7 @@ fn f2(a: int, f: fn(int)) -> int { f(1); return a; }
fn main() {
let mut a = {mut x: 1}, b = 2, c = 3;
assert (f1(a, b, c) == 6);
assert (f1(a, &mut b, c) == 6);
assert (a.x == 0);
assert (b == 10);
assert (f2(a.x, |x| a.x = 50 ) == 0);

View file

@ -1,5 +0,0 @@
fn main(++args: ~[~str]) {
let vs: ~[~str] = ~[~"hi", ~"there", ~"this", ~"is", ~"a", ~"vec"];
let vvs: ~[~[~str]] = ~[args, vs];
for vvs.each |vs| { for vs.each |s| { log(debug, *s); } }
}

View file

@ -10,7 +10,7 @@ fn a(c: Chan<int>) { send(c, 10); }
fn main() {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
task::spawn(|| a(ch) );
task::spawn(|| a(ch) );
let mut n: int = 0;

View file

@ -10,7 +10,7 @@ fn a(c: Chan<int>) { debug!("task a0"); debug!("task a1"); send(c, 10); }
fn main() {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
task::spawn(|| a(ch) );
task::spawn(|| b(ch) );
let mut n: int = 0;

View file

@ -29,7 +29,7 @@ fn main() {
let mut n: int = 2 + 3 * 7;
let s: ~str = ~"hello there";
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
task::spawn(|| a(ch) );
task::spawn(|| b(ch) );
let mut x: int = 10;

View file

@ -17,7 +17,7 @@ use comm::*;
fn foo(&&x: ()) -> Port<()> {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do task::spawn() |copy c, copy x| {
c.send(x);
}

View file

@ -12,7 +12,7 @@ type ctx = Chan<request>;
fn request_task(c: Chan<ctx>) {
let p = Port();
send(c, Chan(p));
send(c, Chan(&p));
let mut req: request;
req = recv(p);
// Need to drop req before receiving it again
@ -21,7 +21,7 @@ fn request_task(c: Chan<ctx>) {
fn new_cx() -> ctx {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
let t = task::spawn(|| request_task(ch) );
let mut cx: ctx;
cx = recv(p);
@ -32,6 +32,6 @@ fn main() {
let cx = new_cx();
let p = Port::<bool>();
send(cx, close(Chan(p)));
send(cx, close(Chan(&p)));
send(cx, quit);
}

View file

@ -7,7 +7,7 @@ use comm::recv;
fn main() {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let t = task::spawn(|| child(ch) );
let y = recv(p);
error!("received");

View file

@ -1,3 +0,0 @@
fn main(++args: ~[~str]) { log(debug, args[0]); }

View file

@ -8,7 +8,7 @@ use comm::recv;
fn main() {
let po = Port();
let ch = Chan(po);
let ch = Chan(&po);
send(ch, 10);
let i = recv(po);
assert (i == 10);

View file

@ -1,15 +1,15 @@
fn f(i: int, &called: bool) {
fn f(i: int, called: &mut bool) {
assert i == 10;
called = true;
*called = true;
}
fn g(f: extern fn(int, &v: bool), &called: bool) {
fn g(f: extern fn(int, v: &mut bool), called: &mut bool) {
f(10, called);
}
fn main() {
let mut called = false;
let h = f;
g(h, called);
g(h, &mut called);
assert called == true;
}

View file

@ -47,7 +47,7 @@ mod map_reduce {
None => {
let p = Port();
error!("sending find_reducer");
send(ctrl, find_reducer(str::to_bytes(key), Chan(p)));
send(ctrl, find_reducer(str::to_bytes(key), Chan(&p)));
error!("receiving");
c = recv(p);
log(error, c);
@ -70,7 +70,7 @@ mod map_reduce {
reducers = map::HashMap();
start_mappers(Chan(ctrl), inputs);
start_mappers(Chan(&ctrl), inputs);
let mut num_mappers = vec::len(inputs) as int;

View file

@ -1,13 +1,13 @@
#[abi = "rust-intrinsic"]
extern mod rusti {
#[legacy_exports];
fn move_val_init<T>(&dst: T, -src: T);
fn move_val<T>(&dst: T, -src: T);
fn move_val_init<T>(dst: &mut T, -src: T);
fn move_val<T>(dst: &mut T, -src: T);
}
fn main() {
let mut x = @1;
let mut y = @2;
rusti::move_val(y, x);
rusti::move_val(&mut y, x);
assert *y == 1;
}

View file

@ -20,7 +20,7 @@ fn child(c: Chan<int>) {
fn main() {
let p = comm::Port();
let ch = Chan(p);
let ch = Chan(&p);
task::spawn(|| child(ch) );

View file

@ -14,7 +14,7 @@ fn producer(c: Chan<~[u8]>) {
fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
let p: Port<~[u8]> = Port();
send(cb, Chan(p));
send(cb, Chan(&p));
loop {
debug!("waiting for bytes");
let data = recv(p);
@ -35,9 +35,9 @@ fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
fn main() {
let p: Port<msg> = Port();
let ch = Chan(p);
let ch = Chan(&p);
let recv_reader: Port<Chan<~[u8]>> = Port();
let recv_reader_chan = Chan(recv_reader);
let recv_reader_chan = Chan(&recv_reader);
let pack = task::spawn(|| packager(recv_reader_chan, ch) );
let source_chan: Chan<~[u8]> = recv(recv_reader);

View file

@ -6,10 +6,10 @@ fn a() {
fn doit() {
fn b(c: Chan<Chan<int>>) {
let p = Port();
send(c, Chan(p));
send(c, Chan(&p));
}
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
spawn(|| b(ch) );
recv(p);
}

View file

@ -13,7 +13,7 @@ fn producer(c: Chan<~[u8]>) {
fn main() {
let p: Port<~[u8]> = Port();
let ch = Chan(p);
let ch = Chan(&p);
let prod = task::spawn(|| producer(ch) );
let data: ~[u8] = recv(p);

View file

@ -1,12 +1,12 @@
fn incr(&x: int) -> bool { x += 1; assert (false); return false; }
fn incr(x: &mut int) -> bool { *x += 1; assert (false); return false; }
fn main() {
let x = 1 == 2 || 3 == 3;
assert (x);
let mut y: int = 10;
log(debug, x || incr(y));
log(debug, x || incr(&mut y));
assert (y == 10);
if true && x { assert (true); } else { assert (false); }
}

View file

@ -5,7 +5,7 @@ use comm::*;
fn main() {
let p = Port();
let ch = Chan(p);
let ch = Chan(&p);
let mut y: int;
task::spawn(|| child(ch) );

View file

@ -1 +0,0 @@
fn main(++args: ~[~str]) { for args.each |s| { log(debug, *s); } }

View file

@ -7,7 +7,7 @@ fn sub(parent: comm::Chan<int>, id: int) {
comm::send(parent, 0);
} else {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let child = task::spawn(|| sub(ch, id - 1) );
let y = comm::recv(p);
comm::send(parent, y + 1);
@ -16,7 +16,7 @@ fn sub(parent: comm::Chan<int>, id: int) {
fn main() {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let child = task::spawn(|| sub(ch, 200) );
let y = comm::recv(p);
debug!("transmission complete");

View file

@ -3,13 +3,13 @@
// -*- rust -*-
extern mod std;
fn grow(&v: ~[int]) { v += ~[1]; }
fn grow(v: &mut ~[int]) { *v += ~[1]; }
fn main() {
let mut v: ~[int] = ~[];
grow(v);
grow(v);
grow(v);
grow(&mut v);
grow(&mut v);
grow(&mut v);
let len = vec::len::<int>(v);
log(debug, len);
assert (len == 3 as uint);

View file

@ -1,3 +1,6 @@
// xfail-pretty
// FIXME #3654
mod a {
pub fn f() {}
pub fn g() {}

View file

@ -18,7 +18,7 @@ type record = {val1: u32, val2: u32, val3: u32};
// assertions.
fn test_init() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
}
@ -28,7 +28,7 @@ fn test_init() {
// Don't trigger any assertions.
fn test_grow() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 100u) |i| {
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
comm::send(mychan, val);
@ -39,14 +39,14 @@ fn test_grow() {
// Don't allow the buffer to shrink below it's original size
fn test_shrink1() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
send(mychan, 0i8);
let x = recv(myport);
}
fn test_shrink2() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 100u) |_i| {
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
@ -58,7 +58,7 @@ fn test_shrink2() {
// Test rotating the buffer when the unit size is not a power of two
fn test_rotate() {
let myport = Port();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 100u) |i| {
let val = {val1: i as u32, val2: i as u32, val3: i as u32};
send(mychan, val);
@ -74,7 +74,7 @@ fn test_rotate() {
// the unit size is not a power of two
fn test_rotate_grow() {
let myport = Port::<record>();
let mychan = Chan(myport);
let mychan = Chan(&myport);
for uint::range(0u, 10u) |j| {
for uint::range(0u, 10u) |i| {
let val: record =

View file

@ -18,7 +18,7 @@ extern mod rustrt {
fn main() unsafe {
let po = comm::Port();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
let parent_sched_id = rustrt::rust_get_sched_id();
error!("parent %?", parent_sched_id);
let num_threads = 1u;

View file

@ -8,7 +8,7 @@ fn die() {
fn iloop() {
task::spawn(|| die() );
let p = comm::Port::<()>();
let c = comm::Chan(p);
let c = comm::Chan(&p);
loop {
// Sending and receiving here because these actions yield,
// at which point our child can kill us

View file

@ -14,11 +14,11 @@ fn test(f: int) -> test {
fn main() {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
do spawn() {
let p = Port();
c.send(Chan(p));
c.send(Chan(&p));
let _r = p.recv();
}

View file

@ -8,6 +8,6 @@ type command<K: Send, V: Send> = {key: K, val: V};
fn cache_server<K: Send, V: Send>(c: Chan<Chan<command<K, V>>>) {
let ctrl = Port();
send(c, Chan(ctrl));
send(c, Chan(&ctrl));
}
fn main() { }

View file

@ -14,6 +14,6 @@ fn foo(i:int, j: char) -> foo {
fn main() {
let po = comm::Port::<foo>();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
comm::send(ch, foo(42, 'c'));
}

View file

@ -15,6 +15,6 @@ fn iotask(cx: ctx, ip: ~str) {
fn main() {
let p = comm::Port::<int>();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
task::spawn(|| iotask(ch, ~"localhost") );
}

View file

@ -2,6 +2,6 @@ extern mod std;
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
comm::send(c, ~"coffee");
}

View file

@ -2,6 +2,6 @@ extern mod std;
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
comm::send(c, ~"coffee");
}

View file

@ -3,7 +3,7 @@ extern mod std;
fn main() {
let c = {
let p = comm::Port();
comm::Chan(p)
comm::Chan(&p)
};
comm::send(c, ~"coffee");
}

View file

@ -12,7 +12,7 @@ fn starship(&&ch: comm::Chan<~str>) {
fn starbase() {
for int::range(0, 10) |_i| {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
task::spawn(|| starship(c) );
task::yield();
}

View file

@ -7,7 +7,7 @@ extern mod std;
// or not this is desirable I don't know, but here's a regression test.
fn main() {
let po = comm::Port();
let ch = comm::Chan(po);
let ch = comm::Chan(&po);
comm::send(ch, ());
let n: () = comm::recv(po);
assert (n == ());

View file

@ -32,7 +32,7 @@ fn test00() {
debug!("Creating tasks");
let po = Port();
let ch = Chan(po);
let ch = Chan(&po);
let mut i: int = 0;
@ -69,7 +69,7 @@ fn test01() {
fn test02() {
let p = Port();
let c = Chan(p);
let c = Chan(&p);
debug!("Writing to a local task channel.");
send(c, 42);
debug!("Reading from a local task port.");
@ -101,7 +101,7 @@ fn test05_start(ch: Chan<int>) {
fn test05() {
let po = comm::Port();
let ch = Chan(po);
let ch = Chan(&po);
task::spawn(|| test05_start(ch) );
let mut value: int;
value = recv(po);

View file

@ -36,7 +36,7 @@ fn joinable(+f: fn~()) -> comm::Port<bool> {
*b = true;
}
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
do task::spawn_unlinked { wrapper(c, copy f) };
p
}

View file

@ -1,6 +1,6 @@
fn main() {
let p = comm::Port::<uint>();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let x = ~1;
let x_in_parent = ptr::addr_of(&(*x)) as uint;

View file

@ -0,0 +1,31 @@
// xfail-fast
// xfail-test
// Broken on 32 bit, I guess?
trait Foo {
fn f();
}
trait Bar : Foo {
fn g();
}
struct A {
x: int
}
impl A : Bar {
fn g() { io::println("in g"); }
fn f() { io::println("in f"); }
}
fn h<T:Foo>(a: &T) {
a.f();
}
fn main() {
let a = A { x: 3 };
h(&a);
}

View file

@ -0,0 +1,21 @@
trait Foo {
fn f() -> int;
}
struct A {
x: int
}
impl A : Foo {
fn f() -> int {
io::println(~"Today's number is " + self.x.to_str());
return self.x;
}
}
fn main() {
let a = A { x: 3 };
let b = (&a) as &Foo;
assert b.f() == 3;
}

View file

@ -1,9 +1,9 @@
fn f(&i: ~int) {
i = ~200;
fn f(i: &mut ~int) {
*i = ~200;
}
fn main() {
let mut i = ~100;
f(i);
f(&mut i);
assert *i == 200;
}

View file

@ -6,7 +6,7 @@ fn child(c: comm::Chan<~uint>, i: uint) {
fn main() {
let p = comm::Port();
let ch = comm::Chan(p);
let ch = comm::Chan(&p);
let n = 100u;
let mut expected = 0u;
for uint::range(0u, n) |i| {

View file

@ -2,7 +2,7 @@ extern mod std;
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
comm::send(c, ~100);
let v = comm::recv(p);
assert v == ~100;

View file

@ -22,7 +22,7 @@ fn f(c: comm::Chan<bool>) {
fn main() {
let p = comm::Port();
let c = comm::Chan(p);
let c = comm::Chan(&p);
task::spawn_unlinked(|| f(c) );
error!("hiiiiiiiii");
assert comm::recv(p);

View file

@ -4,10 +4,10 @@
// -*- rust -*-
type point = {x: int, y: int, mut z: int};
fn f(&p: point) { p.z = 13; }
fn f(p: &mut point) { p.z = 13; }
fn main() {
let mut x: point = {x: 10, y: 11, mut z: 12};
f(x);
f(&mut x);
assert (x.z == 13);
}