]> git.lizzy.rs Git - rust.git/commitdiff
libsyntax: Remove the old-style borrowed closure type syntax from the
authorPatrick Walton <pcwalton@mimiga.net>
Wed, 20 Nov 2013 02:15:10 +0000 (18:15 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 26 Nov 2013 16:20:59 +0000 (08:20 -0800)
language.

15 files changed:
src/compiletest/compiletest.rs
src/compiletest/header.rs
src/compiletest/runtest.rs
src/librustuv/addrinfo.rs
src/librustuv/file.rs
src/librustuv/lib.rs
src/librustuv/net.rs
src/librustuv/process.rs
src/librustuv/uvio.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
src/test/compile-fail/once-cant-call-twice-on-stack.rs
src/test/compile-fail/once-fn-subtyping.rs
src/test/run-pass/once-move-out-on-stack.rs

index 15bddfc80221c8379fc587fa75a40f27149fddc1..9c8fdafe9ad106acb26fa1fc05c70dd1871c6a68 100644 (file)
@@ -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),
index 2c01907d7fae1dcc0273becf62d980690b8ae96e..f722f873d5e675eb2b6c3ad5dab2fa45ebc6db80 100644 (file)
@@ -102,7 +102,7 @@ fn xfail_target(config: &config) -> ~str {
     !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;
 
index 035f0b83406df816eb4c0c1a1abb87587ead22c6..7104a506fccc5df3c76b5da272c0d9a029f33427 100644 (file)
@@ -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(),
index 49782c62838f8a43c2b4c363bb65d5f3d238da97..e90d320e72321297fb04edfbc39a42ed130c3242 100644 (file)
@@ -120,7 +120,7 @@ fn drop(&mut self) {
     }
 }
 
-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);
index ceda5f22adb1b71eff7c35e8b7aff7c35cf5f70d..a94ae695eb7438cdd731e4c54e119e89b479fea7 100644 (file)
@@ -294,7 +294,7 @@ fn drop(&mut self) {
     }
 }
 
-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<FsRequest, UvError>
 {
     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(|_| {})
 }
 
index e8ce8113033a9d8a4753ab84d3cd9f0fc33f69cc..4690a347f1143810a4a46b064b2551800969f71b 100644 (file)
@@ -196,7 +196,7 @@ fn drop(&mut self) {
     }
 }
 
-fn wait_until_woken_after(slot: *mut Option<BlockedTask>, f: &fn()) {
+fn wait_until_woken_after(slot: *mut Option<BlockedTask>, f: ||) {
     let _f = ForbidUnwind::new("wait_until_woken_after");
     unsafe {
         assert!((*slot).is_none());
index c009cc3998cab3bd21dd147d5676a42a92b30b87..0e90e01c46affa4221b590c8b7df7d5754ae505e 100644 (file)
@@ -34,7 +34,7 @@
 /// Generic functions related to dealing with sockaddr things
 ////////////////////////////////////////////////////////////////////////////////
 
-fn socket_addr_as_sockaddr<T>(addr: SocketAddr, f: &fn(*sockaddr) -> T) -> T {
+fn socket_addr_as_sockaddr<T>(addr: SocketAddr, f: |*sockaddr| -> T) -> T {
     let malloc = match addr.ip {
         Ipv4Addr(*) => uvll::rust_malloc_ip4_addr,
         Ipv6Addr(*) => uvll::rust_malloc_ip6_addr,
index c537ee582cb8d950b67cd7c1ab1235c50a2f2dfe..1ab84210face725d626e4195b3abaf1cdbe65f21 100644 (file)
@@ -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<T>(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T {
+fn with_argv<T>(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<T>(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T {
 }
 
 /// Converts the environment to the env array expected by libuv
-fn with_env<T>(env: Option<&[(~str, ~str)]>, f: &fn(**libc::c_char) -> T) -> T {
+fn with_env<T>(env: Option<&[(~str, ~str)]>, f: |**libc::c_char| -> T) -> T {
     let env = match env {
         Some(s) => s,
         None => { return f(ptr::null()); }
index 0ce3e56c29dfcc94bbc421fe0dfd0dfe1aa78b3f..fbf81a6f3a0946f45fbc99f4c7df4ddcaf61f980 100644 (file)
@@ -161,7 +161,7 @@ fn remote_callback(&mut self, f: ~Callback) -> ~RemoteCallback {
         ~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)
     }
 }
index 3adedf76eb840cfa97547c364483a6e06e96b967..8e291ca6705f3619a888bad331af527fe1287cb2 100644 (file)
@@ -43,6 +43,7 @@ pub enum ObsoleteSyntax {
     ObsoleteStructWildcard,
     ObsoleteVecDotDotWildcard,
     ObsoleteBoxedClosure,
+    ObsoleteClosureType,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -134,6 +135,11 @@ fn obsolete(&self, sp: Span, kind: ObsoleteSyntax) {
                 "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);
index 7de8e3087c8777e2738c36f9ee0903e83a4a93cb..5db26dd99dda68adc29f9d39ef23e7639872481d 100644 (file)
@@ -1286,7 +1286,7 @@ pub fn parse_box_or_uniq_pointee(&self,
                 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 @@ pub fn parse_borrowed_pointee(&self) -> ty_ {
         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);
         }
 
index 00eb31485b9d7af4bc367fd95a9e7e89187d2a13..e5898b33e7785305cbe929256dd8a0f3884d14ea 100644 (file)
@@ -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
 }
 
index 9469d123d18d7570f770f7fc96a202010dead3e8..9cc69228c56f5e83a303f6e5b5c1c08af60260d6 100644 (file)
@@ -16,7 +16,7 @@
 use extra::arc;
 use std::util;
 
-fn foo(blk: &once fn()) {
+fn foo(blk: once ||) {
     blk();
     blk(); //~ ERROR use of moved value
 }
index 503b4d3e77b978e5ea0a80fb8e25cbe57e4a8669..3a0afd70e3e7186eaaea56d515daf43286a34bbc 100644 (file)
@@ -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
 }
index 8e340275d7fdea09c544370a2b480227c8707ae7..645948f1426253053afa2cb964c7dc9db19941bb 100644 (file)
@@ -17,7 +17,7 @@
 use extra::arc;
 use std::util;
 
-fn foo(blk: &once fn()) {
+fn foo(blk: once ||) {
     blk();
 }