librustc: Make the default sigil for block lambdas &
instead of @
.
This commit is contained in:
parent
bd6536f868
commit
84825ee310
@ -608,7 +608,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
|
||||
};
|
||||
if result {
|
||||
// Unwinding function in case any ancestral enlisting fails
|
||||
let bail = |tg: TaskGroupInner| {
|
||||
let bail: @fn(TaskGroupInner) = |tg| {
|
||||
leave_taskgroup(tg, child, false)
|
||||
};
|
||||
// Attempt to join every ancestor group.
|
||||
|
@ -66,10 +66,10 @@ export encode_def_id;
|
||||
|
||||
type abbrev_map = map::HashMap<ty::t, tyencode::ty_abbrev>;
|
||||
|
||||
type encode_inlined_item = fn@(ecx: @encode_ctxt,
|
||||
ebml_w: writer::Encoder,
|
||||
path: ast_map::path,
|
||||
ii: ast::inlined_item);
|
||||
pub type encode_inlined_item = fn@(ecx: @encode_ctxt,
|
||||
ebml_w: writer::Encoder,
|
||||
path: ast_map::path,
|
||||
ii: ast::inlined_item);
|
||||
|
||||
type encode_parms = {
|
||||
diag: span_handler,
|
||||
@ -572,7 +572,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
|
||||
index: @mut ~[entry<int>]) {
|
||||
index.push({val: item.id, pos: ebml_w.writer.tell()});
|
||||
}
|
||||
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
|
||||
let add_to_index: &fn() = || add_to_index_(item, ebml_w, index);
|
||||
|
||||
debug!("encoding info for item at %s",
|
||||
ecx.tcx.sess.codemap.span_to_str(item.span));
|
||||
|
@ -30,6 +30,7 @@ use syntax::ast_map::{node_item, node_method};
|
||||
use syntax::ast_map;
|
||||
use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local};
|
||||
use syntax::ast_util::{visibility_to_privacy};
|
||||
use syntax::codemap::span;
|
||||
use syntax::visit;
|
||||
|
||||
fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
|
||||
@ -37,7 +38,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
|
||||
let legacy_exports = has_legacy_export_attr(crate.node.attrs);
|
||||
|
||||
// Adds structs that are privileged to this scope.
|
||||
let add_privileged_items = |items: &[@ast::item]| {
|
||||
let add_privileged_items: @fn(&[@ast::item]) -> int = |items| {
|
||||
let mut count = 0;
|
||||
for items.each |item| {
|
||||
match item.node {
|
||||
@ -53,7 +54,8 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
|
||||
};
|
||||
|
||||
// Checks that an enum variant is in scope
|
||||
let check_variant = |span, enum_id| {
|
||||
let check_variant: @fn(span: span, enum_id: ast::def_id) =
|
||||
|span, enum_id| {
|
||||
let variant_info = ty::enum_variants(tcx, enum_id)[0];
|
||||
let parental_privacy = if is_local(enum_id) {
|
||||
let parent_vis = ast_map::node_item_query(tcx.items, enum_id.node,
|
||||
@ -81,7 +83,8 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
|
||||
};
|
||||
|
||||
// Checks that a private field is in scope.
|
||||
let check_field = |span, id, ident| {
|
||||
let check_field: @fn(span: span, id: ast::def_id, ident: ast::ident) =
|
||||
|span, id, ident| {
|
||||
let fields = ty::lookup_struct_fields(tcx, id);
|
||||
for fields.each |field| {
|
||||
if field.ident != ident { loop; }
|
||||
@ -95,7 +98,8 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
|
||||
};
|
||||
|
||||
// Checks that a private method is in scope.
|
||||
let check_method = |span, origin: &method_origin| {
|
||||
let check_method: @fn(span: span, origin: &method_origin) =
|
||||
|span, origin| {
|
||||
match *origin {
|
||||
method_static(method_id) => {
|
||||
if method_id.crate == local_crate {
|
||||
|
@ -1610,8 +1610,9 @@ fn trans_match_inner(scope_cx: block,
|
||||
if ty::type_is_empty(tcx, t) {
|
||||
// Special case for empty types
|
||||
let fail_cx = @mut None;
|
||||
Some(|| mk_fail(scope_cx, discr_expr.span,
|
||||
~"scrutinizing value that can't exist", fail_cx))
|
||||
let f: mk_fail = || mk_fail(scope_cx, discr_expr.span,
|
||||
~"scrutinizing value that can't exist", fail_cx);
|
||||
Some(f)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -2867,7 +2867,7 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
|
||||
|
||||
fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) -> encoder::encode_parms {
|
||||
// XXX: Bad copy of `c`, whatever it is.
|
||||
let encode_inlined_item =
|
||||
let encode_inlined_item: encoder::encode_inlined_item =
|
||||
|a,b,c,d| astencode::encode_inlined_item(a, b, copy c, d, cx.maps);
|
||||
|
||||
return {
|
||||
|
@ -427,24 +427,23 @@ fn trans_expr_fn(bcx: block,
|
||||
~"expr_fn");
|
||||
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);
|
||||
|
||||
// XXX: Bad copies.
|
||||
let trans_closure_env = |proto, copy body, copy sub_path, copy decl| {
|
||||
let trans_closure_env: &fn(ast::Proto) -> Result = |proto| {
|
||||
let cap_vars = capture::compute_capture_vars(ccx.tcx, user_id, proto,
|
||||
cap_clause);
|
||||
let ret_handle = match is_loop_body { Some(x) => x, None => None };
|
||||
// XXX: Bad copy.
|
||||
let {llbox, cdata_ty, bcx} = build_closure(bcx, copy cap_vars, proto,
|
||||
ret_handle);
|
||||
trans_closure(ccx, /*bad*/copy sub_path, decl, body, llfn, no_self,
|
||||
/*bad*/copy bcx.fcx.param_substs, user_id, None,
|
||||
|fcx| {
|
||||
load_environment(fcx, cdata_ty, copy cap_vars,
|
||||
ret_handle.is_some(), proto);
|
||||
trans_closure(ccx, /*bad*/copy sub_path, decl, /*bad*/copy body,
|
||||
llfn, no_self, /*bad*/copy bcx.fcx.param_substs,
|
||||
user_id, None, |fcx| {
|
||||
load_environment(fcx, cdata_ty, copy cap_vars,
|
||||
ret_handle.is_some(), proto);
|
||||
}, |bcx| {
|
||||
if is_loop_body.is_some() {
|
||||
Store(bcx, C_bool(true), bcx.fcx.llretptr);
|
||||
}
|
||||
});
|
||||
if is_loop_body.is_some() {
|
||||
Store(bcx, C_bool(true), bcx.fcx.llretptr);
|
||||
}
|
||||
});
|
||||
rslt(bcx, llbox)
|
||||
};
|
||||
|
||||
|
@ -444,8 +444,14 @@ fn add_clean_temp_mem(bcx: block, val: ValueRef, t: ty::t) {
|
||||
}
|
||||
fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
|
||||
let free_fn = match heap {
|
||||
heap_shared => |a| glue::trans_free(a, ptr),
|
||||
heap_exchange => |a| glue::trans_unique_free(a, ptr)
|
||||
heap_shared => {
|
||||
let f: @fn(block) -> block = |a| glue::trans_free(a, ptr);
|
||||
f
|
||||
}
|
||||
heap_exchange => {
|
||||
let f: @fn(block) -> block = |a| glue::trans_unique_free(a, ptr);
|
||||
f
|
||||
}
|
||||
};
|
||||
do in_scope_cx(cx) |scope_info| {
|
||||
scope_info.cleanups.push(clean_temp(ptr, free_fn,
|
||||
|
@ -153,7 +153,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
~[path_name((ccx.names)(ccx.sess.str_of(name)))]);
|
||||
let s = mangle_exported_name(ccx, /*bad*/copy pt, mono_ty);
|
||||
|
||||
let mk_lldecl = |/*bad*/copy s| {
|
||||
let mk_lldecl = || {
|
||||
let lldecl = decl_internal_cdecl_fn(ccx.llmod, /*bad*/copy s, llfty);
|
||||
ccx.monomorphized.insert(hash_id, lldecl);
|
||||
lldecl
|
||||
|
@ -1561,7 +1561,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
fn_ty.meta.onceness)
|
||||
}
|
||||
_ => {
|
||||
(None, ast::impure_fn, ast::ProtoBox, ast::Many)
|
||||
(None, ast::impure_fn, ast::ProtoBorrowed, ast::Many)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -58,8 +58,9 @@ fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
|
||||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr =
|
||||
|e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| {
|
||||
let visit_expr: @fn(@ast::expr,
|
||||
&&flag: @mut bool,
|
||||
v: visit::vt<@mut bool>) = |e, &&flag, v| {
|
||||
*flag |= p(e.node);
|
||||
match e.node {
|
||||
// Skip inner loops, since a break in the inner loop isn't a
|
||||
@ -80,8 +81,9 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
|
||||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
fn block_query(b: ast::blk, p: fn@(@ast::expr) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr =
|
||||
|e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| {
|
||||
let visit_expr: @fn(@ast::expr,
|
||||
&&flag: @mut bool,
|
||||
v: visit::vt<@mut bool>) = |e, &&flag, v| {
|
||||
*flag |= p(e);
|
||||
visit::visit_expr(e, flag, v)
|
||||
};
|
||||
|
@ -213,7 +213,9 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
|
||||
fn collect(messages: @DVec<~str>)
|
||||
-> fn@(Option<(@codemap::CodeMap, span)>, &str, level)
|
||||
{
|
||||
|_o, msg: &str, _l| { messages.push(msg.to_str()); }
|
||||
let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) =
|
||||
|_o, msg: &str, _l| { messages.push(msg.to_str()); };
|
||||
f
|
||||
}
|
||||
|
||||
fn emit(cmsp: Option<(@codemap::CodeMap, span)>, msg: &str, lvl: level) {
|
||||
|
@ -136,8 +136,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
|
||||
cx.span_fatal(best_fail_spot, best_fail_msg);
|
||||
}
|
||||
|
||||
let exp = |cx, sp, arg| generic_extension(cx, sp, name,
|
||||
arg, lhses, rhses);
|
||||
let exp: @fn(ext_ctxt, span, ~[ast::token_tree]) -> mac_result =
|
||||
|cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses);
|
||||
|
||||
return mr_def({
|
||||
name: *cx.parse_sess().interner.get(name),
|
||||
|
@ -641,7 +641,8 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
f(fk, decl, body, sp, id);
|
||||
visit_fn(fk, decl, body, sp, id, e, v);
|
||||
}
|
||||
let visit_ty = |a,b,c| v_ty(v.visit_ty, a, b, c);
|
||||
let visit_ty: @fn(@Ty, &&x: (), vt<()>) =
|
||||
|a,b,c| v_ty(v.visit_ty, a, b, c);
|
||||
fn v_struct_field(f: fn@(@struct_field), sf: @struct_field, &&e: (),
|
||||
v: vt<()>) {
|
||||
f(sf);
|
||||
|
@ -13,7 +13,7 @@ fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint {
|
||||
}
|
||||
|
||||
fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint {
|
||||
return to_lambda1({|x| b(x)}); //~ ERROR illegal move from argument `b`
|
||||
return to_lambda1(|x| b(x)); //~ ERROR illegal move from argument `b`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type t<T> = { f: fn() -> T };
|
||||
|
||||
fn f<T>(_x: t<T>) {}
|
||||
|
||||
fn main() {
|
||||
let x: t<()> = { f: { || () } }; //~ ERROR expected & closure, found @ closure
|
||||
//~^ ERROR in field `f`, expected & closure, found @ closure
|
||||
f(x);
|
||||
}
|
@ -21,5 +21,7 @@ impl<A> ~[A]: vec_monad<A> {
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
["hi"].bind({|x| [x] }); //~ ERROR type `[&static/str]/1` does not implement any method in scope named `bind`
|
||||
["hi"].bind(|x| [x] );
|
||||
//~^ ERROR type `[&static/str]/1` does not implement any method in scope named `bind`
|
||||
//~^^ ERROR Unconstrained region variable
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ fn f(a: @int) {
|
||||
|
||||
fn main() {
|
||||
let b = @0;
|
||||
let g = {|move b|f(b)};
|
||||
let g : fn@() = |move b|f(b);
|
||||
g();
|
||||
}
|
@ -8,13 +8,13 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type foo = { mut z : fn@() };
|
||||
struct foo { mut z : fn@() }
|
||||
|
||||
fn nop() { }
|
||||
fn nop_foo(_x : @foo) { }
|
||||
|
||||
fn main() {
|
||||
let w = @{ mut z: {||nop()} };
|
||||
let x = {||nop_foo(w)};
|
||||
let w = @foo{ mut z: || nop() };
|
||||
let x : fn@() = || nop_foo(w);
|
||||
w.z = x;
|
||||
}
|
@ -8,13 +8,13 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type foo = { mut z : fn@() };
|
||||
struct foo { mut z : fn@() }
|
||||
|
||||
fn nop() { }
|
||||
fn nop_foo(_y: ~[int], _x : @foo) { }
|
||||
|
||||
fn main() {
|
||||
let w = @{ mut z: {||nop()} };
|
||||
let x = {||nop_foo(~[], w)};
|
||||
let w = @foo{ z: || nop() };
|
||||
let x : fn@() = || nop_foo(~[], w);
|
||||
w.z = x;
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
type foo = { mut z : fn@() };
|
||||
struct foo { mut z : fn@() }
|
||||
|
||||
fn nop() { }
|
||||
fn nop_foo(_y: @int, _x : @foo) { }
|
||||
@ -16,7 +16,7 @@ fn nop_foo(_y: @int, _x : @foo) { }
|
||||
fn o() -> @int { @10 }
|
||||
|
||||
fn main() {
|
||||
let w = @{ mut z: {||nop()} };
|
||||
let x = {||nop_foo(o(), w)};
|
||||
let w = @foo { mut z: || nop() };
|
||||
let x : fn@() = || nop_foo(o(), w);
|
||||
w.z = x;
|
||||
}
|
@ -12,11 +12,11 @@
|
||||
#[legacy_modes];
|
||||
|
||||
fn fix_help<A, B>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
|
||||
return f({|a|fix_help(f, a)}, x);
|
||||
return f( |a| fix_help(f, a), x);
|
||||
}
|
||||
|
||||
fn fix<A, B>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
||||
return {|a|fix_help(f, a)};
|
||||
return |a| fix_help(f, a);
|
||||
}
|
||||
|
||||
fn fact_(f: fn@(&&v: int) -> int, &&n: int) -> int {
|
||||
|
@ -12,11 +12,11 @@
|
||||
#[legacy_modes];
|
||||
|
||||
fn fix_help<A: &static, B: Owned>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
|
||||
return f({|a|fix_help(f, a)}, x);
|
||||
return f(|a| fix_help(f, a), x);
|
||||
}
|
||||
|
||||
fn fix<A: &static, B: Owned>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
||||
return {|a|fix_help(f, a)};
|
||||
return |a| fix_help(f, a);
|
||||
}
|
||||
|
||||
fn fact_(f: fn@(&&v: int) -> int, &&n: int) -> int {
|
||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||
// Ensure function arguments and box arguments interact sanely.
|
||||
fn call_me(x: fn() -> int, y: ~int) { assert x() == *y; }
|
||||
let q = ~30;
|
||||
call_me({|copy q| *q}, q);
|
||||
call_me(|| *q, q);
|
||||
|
||||
// Check that no false positives are found in loops.
|
||||
let mut q = ~40, p = 10;
|
||||
|
Loading…
x
Reference in New Issue
Block a user