librustc: Make || lambdas not infer to procs
This commit is contained in:
parent
38efa17bb8
commit
749ee53c6d
64 changed files with 139 additions and 126 deletions
|
|
@ -214,29 +214,29 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
smalltest(|mut server| {
|
||||
smalltest(proc(mut server) {
|
||||
let mut buf = [0];
|
||||
server.read(buf);
|
||||
assert!(buf[0] == 99);
|
||||
}, |mut client| {
|
||||
}, proc(mut client) {
|
||||
client.write([99]);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_eof() {
|
||||
smalltest(|mut server| {
|
||||
smalltest(proc(mut server) {
|
||||
let mut buf = [0];
|
||||
assert!(server.read(buf).is_none());
|
||||
assert!(server.read(buf).is_none());
|
||||
}, |_client| {
|
||||
}, proc(_client) {
|
||||
// drop the client
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn write_begone() {
|
||||
smalltest(|mut server| {
|
||||
smalltest(proc(mut server) {
|
||||
let buf = [0];
|
||||
let mut stop = false;
|
||||
while !stop{
|
||||
|
|
@ -248,7 +248,7 @@ mod tests {
|
|||
server.write(buf);
|
||||
})
|
||||
}
|
||||
}, |_client| {
|
||||
}, proc(_client) {
|
||||
// drop the client
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ mod test {
|
|||
do run_in_bare_thread {
|
||||
local_ptr::init_tls_key();
|
||||
let mut sched = ~new_test_uv_sched();
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||
Local::put(task);
|
||||
let task: ~Task = Local::take();
|
||||
cleanup_task(task);
|
||||
|
|
@ -146,11 +146,11 @@ mod test {
|
|||
do run_in_bare_thread {
|
||||
local_ptr::init_tls_key();
|
||||
let mut sched = ~new_test_uv_sched();
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||
Local::put(task);
|
||||
let task: ~Task = Local::take();
|
||||
cleanup_task(task);
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||
Local::put(task);
|
||||
let task: ~Task = Local::take();
|
||||
cleanup_task(task);
|
||||
|
|
@ -163,7 +163,7 @@ mod test {
|
|||
do run_in_bare_thread {
|
||||
local_ptr::init_tls_key();
|
||||
let mut sched = ~new_test_uv_sched();
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||
Local::put(task);
|
||||
|
||||
unsafe {
|
||||
|
|
@ -179,7 +179,7 @@ mod test {
|
|||
do run_in_bare_thread {
|
||||
local_ptr::init_tls_key();
|
||||
let mut sched = ~new_test_uv_sched();
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
|
||||
let task = ~Task::new_root(&mut sched.stack_pool, None, proc(){});
|
||||
Local::put(task);
|
||||
|
||||
let res = Local::borrow(|_task: &mut Task| {
|
||||
|
|
|
|||
|
|
@ -340,14 +340,14 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
|
|||
|
||||
// When the main task exits, after all the tasks in the main
|
||||
// task tree, shut down the schedulers and set the exit code.
|
||||
let handles = Cell::new(handles);
|
||||
let on_exit: proc(UnwindResult) = |exit_success| {
|
||||
let handles = handles;
|
||||
let on_exit: proc(UnwindResult) = proc(exit_success) {
|
||||
unsafe {
|
||||
assert!(!(*exited_already.get()).swap(true, SeqCst),
|
||||
"the runtime already exited");
|
||||
}
|
||||
|
||||
let mut handles = handles.take();
|
||||
let mut handles = handles;
|
||||
for handle in handles.mut_iter() {
|
||||
handle.send(Shutdown);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ mod test {
|
|||
assert!(Task::on_appropriate_sched());
|
||||
};
|
||||
|
||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
||||
let on_exit: proc(UnwindResult) = proc(exit_status) {
|
||||
rtassert!(exit_status.is_success())
|
||||
};
|
||||
task.death.on_exit = Some(on_exit);
|
||||
|
|
@ -1193,12 +1193,15 @@ mod test {
|
|||
|
||||
let thread = do Thread::start {
|
||||
let mut sched = sched.take();
|
||||
let bootstrap_task = ~Task::new_root(&mut sched.stack_pool, None, ||());
|
||||
let bootstrap_task =
|
||||
~Task::new_root(&mut sched.stack_pool,
|
||||
None,
|
||||
proc()());
|
||||
sched.bootstrap(bootstrap_task);
|
||||
};
|
||||
|
||||
let mut stack_pool = StackPool::new();
|
||||
let task = ~Task::new_root(&mut stack_pool, None, ||());
|
||||
let task = ~Task::new_root(&mut stack_pool, None, proc()());
|
||||
handle.send(TaskFromFriend(task));
|
||||
|
||||
handle.send(Shutdown);
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ impl Coroutine {
|
|||
|
||||
fn build_start_wrapper(start: proc()) -> proc() {
|
||||
let start_cell = Cell::new(start);
|
||||
let wrapper: proc() = || {
|
||||
let wrapper: proc() = proc() {
|
||||
// First code after swap to this new context. Run our
|
||||
// cleanup job.
|
||||
unsafe {
|
||||
|
|
@ -712,10 +712,10 @@ mod test {
|
|||
#[test]
|
||||
fn unwind() {
|
||||
do run_in_newsched_task() {
|
||||
let result = spawntask_try(||());
|
||||
let result = spawntask_try(proc()());
|
||||
rtdebug!("trying first assert");
|
||||
assert!(result.is_ok());
|
||||
let result = spawntask_try(|| fail!());
|
||||
let result = spawntask_try(proc() fail!());
|
||||
rtdebug!("trying second assert");
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,10 +83,11 @@ pub fn run_in_uv_task_core(f: proc()) {
|
|||
use rt::sched::Shutdown;
|
||||
|
||||
let mut sched = ~new_test_uv_sched();
|
||||
let exit_handle = Cell::new(sched.make_handle());
|
||||
let exit_handle = sched.make_handle();
|
||||
|
||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
||||
exit_handle.take().send(Shutdown);
|
||||
let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
|
||||
let mut exit_handle = exit_handle;
|
||||
exit_handle.send(Shutdown);
|
||||
rtassert!(exit_status.is_success());
|
||||
};
|
||||
let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
|
||||
|
|
@ -99,10 +100,11 @@ pub fn run_in_newsched_task_core(f: proc()) {
|
|||
use rt::sched::Shutdown;
|
||||
|
||||
let mut sched = ~new_test_sched();
|
||||
let exit_handle = Cell::new(sched.make_handle());
|
||||
let exit_handle = sched.make_handle();
|
||||
|
||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
||||
exit_handle.take().send(Shutdown);
|
||||
let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
|
||||
let mut exit_handle = exit_handle;
|
||||
exit_handle.send(Shutdown);
|
||||
rtassert!(exit_status.is_success());
|
||||
};
|
||||
let mut task = ~Task::new_root(&mut sched.stack_pool, None, f);
|
||||
|
|
@ -244,10 +246,10 @@ pub fn run_in_mt_newsched_task(f: proc()) {
|
|||
scheds.push(sched);
|
||||
}
|
||||
|
||||
let handles = Cell::new(handles);
|
||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
||||
let mut handles = handles.take();
|
||||
let handles = handles; // Work around not being able to capture mut
|
||||
let on_exit: proc(UnwindResult) = proc(exit_status: UnwindResult) {
|
||||
// Tell schedulers to exit
|
||||
let mut handles = handles;
|
||||
for handle in handles.mut_iter() {
|
||||
handle.send(Shutdown);
|
||||
}
|
||||
|
|
@ -319,8 +321,9 @@ pub fn spawntask_random(f: proc()) {
|
|||
pub fn spawntask_try(f: proc()) -> Result<(),()> {
|
||||
|
||||
let (port, chan) = oneshot();
|
||||
let chan = Cell::new(chan);
|
||||
let on_exit: proc(UnwindResult) = |exit_status| chan.take().send(exit_status);
|
||||
let on_exit: proc(UnwindResult) = proc(exit_status) {
|
||||
chan.send(exit_status)
|
||||
};
|
||||
|
||||
let mut new_task = Task::build_root(None, f);
|
||||
new_task.death.on_exit = Some(on_exit);
|
||||
|
|
@ -348,7 +351,9 @@ pub fn spawntask_thread(f: proc()) -> Thread {
|
|||
pub fn with_test_task(blk: proc(~Task) -> ~Task) {
|
||||
do run_in_bare_thread {
|
||||
let mut sched = ~new_test_sched();
|
||||
let task = blk(~Task::new_root(&mut sched.stack_pool, None, ||{}));
|
||||
let task = blk(~Task::new_root(&mut sched.stack_pool,
|
||||
None,
|
||||
proc() {}));
|
||||
cleanup_task(task);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,13 +280,13 @@ impl TaskBuilder {
|
|||
let prev_gen_body = match prev_gen_body {
|
||||
Some(gen) => gen,
|
||||
None => {
|
||||
let f: proc(proc()) -> proc() = |body| body;
|
||||
let f: proc(proc()) -> proc() = proc(body) body;
|
||||
f
|
||||
}
|
||||
};
|
||||
let prev_gen_body = Cell::new(prev_gen_body);
|
||||
let next_gen_body = {
|
||||
let f: proc(proc()) -> proc() = |body| {
|
||||
let f: proc(proc()) -> proc() = proc(body) {
|
||||
let prev_gen_body = prev_gen_body.take();
|
||||
wrapper(prev_gen_body(body))
|
||||
};
|
||||
|
|
@ -551,7 +551,7 @@ fn test_add_wrapper() {
|
|||
let ch = Cell::new(ch);
|
||||
do b0.add_wrapper |body| {
|
||||
let ch = Cell::new(ch.take());
|
||||
let result: proc() = || {
|
||||
let result: proc() = proc() {
|
||||
let ch = ch.take();
|
||||
body();
|
||||
ch.send(());
|
||||
|
|
@ -765,7 +765,7 @@ fn test_child_doesnt_ref_parent() {
|
|||
// valgrind-friendly. try this at home, instead..!)
|
||||
static generations: uint = 16;
|
||||
fn child_no(x: uint) -> proc() {
|
||||
return || {
|
||||
return proc() {
|
||||
if x < generations {
|
||||
let mut t = task();
|
||||
t.unwatched();
|
||||
|
|
@ -783,7 +783,7 @@ fn test_simple_newsched_spawn() {
|
|||
use rt::test::run_in_uv_task;
|
||||
|
||||
do run_in_uv_task {
|
||||
spawn(||())
|
||||
spawn(proc()())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ pub fn spawn_raw(mut opts: TaskOpts, f: proc()) {
|
|||
if opts.notify_chan.is_some() {
|
||||
let notify_chan = opts.notify_chan.take_unwrap();
|
||||
let notify_chan = Cell::new(notify_chan);
|
||||
let on_exit: proc(UnwindResult) = |task_result| {
|
||||
let on_exit: proc(UnwindResult) = proc(task_result) {
|
||||
notify_chan.take().send(task_result)
|
||||
};
|
||||
task.death.on_exit = Some(on_exit);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue