Skip to content

Commit 3b26855

Browse files
committed
libsyntax: Remove the old-style borrowed closure type syntax from the
language.
1 parent 5d57c24 commit 3b26855

15 files changed

+32
-23
lines changed

src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
301301
return valid;
302302
}
303303

304-
pub fn make_test(config: &config, testfile: &Path,
305-
f: &fn()->test::TestFn) -> test::TestDescAndFn {
304+
pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
305+
-> test::TestDescAndFn {
306306
test::TestDescAndFn {
307307
desc: test::TestDesc {
308308
name: make_test_name(config, testfile),

src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
102102
!val
103103
}
104104

105-
fn iter_header(testfile: &Path, it: &fn(&str) -> bool) -> bool {
105+
fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
106106
use std::io::buffered::BufferedReader;
107107
use std::io::File;
108108

src/compiletest/runtest.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,12 @@ fn compose_and_run(config: &config, testfile: &Path,
730730
prog, args, procenv, input);
731731
}
732732
733-
fn make_compile_args(config: &config, props: &TestProps, extras: ~[~str],
734-
xform: &fn(&config, (&Path)) -> Path,
735-
testfile: &Path) -> ProcArgs {
733+
fn make_compile_args(config: &config,
734+
props: &TestProps,
735+
extras: ~[~str],
736+
xform: |&config, &Path| -> Path,
737+
testfile: &Path)
738+
-> ProcArgs {
736739
let xform_file = xform(config, testfile);
737740
// FIXME (#9639): This needs to handle non-utf8 paths
738741
let mut args = ~[testfile.as_str().unwrap().to_owned(),

src/librustuv/addrinfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl Drop for Addrinfo {
120120
}
121121
}
122122

123-
fn each_ai_flag(_f: &fn(c_int, ai::Flag)) {
123+
fn each_ai_flag(_f: |c_int, ai::Flag|) {
124124
/* XXX: do we really want to support these?
125125
unsafe {
126126
f(uvll::rust_AI_ADDRCONFIG(), ai::AddrConfig);

src/librustuv/file.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl Drop for FsRequest {
295295
}
296296
}
297297

298-
fn execute(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int)
298+
fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
299299
-> Result<FsRequest, UvError>
300300
{
301301
return do task::unkillable {
@@ -329,9 +329,8 @@ fn execute(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int)
329329
}
330330
}
331331

332-
fn execute_nop(f: &fn(*uvll::uv_fs_t, uvll::uv_fs_cb) -> c_int)
333-
-> Result<(), UvError>
334-
{
332+
fn execute_nop(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
333+
-> Result<(), UvError> {
335334
execute(f).map(|_| {})
336335
}
337336

src/librustuv/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl Drop for ForbidUnwind {
196196
}
197197
}
198198

199-
fn wait_until_woken_after(slot: *mut Option<BlockedTask>, f: &fn()) {
199+
fn wait_until_woken_after(slot: *mut Option<BlockedTask>, f: ||) {
200200
let _f = ForbidUnwind::new("wait_until_woken_after");
201201
unsafe {
202202
assert!((*slot).is_none());

src/librustuv/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use uvll::sockaddr;
3535
/// Generic functions related to dealing with sockaddr things
3636
////////////////////////////////////////////////////////////////////////////////
3737

38-
fn socket_addr_as_sockaddr<T>(addr: SocketAddr, f: &fn(*sockaddr) -> T) -> T {
38+
fn socket_addr_as_sockaddr<T>(addr: SocketAddr, f: |*sockaddr| -> T) -> T {
3939
let malloc = match addr.ip {
4040
Ipv4Addr(*) => uvll::rust_malloc_ip4_addr,
4141
Ipv6Addr(*) => uvll::rust_malloc_ip6_addr,

src/librustuv/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
148148
}
149149

150150
/// Converts the program and arguments to the argv array expected by libuv
151-
fn with_argv<T>(prog: &str, args: &[~str], f: &fn(**libc::c_char) -> T) -> T {
151+
fn with_argv<T>(prog: &str, args: &[~str], f: |**libc::c_char| -> T) -> T {
152152
// First, allocation space to put all the C-strings (we need to have
153153
// ownership of them somewhere
154154
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 {
167167
}
168168

169169
/// Converts the environment to the env array expected by libuv
170-
fn with_env<T>(env: Option<&[(~str, ~str)]>, f: &fn(**libc::c_char) -> T) -> T {
170+
fn with_env<T>(env: Option<&[(~str, ~str)]>, f: |**libc::c_char| -> T) -> T {
171171
let env = match env {
172172
Some(s) => s,
173173
None => { return f(ptr::null()); }

src/librustuv/uvio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl EventLoop for UvEventLoop {
171171
~AsyncWatcher::new(self.uvio.uv_loop(), f) as ~RemoteCallback
172172
}
173173

174-
fn io<'a>(&'a mut self, f: &fn(&'a mut IoFactory)) {
174+
fn io<'a>(&'a mut self, f: |&'a mut IoFactory|) {
175175
f(&mut self.uvio as &mut IoFactory)
176176
}
177177
}

src/libsyntax/parse/obsolete.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub enum ObsoleteSyntax {
4343
ObsoleteStructWildcard,
4444
ObsoleteVecDotDotWildcard,
4545
ObsoleteBoxedClosure,
46+
ObsoleteClosureType,
4647
}
4748

4849
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -134,6 +135,11 @@ impl ParserObsoleteMethods for Parser {
134135
"managed closures have been removed and owned closures are \
135136
now written `proc()`"
136137
),
138+
ObsoleteClosureType => (
139+
"closure type",
140+
"closures are now written `|A| -> B` rather than `&fn(A) -> \
141+
B`."
142+
),
137143
};
138144

139145
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ impl Parser {
12861286
return self.parse_ty_closure(Some(sigil), Some(lifetime));
12871287
}
12881288

1289-
token::IDENT(*) if sigil == ast::BorrowedSigil => {
1289+
token::IDENT(*) => {
12901290
if self.token_is_old_style_closure_keyword() {
12911291
self.obsolete(*self.last_span, ObsoleteBoxedClosure);
12921292
return self.parse_ty_closure(Some(sigil), None);
@@ -1311,6 +1311,7 @@ impl Parser {
13111311
let opt_lifetime = self.parse_opt_lifetime();
13121312

13131313
if self.token_is_old_style_closure_keyword() {
1314+
self.obsolete(*self.last_span, ObsoleteClosureType);
13141315
return self.parse_ty_closure(Some(BorrowedSigil), opt_lifetime);
13151316
}
13161317

src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// except according to those terms.
1010

1111
struct X {
12-
field: &'static fn:Send(),
12+
field: 'static ||:Send,
1313
}
1414

15-
fn foo(blk: &'static fn:()) -> X {
15+
fn foo(blk: 'static ||:) -> X {
1616
return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds
1717
}
1818

src/test/compile-fail/once-cant-call-twice-on-stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern mod extra;
1616
use extra::arc;
1717
use std::util;
1818

19-
fn foo(blk: &once fn()) {
19+
fn foo(blk: once ||) {
2020
blk();
2121
blk(); //~ ERROR use of moved value
2222
}

src/test/compile-fail/once-fn-subtyping.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
#[feature(once_fns)];
1212
fn main() {
13-
let f: &once fn() = ||();
13+
let f: once || = ||();
1414
let g: || = f; //~ ERROR mismatched types
1515
let h: || = ||();
16-
let i: &once fn() = h; // ok
16+
let i: once || = h; // ok
1717
}

src/test/run-pass/once-move-out-on-stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern mod extra;
1717
use extra::arc;
1818
use std::util;
1919

20-
fn foo(blk: &once fn()) {
20+
fn foo(blk: once ||) {
2121
blk();
2222
}
2323

0 commit comments

Comments
 (0)