librustc: Make || lambdas not infer to procs

This commit is contained in:
Patrick Walton 2013-11-21 23:36:52 -08:00
parent 38efa17bb8
commit 749ee53c6d
64 changed files with 139 additions and 126 deletions

View file

@ -46,7 +46,7 @@ fn fib(n: int) -> int {
let (p, ch) = stream();
let ch = SharedChan::new(ch);
let _t = task::spawn(|| pfib(&ch, n) );
let _t = task::spawn(proc() pfib(&ch, n) );
p.recv()
}

View file

@ -33,5 +33,5 @@ fn main() {
};
let n = from_str::<uint>(args[1]).unwrap();
let mut i = 0u;
while i < n { task::spawn(|| f(n) ); i += 1u; }
while i < n { task::spawn(proc() f(n) ); i += 1u; }
}

View file

@ -24,7 +24,7 @@ fn box_imm() {
let v = ~3;
let _w = &v;
task::spawn(|| {
task::spawn(proc() {
info!("v={}", *v);
//~^ ERROR cannot move
});

View file

@ -3,6 +3,6 @@ pub fn main() {
// you get two error reports here.
let bar = ~3;
let _g = || { //~ ERROR capture of moved value
let _h: proc() -> int = || *bar; //~ ERROR capture of moved value
let _h: proc() -> int = proc() *bar; //~ ERROR capture of moved value
};
}

View file

@ -5,6 +5,6 @@ fn call_f(f: proc() -> int) -> int {
fn main() {
let t = ~3;
call_f(|| { *t + 1 });
call_f(|| { *t + 1 }); //~ ERROR capture of moved value
call_f(proc() { *t + 1 });
call_f(proc() { *t + 1 }); //~ ERROR capture of moved value
}

View file

@ -14,7 +14,7 @@ fn foo(_x: @uint) {}
fn main() {
let x = @3u;
let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
let _: proc() = || foo(x); //~ ERROR does not fulfill `Send`
let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
let _: proc() = proc() foo(x); //~ ERROR does not fulfill `Send`
}

View file

@ -18,7 +18,7 @@ fn failfn() {
fn main() {
let y = ~0;
let x: @proc() = @(|| {
let x: @proc() = @(proc() {
error!("{:?}", y.clone());
});
failfn();

View file

@ -19,7 +19,7 @@ fn asBlock(f: || -> uint) -> uint {
}
pub fn main() {
let x = asSendfn(|| 22u);
let x = asSendfn(proc() 22u);
assert_eq!(x, 22u);
let x = asBlock(|| 22u);
assert_eq!(x, 22u);

View file

@ -1,5 +1,5 @@
pub fn main() {
let bar = ~3;
let h: proc() -> int = || *bar;
let h: proc() -> int = proc() *bar;
assert_eq!(h(), 3);
}

View file

@ -13,11 +13,11 @@ use std::ptr;
pub fn main() {
let x = ~3;
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
let snd_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
let snd_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint;
assert_eq!(snd_move(), y);
let x = ~4;
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
let lam_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
let lam_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint;
assert_eq!(lam_move(), y);
}

View file

@ -15,5 +15,5 @@ use std::task;
fn child2(_s: ~str) { }
pub fn main() {
let _x = task::spawn(|| child2(~"hi"));
let _x = task::spawn(proc() child2(~"hi"));
}

View file

@ -15,7 +15,7 @@ use std::task;
fn adder(x: @int, y: @int) -> int { return *x + *y; }
fn failer() -> @int { fail!(); }
pub fn main() {
assert!(task::try(|| {
assert!(task::try(proc() {
adder(@2, failer()); ()
}).is_err());
}

View file

@ -19,7 +19,7 @@ struct Pair {
pub fn main() {
let z = ~Pair { a : 10, b : 12};
let f: proc() = || {
let f: proc() = proc() {
assert_eq!(z.a, 10);
assert_eq!(z.b, 12);
};

View file

@ -12,7 +12,7 @@ use std::task;
pub fn main() {
let (p, ch) = stream();
let _t = task::spawn(|| child(&ch) );
let _t = task::spawn(proc() child(&ch));
let y = p.recv();
error!("received");
error!("{:?}", y);

View file

@ -34,7 +34,7 @@ mod map_reduce {
for i in inputs.iter() {
let ctrl = ctrl.clone();
let i = i.clone();
task::spawn(|| map_task(ctrl.clone(), i.clone()) );
task::spawn(proc() map_task(ctrl.clone(), i.clone()) );
}
}

View file

@ -21,7 +21,7 @@ type rsrc_loader = proc(path: &Path) -> result::Result<~str, ~str>;
fn tester()
{
let loader: rsrc_loader = |_path| {result::Ok(~"more blah")};
let loader: rsrc_loader = proc(_path) {result::Ok(~"more blah")};
let path = path::Path::new("blah");
assert!(loader(&path).is_ok());

View file

@ -14,13 +14,11 @@ enum Msg
fn foo(name: ~str, samples_chan: Chan<Msg>) {
do task::spawn
{
let callback: SamplesFn =
|buffer|
{
for i in range(0u, buffer.len()) {
error!("{}: {}", i, buffer[i])
}
};
let callback: SamplesFn = proc(buffer) {
for i in range(0u, buffer.len()) {
error!("{}: {}", i, buffer[i])
}
};
samples_chan.send(GetSamples(name.clone(), callback));
};
}

View file

@ -8,7 +8,7 @@ fn producer(c: &Chan<~[u8]>) {
pub fn main() {
let (p, ch) = stream::<~[u8]>();
let _prod = task::spawn(|| producer(&ch) );
let _prod = task::spawn(proc() producer(&ch) );
let _data: ~[u8] = p.recv();
}

View file

@ -11,7 +11,7 @@
// Test that the lambda kind is inferred correctly as a return
// expression
fn unique() -> proc() { return || (); }
fn unique() -> proc() { return proc() (); }
pub fn main() {
}

View file

@ -11,7 +11,7 @@
// Test that the lambda kind is inferred correctly as a return
// expression
fn unique() -> proc() { || () }
fn unique() -> proc() { proc() () }
pub fn main() {
}

View file

@ -69,6 +69,6 @@ pub fn main() {
assert_eq!(q.y, !(p.y));
// Issue #1733
let result: proc(int) = |_|();
let result: proc(int) = proc(_)();
result(p[true]);
}

View file

@ -19,12 +19,12 @@ fn test05_start(f: proc(int)) {
fn test05() {
let three = ~3;
let fn_to_send: proc(int) = |n| {
let fn_to_send: proc(int) = proc(n) {
error!("{}", *three + n); // will copy x into the closure
assert_eq!(*three, 3);
};
let fn_to_send = Cell::new(fn_to_send);
task::spawn(|| {
task::spawn(proc() {
test05_start(fn_to_send.take());
});
}

View file

@ -16,9 +16,9 @@ fn x(s: ~str, n: int) {
}
pub fn main() {
task::spawn(|| x(~"hello from first spawned fn", 65) );
task::spawn(|| x(~"hello from second spawned fn", 66) );
task::spawn(|| x(~"hello from third spawned fn", 67) );
task::spawn(proc() x(~"hello from first spawned fn", 65) );
task::spawn(proc() x(~"hello from second spawned fn", 66) );
task::spawn(proc() x(~"hello from third spawned fn", 67) );
let mut i: int = 30;
while i > 0 { i = i - 1; info!("parent sleeping"); task::deschedule(); }
}

View file

@ -24,5 +24,5 @@ fn iotask(_cx: &ctx, ip: ~str) {
pub fn main() {
let (_p, ch) = stream::<int>();
task::spawn(|| iotask(&ch, ~"localhost") );
task::spawn(proc() iotask(&ch, ~"localhost") );
}

View file

@ -13,7 +13,7 @@ extern mod extra;
use std::task;
pub fn main() {
task::spawn(|| child(10) );
task::spawn(proc() child(10) );
}
fn child(i: int) { error!("{}", i); assert!((i == 10)); }

View file

@ -10,7 +10,7 @@
use std::task;
pub fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
pub fn main() { task::spawn(proc() child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
fn child(args: (int, int, int, int, int, int, int, int, int)) {
let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;

View file

@ -18,5 +18,5 @@ use std::task;
fn main() {
let mut t = task::task();
t.sched_mode(task::SingleThreaded);
t.spawn(|| ());
t.spawn(proc() ());
}

View file

@ -18,7 +18,7 @@ pub fn main() {
name: DynTestName(~"test"),
should_fail: false
},
testfn: DynTestFn(|| ()),
testfn: DynTestFn(proc() ()),
};
do_swap(&mut test);
}

View file

@ -29,7 +29,7 @@ fn test05_start(ch : &Chan<int>) {
fn test05() {
let (po, ch) = comm::stream();
task::spawn(|| test05_start(&ch) );
task::spawn(proc() test05_start(&ch) );
let mut value: int = po.recv();
error!("{}", value);
value = po.recv();

View file

@ -15,6 +15,6 @@ pub fn main() { test00(); }
fn start() { info!("Started / Finished task."); }
fn test00() {
task::try(|| start() );
task::try(proc() start() );
info!("Completing.");
}

View file

@ -31,7 +31,7 @@ fn start(c: &comm::Chan<comm::Chan<~str>>) {
pub fn main() {
let (p, ch) = comm::stream();
let _child = task::spawn(|| start(&ch) );
let _child = task::spawn(proc() start(&ch) );
let c = p.recv();
c.send(~"A");

View file

@ -22,6 +22,6 @@ fn start(c: &comm::Chan<comm::Chan<int>>) {
pub fn main() {
let (p, ch) = comm::stream();
let _child = task::spawn(|| start(&ch) );
let _child = task::spawn(proc() start(&ch) );
let _c = p.recv();
}

View file

@ -23,6 +23,6 @@ fn start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
pub fn main() {
info!("Check that we don't deadlock.");
let (_p, ch) = comm::stream();
task::try(|| start(&ch, 0, 10) );
task::try(proc() start(&ch, 0, 10) );
info!("Joined task");
}

View file

@ -22,7 +22,7 @@ pub fn main() {
while (i > 0) {
info!("{}", i);
let ch = ch.clone();
task::spawn({let i = i; || child(i, &ch)});
task::spawn({let i = i; proc() child(i, &ch)});
i = i - 1;
}

View file

@ -29,6 +29,6 @@ pub fn main() {
// the child's point of view the receiver may die. We should
// drop messages on the floor in this case, and not crash!
let (p, ch) = comm::stream();
task::spawn(|| start(&ch, 10));
task::spawn(proc() start(&ch, 10));
p.recv();
}

View file

@ -20,5 +20,5 @@ fn f() {
}
pub fn main() {
task::spawn(|| f() );
task::spawn(proc() f() );
}

View file

@ -48,7 +48,7 @@ fn test00() {
results.push(builder.future_result());
builder.spawn({
let i = i;
|| test00_start(&ch, i, number_of_messages)
proc() test00_start(&ch, i, number_of_messages)
});
i = i + 1;
}

View file

@ -13,7 +13,7 @@ extern mod extra;
use std::task;
pub fn main() {
task::spawn(|| child(~"Hello") );
task::spawn(proc() child(~"Hello") );
}
fn child(_s: ~str) {

View file

@ -17,7 +17,7 @@ pub fn main() {
let x = ~1;
let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint;
task::spawn(|| {
task::spawn(proc() {
let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint;
ch.send(x_in_child);
});

View file

@ -40,7 +40,7 @@ fn test_tempdir() {
fn test_rm_tempdir() {
let (rd, wr) = stream();
let f: proc() = || {
let f: proc() = proc() {
let tmp = TempDir::new("test_rm_tempdir").unwrap();
wr.send(tmp.path().clone());
fail!("fail to unwind past `tmp`");
@ -52,7 +52,7 @@ fn test_rm_tempdir() {
let tmp = TempDir::new("test_rm_tempdir").unwrap();
let path = tmp.path().clone();
let cell = Cell::new(tmp);
let f: proc() = || {
let f: proc() = proc() {
let _tmp = cell.take();
fail!("fail to unwind past `tmp`");
};
@ -61,7 +61,7 @@ fn test_rm_tempdir() {
let path;
{
let f: proc() -> TempDir = || {
let f: proc() -> TempDir = proc() {
TempDir::new("test_rm_tempdir").unwrap()
};
let tmp = task::try(f).expect("test_rm_tmdir");

View file

@ -25,13 +25,13 @@ fn test_ret() { let _x: @int = return; }
fn test_fail() {
fn f() { let _x: @int = fail!(); }
task::try(|| f() );
task::try(proc() f() );
}
fn test_fail_indirect() {
fn f() -> ! { fail!(); }
fn g() { let _x: @int = f(); }
task::try(|| g() );
task::try(proc() g() );
}
pub fn main() {

View file

@ -14,7 +14,7 @@ use std::task;
pub fn main() {
let mut i = 10;
while i > 0 { task::spawn({let i = i; || child(i)}); i = i - 1; }
while i > 0 { task::spawn({let i = i; proc() child(i)}); i = i - 1; }
info!("main thread exiting");
}

View file

@ -23,7 +23,7 @@ struct Pointy {
}
fn make_uniq_closure<A:Send>(a: A) -> proc() -> uint {
let result: proc() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
let result: proc() -> uint = proc() ptr::to_unsafe_ptr(&a) as uint;
result
}

View file

@ -25,7 +25,7 @@ fn empty_pointy() -> @mut Pointy {
return @mut Pointy {
a : none,
c : ~22,
d : || {},
d : proc() {},
}
}

View file

@ -22,7 +22,7 @@ pub fn main() {
let mut expected = 0u;
for i in range(0u, n) {
let ch = ch.clone();
task::spawn(|| child(&ch, i) );
task::spawn(proc() child(&ch, i) );
expected += i;
}

View file

@ -42,7 +42,7 @@ fn f(c: SharedChan<bool>) {
pub fn main() {
let (p, c) = stream();
let c = SharedChan::new(c);
task::spawn(|| f(c.clone()) );
task::spawn(proc() f(c.clone()));
error!("hiiiiiiiii");
assert!(p.recv());
}