librustc: Convert ~fn()
to proc()
everywhere.
This commit is contained in:
parent
77f621bff4
commit
ba739b2135
@ -213,7 +213,7 @@ msgstr ""
|
||||
#. type: Plain text
|
||||
#: doc/tutorial-tasks.md:102
|
||||
msgid ""
|
||||
"The `spawn` function has a very simple type signature: `fn spawn(f: ~fn())`. "
|
||||
"The `spawn` function has a very simple type signature: `fn spawn(f: proc())`. "
|
||||
"Because it accepts only owned closures, and owned closures contain only "
|
||||
"owned data, `spawn` can safely move the entire closure and all its "
|
||||
"associated state into an entirely different task for execution. Like any "
|
||||
|
@ -3509,13 +3509,13 @@ msgstr "## 所有クロージャ"
|
||||
#. type: Plain text
|
||||
#: doc/tutorial.md:1510
|
||||
msgid ""
|
||||
"Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to "
|
||||
"Owned closures, written `proc`, hold on to "
|
||||
"things that can safely be sent between processes. They copy the values they "
|
||||
"close over, much like managed closures, but they also own them: that is, no "
|
||||
"other code can access them. Owned closures are used in concurrent code, "
|
||||
"particularly for spawning [tasks][tasks]."
|
||||
msgstr ""
|
||||
"`~` ポインタ型と同様に `~fn` 型 で書き表される所有クロージャは安全にプロセス"
|
||||
"`~` `proc` で書き表される所有クロージャは安全にプロセス"
|
||||
"間で送信することができます。所有クローじゃはマネージドクロージャと全く同じよ"
|
||||
"うに閉じ込める値をコピーしますが、値を所有します。つまり、他のコードは閉じ込"
|
||||
"められた値にアクセスできなくなります。所有クロージャは並列プログラム、特に "
|
||||
@ -3666,11 +3666,11 @@ msgstr ""
|
||||
#: doc/tutorial.md:1582
|
||||
msgid ""
|
||||
"`do` is a convenient way to create tasks with the `task::spawn` function. "
|
||||
"`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a "
|
||||
"`spawn` has the signature `spawn(fn: proc())`. In other words, it is a "
|
||||
"function that takes an owned closure that takes no arguments."
|
||||
msgstr ""
|
||||
"`task::spawn` 関数を用いてタスクを生成する場合、 `do` を用いると便利です。"
|
||||
"`spawn` は、 `spawn(fn: ~fn())` という方を持っています。言い換えると、"
|
||||
"`spawn` は、 `spawn(fn: proc())` という方を持っています。言い換えると、"
|
||||
"`spawn` は「引数をとらない所有クロージャ」を引数としてとる関数ということで"
|
||||
"す。"
|
||||
|
||||
|
@ -213,7 +213,7 @@ msgstr ""
|
||||
#. type: Plain text
|
||||
#: doc/tutorial-tasks.md:102
|
||||
msgid ""
|
||||
"The `spawn` function has a very simple type signature: `fn spawn(f: ~fn())`. "
|
||||
"The `spawn` function has a very simple type signature: `fn spawn(f: proc())`. "
|
||||
"Because it accepts only owned closures, and owned closures contain only "
|
||||
"owned data, `spawn` can safely move the entire closure and all its "
|
||||
"associated state into an entirely different task for execution. Like any "
|
||||
|
@ -2683,7 +2683,7 @@ msgstr ""
|
||||
#. type: Plain text
|
||||
#: doc/tutorial.md:1510
|
||||
msgid ""
|
||||
"Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to "
|
||||
"Owned closures, written `proc`, hold on to "
|
||||
"things that can safely be sent between processes. They copy the values they "
|
||||
"close over, much like managed closures, but they also own them: that is, no "
|
||||
"other code can access them. Owned closures are used in concurrent code, "
|
||||
@ -2808,7 +2808,7 @@ msgstr ""
|
||||
#: doc/tutorial.md:1582
|
||||
msgid ""
|
||||
"`do` is a convenient way to create tasks with the `task::spawn` function. "
|
||||
"`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a "
|
||||
"`spawn` has the signature `spawn(fn: proc())`. In other words, it is a "
|
||||
"function that takes an owned closure that takes no arguments."
|
||||
msgstr ""
|
||||
|
||||
|
@ -91,7 +91,7 @@ _owned types_. The language leaves the implementation details to the standard
|
||||
library.
|
||||
|
||||
The `spawn` function has a very simple type signature: `fn spawn(f:
|
||||
~fn())`. Because it accepts only owned closures, and owned closures
|
||||
proc())`. Because it accepts only owned closures, and owned closures
|
||||
contain only owned data, `spawn` can safely move the entire closure
|
||||
and all its associated state into an entirely different task for
|
||||
execution. Like any closure, the function passed to `spawn` may capture
|
||||
|
@ -1409,7 +1409,7 @@ pervasively in Rust code.
|
||||
|
||||
## Owned closures
|
||||
|
||||
Owned closures, written `~fn` in analogy to the `~` pointer type,
|
||||
Owned closures, written `proc`,
|
||||
hold on to things that can safely be sent between
|
||||
processes. They copy the values they close over, much like managed
|
||||
closures, but they also own them: that is, no other code can access
|
||||
@ -1484,7 +1484,7 @@ parentheses, where it looks more like a typical block of
|
||||
code.
|
||||
|
||||
`do` is a convenient way to create tasks with the `task::spawn`
|
||||
function. `spawn` has the signature `spawn(fn: ~fn())`. In other
|
||||
function. `spawn` has the signature `spawn(fn: proc())`. In other
|
||||
words, it is a function that takes an owned closure that takes no
|
||||
arguments.
|
||||
|
||||
|
@ -97,7 +97,7 @@ impl<T> TaskPool<T> {
|
||||
|
||||
#[test]
|
||||
fn test_task_pool() {
|
||||
let f: proc() -> proc(uint) -> uint = || {
|
||||
let f: &fn() -> proc(uint) -> uint = || {
|
||||
let g: proc(uint) -> uint = |i| i;
|
||||
g
|
||||
};
|
||||
|
@ -1101,7 +1101,7 @@ mod test {
|
||||
let handle2 = Cell::new(sched2.make_handle());
|
||||
let tasksFriendHandle = Cell::new(sched2.make_handle());
|
||||
|
||||
let on_exit: ~fn(UnwindResult) = |exit_status| {
|
||||
let on_exit: proc(UnwindResult) = |exit_status| {
|
||||
handle1.take().send(Shutdown);
|
||||
handle2.take().send(Shutdown);
|
||||
assert!(exit_status.is_success());
|
||||
@ -1115,7 +1115,7 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
let test_function: ~fn() = || {
|
||||
let test_function: proc() = || {
|
||||
let io = unsafe { local_io() };
|
||||
let addr = next_test_ip4();
|
||||
let maybe_socket = io.udp_bind(addr);
|
||||
|
@ -53,7 +53,7 @@ fn grandchild_group(num_tasks: uint) {
|
||||
// Master grandchild task exits early.
|
||||
}
|
||||
|
||||
fn spawn_supervised_blocking(myname: &str, f: ~fn()) {
|
||||
fn spawn_supervised_blocking(myname: &str, f: proc()) {
|
||||
let mut builder = task::task();
|
||||
let res = builder.future_result();
|
||||
builder.supervised();
|
||||
|
@ -11,7 +11,7 @@
|
||||
// xfail-test #2978
|
||||
|
||||
struct Foo {
|
||||
f: ~fn()
|
||||
f: proc()
|
||||
}
|
||||
|
||||
fn call(x: @Foo) {
|
||||
|
@ -1,13 +1,8 @@
|
||||
pub fn main() {
|
||||
let foo = ~3;
|
||||
let _pfoo = &foo;
|
||||
let _f: ~fn() -> int = || *foo + 5;
|
||||
//~^ ERROR cannot move `foo`
|
||||
|
||||
// FIXME(#2202) - Due to the way that borrowck treats closures,
|
||||
// you get two error reports here.
|
||||
let bar = ~3;
|
||||
let _g = || { //~ ERROR capture of moved value
|
||||
let _h: ~fn() -> int = || *bar; //~ ERROR capture of moved value
|
||||
let _h: proc() -> int = || *bar; //~ ERROR capture of moved value
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn call_f(f: ~fn:Send() -> int) -> int {
|
||||
fn call_f(f: proc() -> int) -> int {
|
||||
f()
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,10 @@
|
||||
// except according to those terms.
|
||||
|
||||
struct X {
|
||||
field: ~fn:Send(),
|
||||
field: &'static fn:Send(),
|
||||
}
|
||||
|
||||
fn foo(blk: ~fn:()) -> X {
|
||||
fn foo(blk: &'static fn:()) -> X {
|
||||
return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ fn foo(_x: @uint) {}
|
||||
|
||||
fn main() {
|
||||
let x = @3u;
|
||||
let _: ~fn() = || foo(x); //~ ERROR does not fulfill `Send`
|
||||
let _: ~fn() = || foo(x); //~ ERROR does not fulfill `Send`
|
||||
let _: ~fn() = || 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() = || foo(x); //~ ERROR does not fulfill `Send`
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ fn test<'a,T,U:Send>(_: &'a int) {
|
||||
|
||||
// but closure and object types can have lifetime bounds which make
|
||||
// them not ok (FIXME #5121)
|
||||
// assert_send::<~fn:'a()>(); // ERROR does not fulfill `Send`
|
||||
// assert_send::<proc:'a()>(); // ERROR does not fulfill `Send`
|
||||
// assert_send::<~Dummy:'a>(); // ERROR does not fulfill `Send`
|
||||
|
||||
// unsafe ptrs are ok unless they point at unsendable things
|
||||
|
@ -1,4 +1,4 @@
|
||||
type Noncopyable = ~fn();
|
||||
type Noncopyable = proc();
|
||||
|
||||
struct Foo {
|
||||
copied: int,
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Testing guarantees provided by once functions.
|
||||
// This program would segfault if it were legal.
|
||||
|
||||
extern mod extra;
|
||||
use extra::arc;
|
||||
use std::util;
|
||||
|
||||
fn foo(blk: ~fn()) {
|
||||
blk();
|
||||
blk();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = arc::Arc::new(true);
|
||||
do foo {
|
||||
assert!(*x.get());
|
||||
util::ignore(x); //~ ERROR cannot move out of captured outer variable
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
|
||||
// check that the &int here does not cause us to think that `foo`
|
||||
// contains region pointers
|
||||
struct foo(~fn(x: &int));
|
||||
struct foo(proc(x: &int));
|
||||
|
||||
fn take_foo(x: foo<'static>) {} //~ ERROR wrong number of lifetime parameters
|
||||
|
||||
|
@ -51,7 +51,7 @@ fn main() {
|
||||
zzz();
|
||||
sentinel();
|
||||
|
||||
let unique_closure: ~fn(int) = |x| {
|
||||
let unique_closure: proc(int) = |x| {
|
||||
zzz();
|
||||
sentinel();
|
||||
|
||||
|
@ -39,7 +39,7 @@ fn main() {
|
||||
|
||||
let owned = ~5;
|
||||
|
||||
let closure: ~fn() = || {
|
||||
let closure: proc() = || {
|
||||
zzz();
|
||||
do_something(&constant, &a_struct.a, owned);
|
||||
};
|
||||
|
@ -12,5 +12,5 @@
|
||||
|
||||
fn from_foreign_fn(_x: fn()) { }
|
||||
fn from_stack_closure(_x: ||) { }
|
||||
fn from_unique_closure(_x: ~fn()) { }
|
||||
fn from_unique_closure(_x: proc()) { }
|
||||
fn main() { }
|
||||
|
@ -18,7 +18,7 @@ fn failfn() {
|
||||
|
||||
fn main() {
|
||||
let y = ~0;
|
||||
let x: @~fn() = @(|| {
|
||||
let x: @proc() = @(|| {
|
||||
error!("{:?}", y.clone());
|
||||
});
|
||||
failfn();
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
extern mod extra;
|
||||
|
||||
fn asSendfn( f : ~fn()->uint ) -> uint {
|
||||
fn asSendfn( f : proc()->uint ) -> uint {
|
||||
return f();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
pub fn main() {
|
||||
let bar = ~3;
|
||||
let h: ~fn() -> int = || *bar;
|
||||
let h: proc() -> int = || *bar;
|
||||
assert_eq!(h(), 3);
|
||||
}
|
||||
|
@ -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: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
let snd_move: proc() -> uint = || 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: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
let lam_move: proc() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
assert_eq!(lam_move(), y);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ struct Pair {
|
||||
pub fn main() {
|
||||
let z = ~Pair { a : 10, b : 12};
|
||||
|
||||
let f: ~fn() = || {
|
||||
let f: proc() = || {
|
||||
assert_eq!(z.a, 10);
|
||||
assert_eq!(z.b, 12);
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
use std::comm;
|
||||
|
||||
fn foo(blk: ~fn:Send()) {
|
||||
fn foo(blk: proc()) {
|
||||
blk();
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@ extern mod extra;
|
||||
*
|
||||
* The hash should concentrate entropy in the lower bits.
|
||||
*/
|
||||
type HashFn<K> = ~fn(K) -> uint;
|
||||
type EqFn<K> = ~fn(K, K) -> bool;
|
||||
type HashFn<K> = proc(K) -> uint;
|
||||
type EqFn<K> = proc(K, K) -> bool;
|
||||
|
||||
struct LM { resize_at: uint, size: uint }
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
// xfail-test
|
||||
static generations: uint = 1024+256+128+49;
|
||||
|
||||
fn child_no(x: uint) -> ~fn() {
|
||||
fn child_no(x: uint) -> proc() {
|
||||
|| {
|
||||
if x < generations {
|
||||
task::spawn(child_no(x+1));
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// xfail-test
|
||||
type t = {
|
||||
f: ~fn()
|
||||
f: proc()
|
||||
};
|
||||
|
||||
pub fn main() {
|
||||
|
@ -17,7 +17,7 @@ use std::path::{Path};
|
||||
use std::path;
|
||||
use std::result;
|
||||
|
||||
type rsrc_loader = ~fn(path: &Path) -> result::Result<~str, ~str>;
|
||||
type rsrc_loader = proc(path: &Path) -> result::Result<~str, ~str>;
|
||||
|
||||
fn tester()
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ use std::comm::Chan;
|
||||
use std::task;
|
||||
|
||||
type RingBuffer = ~[f64];
|
||||
type SamplesFn = ~fn(samples: &RingBuffer);
|
||||
type SamplesFn = proc(samples: &RingBuffer);
|
||||
|
||||
enum Msg
|
||||
{
|
||||
|
@ -1,8 +0,0 @@
|
||||
fn run(f: &fn()) {
|
||||
f()
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let f: ~fn() = || ();
|
||||
run(f);
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
// Test that the lambda kind is inferred correctly as a return
|
||||
// expression
|
||||
|
||||
fn unique() -> ~fn() { return || (); }
|
||||
fn unique() -> proc() { return || (); }
|
||||
|
||||
pub fn main() {
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Test that the lambda kind is inferred correctly as a return
|
||||
// expression
|
||||
|
||||
fn unique() -> ~fn() { || () }
|
||||
fn unique() -> proc() { || () }
|
||||
|
||||
pub fn main() {
|
||||
}
|
||||
|
@ -69,6 +69,6 @@ pub fn main() {
|
||||
assert_eq!(q.y, !(p.y));
|
||||
|
||||
// Issue #1733
|
||||
let result: ~fn(int) = |_|();
|
||||
let result: proc(int) = |_|();
|
||||
result(p[true]);
|
||||
}
|
||||
|
@ -1,46 +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.
|
||||
|
||||
// xfail-fast
|
||||
|
||||
use std::task;
|
||||
|
||||
pub fn main() { test05(); }
|
||||
|
||||
#[deriving(Clone)]
|
||||
struct Pair<A,B> {
|
||||
a: A,
|
||||
b: B,
|
||||
}
|
||||
|
||||
fn make_generic_record<A,B>(a: A, b: B) -> Pair<A,B> {
|
||||
return Pair {a: a, b: b};
|
||||
}
|
||||
|
||||
fn test05_start(f: &~fn(v: f64, v: ~str) -> Pair<f64, ~str>) {
|
||||
let p = (*f)(22.22, ~"Hi");
|
||||
info!("{:?}", p.clone());
|
||||
assert!(p.a == 22.22);
|
||||
assert!(p.b == ~"Hi");
|
||||
|
||||
let q = (*f)(44.44, ~"Ho");
|
||||
info!("{:?}", q.clone());
|
||||
assert!(q.a == 44.44);
|
||||
assert!(q.b == ~"Ho");
|
||||
}
|
||||
|
||||
fn spawn<A,B>(f: extern fn(&~fn(A,B)->Pair<A,B>)) {
|
||||
let arg: ~fn(A, B) -> Pair<A,B> = |a, b| make_generic_record(a, b);
|
||||
task::spawn(|| f(&arg));
|
||||
}
|
||||
|
||||
fn test05() {
|
||||
spawn::<f64,~str>(test05_start);
|
||||
}
|
@ -13,13 +13,13 @@ use std::task;
|
||||
|
||||
pub fn main() { test05(); }
|
||||
|
||||
fn test05_start(f: ~fn(int)) {
|
||||
fn test05_start(f: proc(int)) {
|
||||
f(22);
|
||||
}
|
||||
|
||||
fn test05() {
|
||||
let three = ~3;
|
||||
let fn_to_send: ~fn(int) = |n| {
|
||||
let fn_to_send: proc(int) = |n| {
|
||||
error!("{}", *three + n); // will copy x into the closure
|
||||
assert_eq!(*three, 3);
|
||||
};
|
||||
|
@ -34,8 +34,8 @@ pub enum TestName {
|
||||
}
|
||||
|
||||
pub enum TestFn {
|
||||
DynTestFn(~fn()),
|
||||
DynBenchFn(~fn(&mut int))
|
||||
DynTestFn(proc()),
|
||||
DynBenchFn(proc(&mut int))
|
||||
}
|
||||
|
||||
pub struct TestDesc {
|
||||
|
@ -44,7 +44,7 @@ fn notify(ch: Chan<bool>, v: @mut bool) -> notify {
|
||||
}
|
||||
}
|
||||
|
||||
fn joinable(f: ~fn()) -> Port<bool> {
|
||||
fn joinable(f: proc()) -> Port<bool> {
|
||||
fn wrapper(c: Chan<bool>, f: &fn()) {
|
||||
let b = @mut false;
|
||||
error!("wrapper: task=%? allocated v=%x",
|
||||
|
@ -40,7 +40,7 @@ fn test_tempdir() {
|
||||
|
||||
fn test_rm_tempdir() {
|
||||
let (rd, wr) = stream();
|
||||
let f: ~fn() = || {
|
||||
let f: 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: ~fn() = || {
|
||||
let f: proc() = || {
|
||||
let _tmp = cell.take();
|
||||
fail!("fail to unwind past `tmp`");
|
||||
};
|
||||
@ -61,7 +61,7 @@ fn test_rm_tempdir() {
|
||||
|
||||
let path;
|
||||
{
|
||||
let f: ~fn() -> TempDir = || {
|
||||
let f: proc() -> TempDir = || {
|
||||
TempDir::new("test_rm_tempdir").unwrap()
|
||||
};
|
||||
let tmp = task::try(f).expect("test_rm_tmdir");
|
||||
|
@ -19,11 +19,11 @@ enum maybe_pointy {
|
||||
|
||||
struct Pointy {
|
||||
a : maybe_pointy,
|
||||
d : ~fn() -> uint,
|
||||
d : proc() -> uint,
|
||||
}
|
||||
|
||||
fn make_uniq_closure<A:Send>(a: A) -> ~fn() -> uint {
|
||||
let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
||||
fn make_uniq_closure<A:Send>(a: A) -> proc() -> uint {
|
||||
let result: proc() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
||||
result
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ enum maybe_pointy {
|
||||
struct Pointy {
|
||||
a : maybe_pointy,
|
||||
c : ~int,
|
||||
d : ~fn()->(),
|
||||
d : proc()->(),
|
||||
}
|
||||
|
||||
fn empty_pointy() -> @mut Pointy {
|
||||
|
Loading…
x
Reference in New Issue
Block a user