libsyntax: Remove the old-style borrowed closure type syntax from the
language.
This commit is contained in:
parent
9e610573ba
commit
6801bc8f55
@ -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),
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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);
|
||||
|
@ -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<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(|_| {})
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ impl Drop for ForbidUnwind {
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
|
@ -34,7 +34,7 @@ use uvll::sockaddr;
|
||||
/// 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,
|
||||
|
@ -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()); }
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ extern mod extra;
|
||||
use extra::arc;
|
||||
use std::util;
|
||||
|
||||
fn foo(blk: &once fn()) {
|
||||
fn foo(blk: once ||) {
|
||||
blk();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user