diff options
| author | bors <bors@rust-lang.org> | 2013-03-02 19:18:37 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-02 19:18:37 -0800 |
| commit | 5655ae46a73723203edcf6a53c87560e0da7aaec (patch) | |
| tree | a7c5ca21cf001ff1847c16016822a4965f8d7758 /src/libstd | |
| parent | 826644e8cb37363a4e44561a498e79acfeb77b6a (diff) | |
| parent | ccec510f392d5017a1da37c6b8327b5201dffd2a (diff) | |
| download | rust-5655ae46a73723203edcf6a53c87560e0da7aaec.tar.gz rust-5655ae46a73723203edcf6a53c87560e0da7aaec.zip | |
auto merge of #5197 : pcwalton/rust/fn-types, r=pcwalton
r? @catamorphism
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/bigint.rs | 2 | ||||
| -rw-r--r-- | src/libstd/c_vec.rs | 6 | ||||
| -rw-r--r-- | src/libstd/flatpipes.rs | 4 | ||||
| -rw-r--r-- | src/libstd/future.rs | 6 | ||||
| -rw-r--r-- | src/libstd/net_tcp.rs | 18 | ||||
| -rw-r--r-- | src/libstd/par.rs | 27 | ||||
| -rw-r--r-- | src/libstd/semver.rs | 14 | ||||
| -rw-r--r-- | src/libstd/std.rc | 2 | ||||
| -rw-r--r-- | src/libstd/test.rs | 27 | ||||
| -rw-r--r-- | src/libstd/timer.rs | 2 | ||||
| -rw-r--r-- | src/libstd/uv_global_loop.rs | 20 | ||||
| -rw-r--r-- | src/libstd/uv_iotask.rs | 5 | ||||
| -rw-r--r-- | src/libstd/workcache.rs | 2 |
13 files changed, 68 insertions, 67 deletions
diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 23a4769775c..5212a17f373 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -865,7 +865,7 @@ pub impl BigInt { mod biguint_tests { use core::*; - use num::{IntConvertible, Zero, One}; + use core::num::{IntConvertible, Zero, One}; use super::{BigInt, BigUint, BigDigit}; #[test] diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 5af596c1f84..30538a12942 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -53,7 +53,7 @@ pub struct CVec<T> { } struct DtorRes { - dtor: Option<fn@()>, + dtor: Option<@fn()>, } impl Drop for DtorRes { @@ -65,7 +65,7 @@ impl Drop for DtorRes { } } -fn DtorRes(dtor: Option<fn@()>) -> DtorRes { +fn DtorRes(dtor: Option<@fn()>) -> DtorRes { DtorRes { dtor: dtor } @@ -102,7 +102,7 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { * * dtor - A function to run when the value is destructed, useful * for freeing the buffer, etc. */ -pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) +pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn()) -> CVec<T> { return CVec{ base: base, diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 73dbe4bea57..42f954f7c39 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -771,10 +771,10 @@ mod test { writer_chan: WriterChanFactory<F>, port: uint) { - use net::tcp; + use core::cell::Cell; use net::ip; - use cell::Cell; use net::tcp::TcpSocket; + use net::tcp; use uv; // Indicate to the client task that the server is listening diff --git a/src/libstd/future.rs b/src/libstd/future.rs index c5775406125..990c37ce807 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -37,13 +37,13 @@ pub struct Future<A> { } // FIXME(#2829) -- futures should not be copyable, because they close -// over fn~'s that have pipes and so forth within! +// over ~fn's that have pipes and so forth within! impl<A> Drop for Future<A> { fn finalize(&self) {} } priv enum FutureState<A> { - Pending(fn~() -> A), + Pending(~fn() -> A), Evaluating, Forced(A) } @@ -125,7 +125,7 @@ pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> { Future {state: Pending(f)} } -pub fn spawn<A:Owned>(blk: fn~() -> A) -> Future<A> { +pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> { /*! * Create a future from a unique closure. * diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 4266cab0a05..5b116705698 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -625,8 +625,8 @@ pub fn accept(new_conn: TcpNewConnection) */ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: &IoTask, - on_establish_cb: fn~(SharedChan<Option<TcpErrData>>), - new_connect_cb: fn~(TcpNewConnection, + on_establish_cb: ~fn(SharedChan<Option<TcpErrData>>), + new_connect_cb: ~fn(TcpNewConnection, SharedChan<Option<TcpErrData>>)) -> result::Result<(), TcpListenErrData> { do listen_common(host_ip, port, backlog, iotask, @@ -643,11 +643,13 @@ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, } } -fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint, - iotask: &IoTask, - on_establish_cb: fn~(SharedChan<Option<TcpErrData>>), - on_connect_cb: fn~(*uv::ll::uv_tcp_t)) - -> result::Result<(), TcpListenErrData> { +fn listen_common(host_ip: ip::IpAddr, + port: uint, + backlog: uint, + iotask: &IoTask, + on_establish_cb: ~fn(SharedChan<Option<TcpErrData>>), + on_connect_cb: ~fn(*uv::ll::uv_tcp_t)) + -> result::Result<(), TcpListenErrData> { unsafe { let (stream_closed_po, stream_closed_ch) = stream::<()>(); let stream_closed_ch = SharedChan(stream_closed_ch); @@ -1197,7 +1199,7 @@ struct TcpListenFcData { server_stream_ptr: *uv::ll::uv_tcp_t, stream_closed_ch: SharedChan<()>, kill_ch: SharedChan<Option<TcpErrData>>, - on_connect_cb: fn~(*uv::ll::uv_tcp_t), + on_connect_cb: ~fn(*uv::ll::uv_tcp_t), iotask: IoTask, ipv6: bool, mut active: bool, diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 0839ce18123..d65921f910c 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -94,24 +94,24 @@ pub fn map<A:Copy + Owned,B:Copy + Owned>( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { let f = fn_factory(); - fn~(_base: uint, slice : &[A]) -> ~[B] { - vec::map(slice, |x| f(x)) - } + let result: ~fn(uint, &[A]) -> ~[B] = + |_, slice| vec::map(slice, |x| f(x)); + result })) } /// A parallel version of mapi. pub fn mapi<A:Copy + Owned,B:Copy + Owned>( - xs: &[A], - fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] -{ + xs: &[A], + fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] { let slices = map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A]) -> ~[B] { + let result: ~fn(uint, &[A]) -> ~[B] = |base, slice| { vec::mapi(slice, |i, x| { f(i + base, x) }) - } + }; + result }); let r = vec::concat(slices); log(info, (r.len(), xs.len())); @@ -126,11 +126,12 @@ pub fn alli<A:Copy + Owned>( { do vec::all(map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A]) -> bool { + let result: ~fn(uint, &[A]) -> bool = |base, slice| { vec::alli(slice, |i, x| { f(i + base, x) }) - } + }; + result })) |x| { *x } } @@ -140,8 +141,8 @@ pub fn any<A:Copy + Owned>( fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { let f = fn_factory(); - fn~(_base : uint, slice: &[A]) -> bool { - vec::any(slice, |x| f(x)) - } + let result: ~fn(uint, &[A]) -> bool = + |_, slice| vec::any(slice, |x| f(x)); + result })) |x| { *x } } diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index 5f96687127c..7c7f3390f2e 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -10,14 +10,14 @@ //! Semver parsing and logic -use io; -use io::{ReaderUtil}; -use option::{Option, Some, None}; -use uint; -use str; -use to_str::ToStr; -use char; +use core::char; use core::cmp; +use core::io::{ReaderUtil}; +use core::io; +use core::option::{Option, Some, None}; +use core::str; +use core::to_str::ToStr; +use core::uint; #[deriving_eq] pub enum Identifier { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 2f6c4e3f190..f29872bf387 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -113,7 +113,7 @@ pub mod serialize; // 'std' so that macro-expanded references to std::serialize and such // can be resolved within libcore. #[doc(hidden)] // FIXME #3538 -mod std { +pub mod std { pub use serialize; pub use test; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 49a8dff4a96..4ffa9b01d2b 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -409,7 +409,7 @@ type MonitorMsg = (TestDesc, TestResult); fn run_tests(opts: &TestOpts, tests: ~[TestDescAndFn], - callback: fn@(e: TestEvent)) { + callback: @fn(e: TestEvent)) { let mut filtered_tests = filter_tests(opts, tests); let filtered_descs = filtered_tests.map(|t| t.desc); @@ -537,7 +537,7 @@ pub fn filter_tests( struct TestFuture { test: TestDesc, - wait: fn@() -> TestResult, + wait: @fn() -> TestResult, } pub fn run_test(force_ignore: bool, @@ -594,15 +594,14 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult { } pub mod bench { - - use rand; - use u64; - use vec; use time::precise_time_ns; use test::{BenchHarness, BenchSamples}; use stats::Stats; - use num; - use rand; + + use core::num; + use core::rand; + use core::u64; + use core::vec; pub impl BenchHarness { @@ -783,7 +782,7 @@ mod tests { ignore: true, should_fail: false }, - testfn: DynTestFn(fn~() { f()}), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -801,7 +800,7 @@ mod tests { ignore: true, should_fail: false }, - testfn: DynTestFn(fn~() { f()}), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -820,7 +819,7 @@ mod tests { ignore: false, should_fail: true }, - testfn: DynTestFn(fn~() { f() }), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -838,7 +837,7 @@ mod tests { ignore: false, should_fail: true }, - testfn: DynTestFn(fn~() { f() }), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -891,7 +890,7 @@ mod tests { ignore: true, should_fail: false, }, - testfn: DynTestFn(fn~() { }), + testfn: DynTestFn(|| {}), }, TestDescAndFn { desc: TestDesc { @@ -899,7 +898,7 @@ mod tests { ignore: false, should_fail: false }, - testfn: DynTestFn(fn~() { }), + testfn: DynTestFn(|| {}), }, ]; let filtered = filter_tests(&opts, tests); diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index b711825aecf..7bd411315b2 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -221,7 +221,7 @@ mod test { let ch = ch.clone(); let hl_loop_clone = hl_loop.clone(); do task::spawn { - use rand::*; + use core::rand::*; let rng = Rng(); for iter::repeat(times) { sleep(&hl_loop_clone, rng.next() as uint % maxms); diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 52cfc078bac..daf90f345e0 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -12,21 +12,20 @@ use ll = uv_ll; use iotask = uv_iotask; -use get_gl = get; +use get_gl = self::get; use uv_iotask::{IoTask, spawn_iotask}; +use core::clone::Clone; +use core::comm::{Port, Chan, SharedChan, select2i}; use core::either::{Left, Right}; use core::libc; -use core::comm::{Port, Chan, SharedChan, select2i}; -use core::unstable::global::{global_data_clone_create, - global_data_clone}; -use core::unstable::weak_task::weaken_task; +use core::option::{Some, None}; use core::str; use core::task::{task, SingleThreaded, spawn}; use core::task; +use core::unstable::global::{global_data_clone_create, global_data_clone}; +use core::unstable::weak_task::weaken_task; use core::vec; -use core::clone::Clone; -use core::option::{Some, None}; /** * Race-free helper to get access to a global task where a libuv @@ -98,7 +97,7 @@ fn get_monitor_task_gl() -> IoTask { fn spawn_loop() -> IoTask { let builder = do task().add_wrapper |task_body| { - fn~() { + let result: ~fn() = || { // The I/O loop task also needs to be weak so it doesn't keep // the runtime alive unsafe { @@ -113,7 +112,8 @@ fn spawn_loop() -> IoTask { debug!("global libuv task is leaving weakened state"); } } - } + }; + result }; let builder = builder.unlinked(); spawn_iotask(builder) @@ -123,7 +123,7 @@ fn spawn_loop() -> IoTask { mod test { use core::prelude::*; - use get_gl = get; + use get_gl = uv_global_loop::get; use uv::iotask; use uv::ll; use uv_global_loop::*; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 14726a0854d..6179b10f3c3 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -76,8 +76,7 @@ pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask { * module. It is not safe to send the `loop_ptr` param to this callback out * via ports/chans. */ -pub unsafe fn interact(iotask: &IoTask, - cb: fn~(*c_void)) { +pub unsafe fn interact(iotask: &IoTask, cb: ~fn(*c_void)) { send_msg(iotask, Interaction(cb)); } @@ -98,7 +97,7 @@ pub fn exit(iotask: &IoTask) { // INTERNAL API enum IoTaskMsg { - Interaction (fn~(*libc::c_void)), + Interaction(~fn(*libc::c_void)), TeardownLoop } diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 592ac40e082..7f47db37504 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -396,7 +396,7 @@ fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>( //#[test] fn test() { - use io::WriterUtil; + use core::io::WriterUtil; let db = @Mut(Database { db_filename: Path("db.json"), db_cache: LinearMap::new(), |
