diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 15bddfc8022..9c8fdafe9ad 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -301,8 +301,8 @@ pub fn is_test(config: &config, testfile: &Path) -> bool { return valid; } -pub fn make_test(config: &config, testfile: &Path, - f: &fn()->test::TestFn) -> test::TestDescAndFn { +pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn) + -> test::TestDescAndFn { test::TestDescAndFn { desc: test::TestDesc { name: make_test_name(config, testfile), diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 2c01907d7fa..f722f873d5e 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -102,7 +102,7 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool { !val } -fn iter_header(testfile: &Path, it: &fn(&str) -> bool) -> bool { +fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool { use std::io::buffered::BufferedReader; use std::io::File; diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 035f0b83406..7104a506fcc 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -730,9 +730,12 @@ fn compose_and_run(config: &config, testfile: &Path, prog, args, procenv, input); } -fn make_compile_args(config: &config, props: &TestProps, extras: ~[~str], - xform: &fn(&config, (&Path)) -> Path, - testfile: &Path) -> ProcArgs { +fn make_compile_args(config: &config, + props: &TestProps, + extras: ~[~str], + xform: |&config, &Path| -> Path, + testfile: &Path) + -> ProcArgs { let xform_file = xform(config, testfile); // FIXME (#9639): This needs to handle non-utf8 paths let mut args = ~[testfile.as_str().unwrap().to_owned(), diff --git a/src/librustuv/addrinfo.rs b/src/librustuv/addrinfo.rs index 49782c62838..e90d320e723 100644 --- a/src/librustuv/addrinfo.rs +++ b/src/librustuv/addrinfo.rs @@ -120,7 +120,7 @@ impl Drop for Addrinfo { } } -fn each_ai_flag(_f: &fn(c_int, ai::Flag)) { +fn each_ai_flag(_f: |c_int, ai::Flag|) { /* XXX: do we really want to support these? unsafe { f(uvll::rust_AI_ADDRCONFIG(), ai::AddrConfig); diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index ceda5f22adb..a94ae695eb7 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -294,7 +294,7 @@ impl Drop for FsRequest { } } -fn execute(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int) +fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int) -> Result { let mut req = FsRequest { @@ -326,9 +326,8 @@ fn execute(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int) } } -fn execute_nop(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int) - -> Result<(), UvError> -{ +fn execute_nop(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int) + -> Result<(), UvError> { execute(f).map(|_| {}) } diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index e8ce8113033..4690a347f11 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -196,7 +196,7 @@ impl Drop for ForbidUnwind { } } -fn wait_until_woken_after(slot: *mut Option, f: &fn()) { +fn wait_until_woken_after(slot: *mut Option, f: ||) { let _f = ForbidUnwind::new("wait_until_woken_after"); unsafe { assert!((*slot).is_none()); diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index c009cc3998c..0e90e01c46a 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -34,7 +34,7 @@ use uvll::sockaddr; /// Generic functions related to dealing with sockaddr things //////////////////////////////////////////////////////////////////////////////// -fn socket_addr_as_sockaddr(addr: SocketAddr, f: &fn(*sockaddr) -> T) -> T { +fn socket_addr_as_sockaddr(addr: SocketAddr, f: |*sockaddr| -> T) -> T { let malloc = match addr.ip { Ipv4Addr(*) => uvll::rust_malloc_ip4_addr, Ipv6Addr(*) => uvll::rust_malloc_ip6_addr, diff --git a/src/librustuv/process.rs b/src/librustuv/process.rs index c537ee582cb..1ab84210fac 100644 --- a/src/librustuv/process.rs +++ b/src/librustuv/process.rs @@ -148,7 +148,7 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t, } /// Converts the program and arguments to the argv array expected by libuv -fn with_argv(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T { +fn with_argv(prog: &str, args: &[~str], f: |**libc::c_char| -> T) -> T { // First, allocation space to put all the C-strings (we need to have // ownership of them somewhere let mut c_strs = vec::with_capacity(args.len() + 1); @@ -167,7 +167,7 @@ fn with_argv(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T { } /// Converts the environment to the env array expected by libuv -fn with_env(env: Option<&[(~str, ~str)]>, f: &fn(**libc::c_char) -> T) -> T { +fn with_env(env: Option<&[(~str, ~str)]>, f: |**libc::c_char| -> T) -> T { let env = match env { Some(s) => s, None => { return f(ptr::null()); } diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 0ce3e56c29d..fbf81a6f3a0 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -161,7 +161,7 @@ impl EventLoop for UvEventLoop { ~AsyncWatcher::new(self.uvio.uv_loop(), f) as ~RemoteCallback } - fn io<'a>(&'a mut self, f: &fn(&'a mut IoFactory)) { + fn io<'a>(&'a mut self, f: |&'a mut IoFactory|) { f(&mut self.uvio as &mut IoFactory) } } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 3adedf76eb8..8e291ca6705 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -43,6 +43,7 @@ pub enum ObsoleteSyntax { ObsoleteStructWildcard, ObsoleteVecDotDotWildcard, ObsoleteBoxedClosure, + ObsoleteClosureType, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -134,6 +135,11 @@ impl ParserObsoleteMethods for Parser { "managed closures have been removed and owned closures are \ now written `proc()`" ), + ObsoleteClosureType => ( + "closure type", + "closures are now written `|A| -> B` rather than `&fn(A) -> \ + B`." + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7de8e3087c8..5db26dd99dd 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1286,7 +1286,7 @@ impl Parser { return self.parse_ty_closure(Some(sigil), Some(lifetime)); } - token::IDENT(*) if sigil == ast::BorrowedSigil => { + token::IDENT(*) => { if self.token_is_old_style_closure_keyword() { self.obsolete(*self.last_span, ObsoleteBoxedClosure); return self.parse_ty_closure(Some(sigil), None); @@ -1311,6 +1311,7 @@ impl Parser { let opt_lifetime = self.parse_opt_lifetime(); if self.token_is_old_style_closure_keyword() { + self.obsolete(*self.last_span, ObsoleteClosureType); return self.parse_ty_closure(Some(BorrowedSigil), opt_lifetime); } diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index 00eb31485b9..e5898b33e77 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -9,10 +9,10 @@ // except according to those terms. struct X { - field: &'static fn:Send(), + field: 'static ||:Send, } -fn foo(blk: &'static fn:()) -> X { +fn foo(blk: 'static ||:) -> X { return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds } diff --git a/src/test/compile-fail/once-cant-call-twice-on-stack.rs b/src/test/compile-fail/once-cant-call-twice-on-stack.rs index 9469d123d18..9cc69228c56 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-stack.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-stack.rs @@ -16,7 +16,7 @@ extern mod extra; use extra::arc; use std::util; -fn foo(blk: &once fn()) { +fn foo(blk: once ||) { blk(); blk(); //~ ERROR use of moved value } diff --git a/src/test/compile-fail/once-fn-subtyping.rs b/src/test/compile-fail/once-fn-subtyping.rs index 503b4d3e77b..3a0afd70e3e 100644 --- a/src/test/compile-fail/once-fn-subtyping.rs +++ b/src/test/compile-fail/once-fn-subtyping.rs @@ -10,8 +10,8 @@ #[feature(once_fns)]; fn main() { - let f: &once fn() = ||(); + let f: once || = ||(); let g: || = f; //~ ERROR mismatched types let h: || = ||(); - let i: &once fn() = h; // ok + let i: once || = h; // ok } diff --git a/src/test/run-pass/once-move-out-on-stack.rs b/src/test/run-pass/once-move-out-on-stack.rs index 8e340275d7f..645948f1426 100644 --- a/src/test/run-pass/once-move-out-on-stack.rs +++ b/src/test/run-pass/once-move-out-on-stack.rs @@ -17,7 +17,7 @@ extern mod extra; use extra::arc; use std::util; -fn foo(blk: &once fn()) { +fn foo(blk: once ||) { blk(); }