rename sendfn to fn~, lambda to fn@
This commit is contained in:
parent
af086aa8ef
commit
8b911587df
15 changed files with 113 additions and 96 deletions
|
|
@ -231,10 +231,10 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
|||
ret ty::mk_tup(st.tcx, params);
|
||||
}
|
||||
's' {
|
||||
ret parse_ty_rust_fn(st, conv, ast::proto_send);
|
||||
ret parse_ty_rust_fn(st, conv, ast::proto_uniq);
|
||||
}
|
||||
'F' {
|
||||
ret parse_ty_rust_fn(st, conv, ast::proto_shared);
|
||||
ret parse_ty_rust_fn(st, conv, ast::proto_box);
|
||||
}
|
||||
'f' {
|
||||
ret parse_ty_rust_fn(st, conv, ast::proto_bare);
|
||||
|
|
@ -279,9 +279,9 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
|||
'y' { ret ty::mk_send_type(st.tcx); }
|
||||
'C' {
|
||||
let ck = alt next(st) as char {
|
||||
'&' { ty::closure_block }
|
||||
'@' { ty::closure_shared }
|
||||
'~' { ty::closure_send }
|
||||
'&' { ty::ck_block }
|
||||
'@' { ty::ck_box }
|
||||
'~' { ty::ck_uniq }
|
||||
};
|
||||
ret ty::mk_opaque_closure_ptr(st.tcx, ck);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,9 +189,9 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
|||
}
|
||||
ty::ty_type. { w.write_char('Y'); }
|
||||
ty::ty_send_type. { w.write_char('y'); }
|
||||
ty::ty_opaque_closure_ptr(ty::closure_block.) { w.write_str("C&"); }
|
||||
ty::ty_opaque_closure_ptr(ty::closure_shared.) { w.write_str("C@"); }
|
||||
ty::ty_opaque_closure_ptr(ty::closure_send.) { w.write_str("C~"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_block.) { w.write_str("C&"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_box.) { w.write_str("C@"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_uniq.) { w.write_str("C~"); }
|
||||
ty::ty_constr(ty, cs) {
|
||||
w.write_str("A[");
|
||||
enc_ty(w, cx, ty);
|
||||
|
|
@ -202,8 +202,8 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
|||
}
|
||||
fn enc_proto(w: io::writer, proto: proto) {
|
||||
alt proto {
|
||||
proto_send. { w.write_char('s'); }
|
||||
proto_shared. { w.write_char('F'); }
|
||||
proto_uniq. { w.write_char('s'); }
|
||||
proto_box. { w.write_char('F'); }
|
||||
proto_block. { w.write_char('B'); }
|
||||
proto_bare. { w.write_char('f'); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ fn check_capture_clause(tcx: ty::ctxt,
|
|||
check_block_captures(cap_clause.copies);
|
||||
check_block_captures(cap_clause.moves);
|
||||
}
|
||||
ast::proto_bare. | ast::proto_shared. | ast::proto_send. {
|
||||
ast::proto_bare. | ast::proto_box. | ast::proto_uniq. {
|
||||
vec::iter(cap_clause.copies, check_capture_item);
|
||||
vec::iter(cap_clause.moves, check_capture_item);
|
||||
vec::iter(cap_clause.moves, check_not_upvar);
|
||||
|
|
@ -113,7 +113,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
|
||||
let implicit_mode = alt fn_proto {
|
||||
ast::proto_block. { cap_ref }
|
||||
ast::proto_bare. | ast::proto_shared. | ast::proto_send. { cap_copy }
|
||||
ast::proto_bare. | ast::proto_box. | ast::proto_uniq. { cap_copy }
|
||||
};
|
||||
|
||||
vec::iter(*freevars) { |fvar|
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ fn with_appropriate_checker(cx: ctx, id: node_id,
|
|||
b: block(fn(ctx, ty::t, sp: span))) {
|
||||
let fty = ty::node_id_to_monotype(cx.tcx, id);
|
||||
alt ty::ty_fn_proto(cx.tcx, fty) {
|
||||
proto_send. { b(check_send); }
|
||||
proto_shared. { b(check_copy); }
|
||||
proto_uniq. { b(check_send); }
|
||||
proto_box. { b(check_copy); }
|
||||
proto_block. { /* no check needed */ }
|
||||
proto_bare. { b(check_none); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
|
|||
|
||||
fn mk_tydesc_ty(tcx: ty::ctxt, ck: ty::closure_kind) -> ty::t {
|
||||
ret alt ck {
|
||||
ty::closure_block. | ty::closure_shared. { ty::mk_type(tcx) }
|
||||
ty::closure_send. { ty::mk_send_type(tcx) }
|
||||
ty::ck_block. | ty::ck_box. { ty::mk_type(tcx) }
|
||||
ty::ck_uniq. { ty::mk_send_type(tcx) }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -236,15 +236,15 @@ fn allocate_cbox(bcx: @block_ctxt,
|
|||
// Allocate the box:
|
||||
let temp_cleanups = [];
|
||||
let (bcx, box, rc) = alt ck {
|
||||
ty::closure_shared. {
|
||||
ty::ck_box. {
|
||||
let (bcx, box) = alloc_in_heap(bcx, false, temp_cleanups);
|
||||
(bcx, box, 1)
|
||||
}
|
||||
ty::closure_send. {
|
||||
ty::ck_uniq. {
|
||||
let (bcx, box) = alloc_in_heap(bcx, true, temp_cleanups);
|
||||
(bcx, box, 0x12345678) // use arbitrary value for debugging
|
||||
}
|
||||
ty::closure_block. {
|
||||
ty::ck_block. {
|
||||
let {bcx, val: box} = trans::alloc_ty(bcx, cbox_ty);
|
||||
(bcx, box, 0x12345678) // use arbitrary value for debugging
|
||||
}
|
||||
|
|
@ -288,10 +288,10 @@ fn store_environment(
|
|||
ck: ty::closure_kind,
|
||||
td: ValueRef) -> ValueRef {
|
||||
ret alt ck {
|
||||
ty::closure_block. | ty::closure_shared. {
|
||||
ty::ck_block. | ty::ck_box. {
|
||||
td
|
||||
}
|
||||
ty::closure_send. {
|
||||
ty::ck_uniq. {
|
||||
Call(bcx, bcx_ccx(bcx).upcalls.create_shared_type_desc, [td])
|
||||
}
|
||||
};
|
||||
|
|
@ -310,7 +310,7 @@ fn store_environment(
|
|||
|
||||
// store data tydesc.
|
||||
alt ck {
|
||||
ty::closure_shared. | ty::closure_send. {
|
||||
ty::ck_box. | ty::ck_uniq. {
|
||||
let bound_tydesc = GEPi(bcx, llbox, [0, abi::cbox_elt_tydesc]);
|
||||
let ti = none;
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ fn store_environment(
|
|||
let td = maybe_clone_tydesc(bcx, ck, closure_td.val);
|
||||
Store(bcx, td, bound_tydesc);
|
||||
}
|
||||
ty::closure_block. { /* skip this for blocks, not really relevant */ }
|
||||
ty::ck_block. { /* skip this for blocks, not really relevant */ }
|
||||
}
|
||||
|
||||
// cbox_ty has the form of a tuple: (a, b, c) we want a ptr to a
|
||||
|
|
@ -425,7 +425,7 @@ fn build_closure(bcx0: @block_ctxt,
|
|||
let ty = ty::node_id_to_monotype(tcx, nid);
|
||||
alt cap_var.mode {
|
||||
capture::cap_ref. {
|
||||
assert ck == ty::closure_block;
|
||||
assert ck == ty::ck_block;
|
||||
ty = ty::mk_mut_ptr(tcx, ty);
|
||||
env_vals += [env_ref(lv.val, ty, lv.kind)];
|
||||
}
|
||||
|
|
@ -492,8 +492,8 @@ fn load_environment(enclosing_cx: @block_ctxt,
|
|||
bcx = upvarptr.bcx;
|
||||
let llupvarptr = upvarptr.val;
|
||||
alt ck {
|
||||
ty::closure_block. { llupvarptr = Load(bcx, llupvarptr); }
|
||||
ty::closure_send. | ty::closure_shared. { }
|
||||
ty::ck_block. { llupvarptr = Load(bcx, llupvarptr); }
|
||||
ty::ck_uniq. | ty::ck_box. { }
|
||||
}
|
||||
let def_id = ast_util::def_id_of_def(cap_var.def);
|
||||
fcx.llupvars.insert(def_id.node, llupvarptr);
|
||||
|
|
@ -531,9 +531,9 @@ fn trans_expr_fn(bcx: @block_ctxt,
|
|||
};
|
||||
|
||||
let closure = alt proto {
|
||||
ast::proto_block. { trans_closure_env(ty::closure_block) }
|
||||
ast::proto_shared. { trans_closure_env(ty::closure_shared) }
|
||||
ast::proto_send. { trans_closure_env(ty::closure_send) }
|
||||
ast::proto_block. { trans_closure_env(ty::ck_block) }
|
||||
ast::proto_box. { trans_closure_env(ty::ck_box) }
|
||||
ast::proto_uniq. { trans_closure_env(ty::ck_uniq) }
|
||||
ast::proto_bare. {
|
||||
let closure = C_null(T_opaque_cbox_ptr(ccx));
|
||||
trans_closure(sub_cx, sp, decl, body, llfn, no_self, [],
|
||||
|
|
@ -625,7 +625,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
|
|||
let {llbox, cboxptr_ty, bcx} = store_environment(
|
||||
bcx, vec::map(lltydescs, {|d| {desc: d, dicts: none}}),
|
||||
env_vals + vec::map(bound, {|x| env_expr(x)}),
|
||||
ty::closure_shared);
|
||||
ty::ck_box);
|
||||
|
||||
// Make thunk
|
||||
let llthunk =
|
||||
|
|
@ -672,12 +672,8 @@ fn make_fn_glue(
|
|||
ret alt ty::struct(tcx, t) {
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare., _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_block., _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_send., _}) {
|
||||
fn_env(ty::closure_send)
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_shared., _}) {
|
||||
fn_env(ty::closure_shared)
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_uniq., _}) { fn_env(ty::ck_uniq) }
|
||||
ty::ty_fn({proto: ast::proto_box., _}) { fn_env(ty::ck_box) }
|
||||
_ { fail "make_fn_glue invoked on non-function type" }
|
||||
};
|
||||
}
|
||||
|
|
@ -689,13 +685,9 @@ fn make_opaque_cbox_take_glue(
|
|||
-> @block_ctxt {
|
||||
// Easy cases:
|
||||
alt ck {
|
||||
ty::closure_block. {
|
||||
ret bcx;
|
||||
}
|
||||
ty::closure_shared. {
|
||||
ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr));
|
||||
}
|
||||
ty::closure_send. { /* hard case: */ }
|
||||
ty::ck_block. { ret bcx; }
|
||||
ty::ck_box. { ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); }
|
||||
ty::ck_uniq. { /* hard case: */ }
|
||||
}
|
||||
|
||||
// Hard case, a deep copy:
|
||||
|
|
@ -731,12 +723,12 @@ fn make_opaque_cbox_drop_glue(
|
|||
cboxptr: ValueRef) // ptr to the opaque closure
|
||||
-> @block_ctxt {
|
||||
alt ck {
|
||||
ty::closure_block. { bcx }
|
||||
ty::closure_shared. {
|
||||
ty::ck_block. { bcx }
|
||||
ty::ck_box. {
|
||||
decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr),
|
||||
ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
|
||||
}
|
||||
ty::closure_send. {
|
||||
ty::ck_uniq. {
|
||||
free_ty(bcx, Load(bcx, cboxptr),
|
||||
ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
|
||||
}
|
||||
|
|
@ -749,8 +741,8 @@ fn make_opaque_cbox_free_glue(
|
|||
cbox: ValueRef) // ptr to the opaque closure
|
||||
-> @block_ctxt {
|
||||
alt ck {
|
||||
ty::closure_block. { ret bcx; }
|
||||
ty::closure_shared. | ty::closure_send. { /* hard cases: */ }
|
||||
ty::ck_block. { ret bcx; }
|
||||
ty::ck_box. | ty::ck_uniq. { /* hard cases: */ }
|
||||
}
|
||||
|
||||
let ccx = bcx_ccx(bcx);
|
||||
|
|
@ -777,11 +769,11 @@ fn make_opaque_cbox_free_glue(
|
|||
|
||||
// Free the ty descr (if necc) and the box itself
|
||||
alt ck {
|
||||
ty::closure_block. { fail "Impossible."; }
|
||||
ty::closure_shared. {
|
||||
ty::ck_block. { fail "Impossible."; }
|
||||
ty::ck_box. {
|
||||
trans_free_if_not_gc(bcx, cbox)
|
||||
}
|
||||
ty::closure_send. {
|
||||
ty::ck_uniq. {
|
||||
let bcx = free_ty(bcx, tydesc, mk_tydesc_ty(tcx, ck));
|
||||
trans_shared_free(bcx, cbox)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,9 +181,9 @@ export variant_info;
|
|||
export walk_ty;
|
||||
export occurs_check_fails;
|
||||
export closure_kind;
|
||||
export closure_block;
|
||||
export closure_shared;
|
||||
export closure_send;
|
||||
export ck_block;
|
||||
export ck_box;
|
||||
export ck_uniq;
|
||||
export param_bound, param_bounds, bound_copy, bound_send, bound_iface;
|
||||
export param_bounds_to_kind;
|
||||
|
||||
|
|
@ -234,9 +234,9 @@ type raw_t = {struct: sty,
|
|||
type t = uint;
|
||||
|
||||
tag closure_kind {
|
||||
closure_block;
|
||||
closure_shared;
|
||||
closure_send;
|
||||
ck_block;
|
||||
ck_box;
|
||||
ck_uniq;
|
||||
}
|
||||
|
||||
type fn_ty = {proto: ast::proto,
|
||||
|
|
@ -1020,8 +1020,8 @@ pure fn kind_can_be_sent(k: kind) -> bool {
|
|||
fn proto_kind(p: proto) -> kind {
|
||||
alt p {
|
||||
ast::proto_block. { kind_noncopyable }
|
||||
ast::proto_shared. { kind_copyable }
|
||||
ast::proto_send. { kind_sendable }
|
||||
ast::proto_box. { kind_copyable }
|
||||
ast::proto_uniq. { kind_sendable }
|
||||
ast::proto_bare. { kind_sendable }
|
||||
}
|
||||
}
|
||||
|
|
@ -1057,9 +1057,9 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
// anything about its fields.
|
||||
ty_obj(_) { kind_copyable }
|
||||
ty_fn(f) { proto_kind(f.proto) }
|
||||
ty_opaque_closure_ptr(closure_block.) { kind_noncopyable }
|
||||
ty_opaque_closure_ptr(closure_shared.) { kind_copyable }
|
||||
ty_opaque_closure_ptr(closure_send.) { kind_sendable }
|
||||
ty_opaque_closure_ptr(ck_block.) { kind_noncopyable }
|
||||
ty_opaque_closure_ptr(ck_box.) { kind_copyable }
|
||||
ty_opaque_closure_ptr(ck_uniq.) { kind_sendable }
|
||||
// Those with refcounts-to-inner raise pinned to shared,
|
||||
// lower unique to shared. Therefore just set result to shared.
|
||||
ty_box(_) | ty_iface(_, _) { kind_copyable }
|
||||
|
|
@ -1422,9 +1422,9 @@ fn hash_type_structure(st: sty) -> uint {
|
|||
for typ: t in tys { h = hash_subty(h, typ); }
|
||||
ret h;
|
||||
}
|
||||
ty_opaque_closure_ptr(closure_block.) { ret 41u; }
|
||||
ty_opaque_closure_ptr(closure_shared.) { ret 42u; }
|
||||
ty_opaque_closure_ptr(closure_send.) { ret 43u; }
|
||||
ty_opaque_closure_ptr(ck_block.) { ret 41u; }
|
||||
ty_opaque_closure_ptr(ck_box.) { ret 42u; }
|
||||
ty_opaque_closure_ptr(ck_uniq.) { ret 43u; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1563,7 +1563,7 @@ fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto {
|
|||
ty::ty_fn(f) { ret f.proto; }
|
||||
ty::ty_native_fn(_, _) {
|
||||
// FIXME: This should probably be proto_bare
|
||||
ret ast::proto_shared;
|
||||
ret ast::proto_box;
|
||||
}
|
||||
_ { cx.sess.bug("ty_fn_proto() called on non-fn type"); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
|
|||
let t_field = ast_ty_to_ty(tcx, mode, f.ty);
|
||||
t_inputs += [{mode: ast::by_copy, ty: t_field}];
|
||||
}
|
||||
let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared,
|
||||
let t_fn = ty::mk_fn(tcx, {proto: ast::proto_box,
|
||||
inputs: t_inputs, output: t_obj.ty,
|
||||
ret_style: ast::return_val, constraints: []});
|
||||
let tpt = {bounds: ty_param_bounds(tcx, mode, ty_params), ty: t_fn};
|
||||
|
|
@ -697,7 +697,7 @@ mod collect {
|
|||
}
|
||||
// FIXME: this will be different for constrained types
|
||||
ty::mk_fn(cx.tcx,
|
||||
{proto: ast::proto_shared,
|
||||
{proto: ast::proto_box,
|
||||
inputs: args, output: tag_ty,
|
||||
ret_style: ast::return_val, constraints: []})
|
||||
};
|
||||
|
|
@ -799,13 +799,13 @@ mod collect {
|
|||
let t_res = ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty,
|
||||
params);
|
||||
let t_ctor = ty::mk_fn(cx.tcx, {
|
||||
proto: ast::proto_shared,
|
||||
proto: ast::proto_box,
|
||||
inputs: [{mode: ast::by_copy with t_arg}],
|
||||
output: t_res,
|
||||
ret_style: ast::return_val, constraints: []
|
||||
});
|
||||
let t_dtor = ty::mk_fn(cx.tcx, {
|
||||
proto: ast::proto_shared,
|
||||
proto: ast::proto_box,
|
||||
inputs: [t_arg], output: ty::mk_nil(cx.tcx),
|
||||
ret_style: ast::return_val, constraints: []
|
||||
});
|
||||
|
|
@ -2179,7 +2179,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
|||
fn lower_bound_proto(proto: ast::proto) -> ast::proto {
|
||||
// FIXME: This is right for bare fns, possibly not others
|
||||
alt proto {
|
||||
ast::proto_bare. { ast::proto_shared }
|
||||
ast::proto_bare. { ast::proto_box }
|
||||
_ { proto }
|
||||
}
|
||||
}
|
||||
|
|
@ -2632,7 +2632,7 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) {
|
|||
let fcx: @fn_ctxt =
|
||||
@{ret_ty: rty,
|
||||
purity: ast::pure_fn,
|
||||
proto: ast::proto_shared,
|
||||
proto: ast::proto_box,
|
||||
var_bindings: ty::unify::mk_var_bindings(),
|
||||
locals: new_int_hash::<int>(),
|
||||
next_var_id: @mutable 0,
|
||||
|
|
|
|||
|
|
@ -111,10 +111,10 @@ tag pat_ {
|
|||
tag mutability { mut; imm; maybe_mut; }
|
||||
|
||||
tag proto {
|
||||
proto_bare;
|
||||
proto_send;
|
||||
proto_shared;
|
||||
proto_block;
|
||||
proto_bare; // fn
|
||||
proto_uniq; // fn~
|
||||
proto_box; // fn@
|
||||
proto_block; // block
|
||||
}
|
||||
|
||||
tag binop {
|
||||
|
|
|
|||
|
|
@ -514,10 +514,10 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
|
|||
t = parse_ty_fn(proto, p);
|
||||
} else if eat_word(p, "block") {
|
||||
t = parse_ty_fn(ast::proto_block, p);
|
||||
} else if eat_word(p, "fn@") {
|
||||
t = parse_ty_fn(ast::proto_shared, p);
|
||||
} else if eat_word(p, "lambda") {
|
||||
t = parse_ty_fn(ast::proto_box, p);
|
||||
} else if eat_word(p, "sendfn") {
|
||||
t = parse_ty_fn(ast::proto_send, p);
|
||||
t = parse_ty_fn(ast::proto_uniq, p);
|
||||
} else if eat_word(p, "obj") {
|
||||
t = ast::ty_obj(parse_ty_methods(p, false));
|
||||
} else if p.peek() == token::MOD_SEP || is_ident(p.peek()) {
|
||||
|
|
@ -821,10 +821,10 @@ fn parse_bottom_expr(p: parser) -> pexpr {
|
|||
ret pexpr(parse_fn_expr(p, proto));
|
||||
} else if eat_word(p, "block") {
|
||||
ret pexpr(parse_fn_expr(p, ast::proto_block));
|
||||
} else if eat_word(p, "fn@") {
|
||||
ret pexpr(parse_fn_expr(p, ast::proto_shared));
|
||||
} else if eat_word(p, "lambda") {
|
||||
ret pexpr(parse_fn_expr(p, ast::proto_box));
|
||||
} else if eat_word(p, "sendfn") {
|
||||
ret pexpr(parse_fn_expr(p, ast::proto_send));
|
||||
ret pexpr(parse_fn_expr(p, ast::proto_uniq));
|
||||
} else if eat_word(p, "unchecked") {
|
||||
ret pexpr(parse_block_expr(p, lo, ast::unchecked_blk));
|
||||
} else if eat_word(p, "unsafe") {
|
||||
|
|
@ -2113,7 +2113,10 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
|||
fn parse_fn_ty_proto(p: parser) -> ast::proto {
|
||||
if p.peek() == token::AT {
|
||||
p.bump();
|
||||
ast::proto_shared
|
||||
ast::proto_box
|
||||
} else if p.peek() == token::TILDE {
|
||||
p.bump();
|
||||
ast::proto_uniq
|
||||
} else {
|
||||
ast::proto_bare
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1684,8 +1684,8 @@ fn proto_to_str(p: ast::proto) -> str {
|
|||
ret alt p {
|
||||
ast::proto_bare. { "fn" }
|
||||
ast::proto_block. { "block" }
|
||||
ast::proto_send. { "sendfn" }
|
||||
ast::proto_shared. { "fn@" }
|
||||
ast::proto_uniq. { "fn~" }
|
||||
ast::proto_box. { "fn@" }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
// error-pattern: mismatched types: expected `fn@(++uint) -> uint`
|
||||
|
||||
fn test(f: fn@(uint) -> uint) -> uint {
|
||||
ret f(22u);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let f = sendfn(x: uint) -> uint { ret 4u; };
|
||||
log(debug, test(f));
|
||||
let f = fn~(x: uint) -> uint { ret 4u; };
|
||||
log(debug, test(f)); //! ERROR expected `fn@(++uint) -> uint`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ fn main() {
|
|||
let x = 1;
|
||||
let y = 2;
|
||||
let z = 3;
|
||||
let s1 = sendfn[copy x]() -> int { x + y };
|
||||
let s2 = sendfn[copy x; move y]() -> int { x + y };
|
||||
let s3 = sendfn[move z]() -> int { z };
|
||||
let s1 = fn~[copy x]() -> int { x + y };
|
||||
let s2 = fn~[copy x; move y]() -> int { x + y };
|
||||
let s3 = fn~[move z]() -> int { z };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ fn main() {
|
|||
macerate(*tasties);
|
||||
} (carrots, { |food|
|
||||
let mush = food + cheese;
|
||||
let _ = fn@() {
|
||||
let f = fn@() {
|
||||
let chew = mush + cheese;
|
||||
fail "so yummy"
|
||||
} ();
|
||||
};
|
||||
f();
|
||||
});
|
||||
}
|
||||
|
|
@ -2,6 +2,6 @@
|
|||
fn force(f: fn@()) { f() }
|
||||
fn main() {
|
||||
let x = 7;
|
||||
let _ = fn@ () { log(error, x); };
|
||||
force(fn@ () { log(error, x); });
|
||||
let _f = fn@() { log(error, x); };
|
||||
force(fn@() { log(error, x); });
|
||||
}
|
||||
|
|
|
|||
23
src/test/run-pass/uniq-fn-leak.rs
Normal file
23
src/test/run-pass/uniq-fn-leak.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// xfail-test
|
||||
tag maybe_pointy {
|
||||
none;
|
||||
p(@pointy);
|
||||
}
|
||||
|
||||
type pointy = {
|
||||
mutable a : maybe_pointy,
|
||||
d : sendfn()->(),
|
||||
};
|
||||
|
||||
fn empty_pointy() -> @pointy {
|
||||
ret @{
|
||||
mutable a : none,
|
||||
d : sendfn()->(){},
|
||||
}
|
||||
}
|
||||
|
||||
fn main()
|
||||
{
|
||||
let v = empty_pointy();
|
||||
v.a = p(v);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue