Skip to content

Commit 8b91158

Browse files
committed
rename sendfn to fn~, lambda to fn@
1 parent af086aa commit 8b91158

File tree

15 files changed

+113
-96
lines changed

15 files changed

+113
-96
lines changed

src/comp/metadata/tydecode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
231231
ret ty::mk_tup(st.tcx, params);
232232
}
233233
's' {
234-
ret parse_ty_rust_fn(st, conv, ast::proto_send);
234+
ret parse_ty_rust_fn(st, conv, ast::proto_uniq);
235235
}
236236
'F' {
237-
ret parse_ty_rust_fn(st, conv, ast::proto_shared);
237+
ret parse_ty_rust_fn(st, conv, ast::proto_box);
238238
}
239239
'f' {
240240
ret parse_ty_rust_fn(st, conv, ast::proto_bare);
@@ -279,9 +279,9 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
279279
'y' { ret ty::mk_send_type(st.tcx); }
280280
'C' {
281281
let ck = alt next(st) as char {
282-
'&' { ty::closure_block }
283-
'@' { ty::closure_shared }
284-
'~' { ty::closure_send }
282+
'&' { ty::ck_block }
283+
'@' { ty::ck_box }
284+
'~' { ty::ck_uniq }
285285
};
286286
ret ty::mk_opaque_closure_ptr(st.tcx, ck);
287287
}

src/comp/metadata/tyencode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
189189
}
190190
ty::ty_type. { w.write_char('Y'); }
191191
ty::ty_send_type. { w.write_char('y'); }
192-
ty::ty_opaque_closure_ptr(ty::closure_block.) { w.write_str("C&"); }
193-
ty::ty_opaque_closure_ptr(ty::closure_shared.) { w.write_str("C@"); }
194-
ty::ty_opaque_closure_ptr(ty::closure_send.) { w.write_str("C~"); }
192+
ty::ty_opaque_closure_ptr(ty::ck_block.) { w.write_str("C&"); }
193+
ty::ty_opaque_closure_ptr(ty::ck_box.) { w.write_str("C@"); }
194+
ty::ty_opaque_closure_ptr(ty::ck_uniq.) { w.write_str("C~"); }
195195
ty::ty_constr(ty, cs) {
196196
w.write_str("A[");
197197
enc_ty(w, cx, ty);
@@ -202,8 +202,8 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
202202
}
203203
fn enc_proto(w: io::writer, proto: proto) {
204204
alt proto {
205-
proto_send. { w.write_char('s'); }
206-
proto_shared. { w.write_char('F'); }
205+
proto_uniq. { w.write_char('s'); }
206+
proto_box. { w.write_char('F'); }
207207
proto_block. { w.write_char('B'); }
208208
proto_bare. { w.write_char('f'); }
209209
}

src/comp/middle/capture.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn check_capture_clause(tcx: ty::ctxt,
7878
check_block_captures(cap_clause.copies);
7979
check_block_captures(cap_clause.moves);
8080
}
81-
ast::proto_bare. | ast::proto_shared. | ast::proto_send. {
81+
ast::proto_bare. | ast::proto_box. | ast::proto_uniq. {
8282
vec::iter(cap_clause.copies, check_capture_item);
8383
vec::iter(cap_clause.moves, check_capture_item);
8484
vec::iter(cap_clause.moves, check_not_upvar);
@@ -113,7 +113,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
113113

114114
let implicit_mode = alt fn_proto {
115115
ast::proto_block. { cap_ref }
116-
ast::proto_bare. | ast::proto_shared. | ast::proto_send. { cap_copy }
116+
ast::proto_bare. | ast::proto_box. | ast::proto_uniq. { cap_copy }
117117
};
118118

119119
vec::iter(*freevars) { |fvar|

src/comp/middle/kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ fn with_appropriate_checker(cx: ctx, id: node_id,
6060
b: block(fn(ctx, ty::t, sp: span))) {
6161
let fty = ty::node_id_to_monotype(cx.tcx, id);
6262
alt ty::ty_fn_proto(cx.tcx, fty) {
63-
proto_send. { b(check_send); }
64-
proto_shared. { b(check_copy); }
63+
proto_uniq. { b(check_send); }
64+
proto_box. { b(check_copy); }
6565
proto_block. { /* no check needed */ }
6666
proto_bare. { b(check_none); }
6767
}

src/comp/middle/trans_closure.rs

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
136136

137137
fn mk_tydesc_ty(tcx: ty::ctxt, ck: ty::closure_kind) -> ty::t {
138138
ret alt ck {
139-
ty::closure_block. | ty::closure_shared. { ty::mk_type(tcx) }
140-
ty::closure_send. { ty::mk_send_type(tcx) }
139+
ty::ck_block. | ty::ck_box. { ty::mk_type(tcx) }
140+
ty::ck_uniq. { ty::mk_send_type(tcx) }
141141
};
142142
}
143143

@@ -236,15 +236,15 @@ fn allocate_cbox(bcx: @block_ctxt,
236236
// Allocate the box:
237237
let temp_cleanups = [];
238238
let (bcx, box, rc) = alt ck {
239-
ty::closure_shared. {
239+
ty::ck_box. {
240240
let (bcx, box) = alloc_in_heap(bcx, false, temp_cleanups);
241241
(bcx, box, 1)
242242
}
243-
ty::closure_send. {
243+
ty::ck_uniq. {
244244
let (bcx, box) = alloc_in_heap(bcx, true, temp_cleanups);
245245
(bcx, box, 0x12345678) // use arbitrary value for debugging
246246
}
247-
ty::closure_block. {
247+
ty::ck_block. {
248248
let {bcx, val: box} = trans::alloc_ty(bcx, cbox_ty);
249249
(bcx, box, 0x12345678) // use arbitrary value for debugging
250250
}
@@ -288,10 +288,10 @@ fn store_environment(
288288
ck: ty::closure_kind,
289289
td: ValueRef) -> ValueRef {
290290
ret alt ck {
291-
ty::closure_block. | ty::closure_shared. {
291+
ty::ck_block. | ty::ck_box. {
292292
td
293293
}
294-
ty::closure_send. {
294+
ty::ck_uniq. {
295295
Call(bcx, bcx_ccx(bcx).upcalls.create_shared_type_desc, [td])
296296
}
297297
};
@@ -310,7 +310,7 @@ fn store_environment(
310310

311311
// store data tydesc.
312312
alt ck {
313-
ty::closure_shared. | ty::closure_send. {
313+
ty::ck_box. | ty::ck_uniq. {
314314
let bound_tydesc = GEPi(bcx, llbox, [0, abi::cbox_elt_tydesc]);
315315
let ti = none;
316316

@@ -331,7 +331,7 @@ fn store_environment(
331331
let td = maybe_clone_tydesc(bcx, ck, closure_td.val);
332332
Store(bcx, td, bound_tydesc);
333333
}
334-
ty::closure_block. { /* skip this for blocks, not really relevant */ }
334+
ty::ck_block. { /* skip this for blocks, not really relevant */ }
335335
}
336336

337337
// 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,
425425
let ty = ty::node_id_to_monotype(tcx, nid);
426426
alt cap_var.mode {
427427
capture::cap_ref. {
428-
assert ck == ty::closure_block;
428+
assert ck == ty::ck_block;
429429
ty = ty::mk_mut_ptr(tcx, ty);
430430
env_vals += [env_ref(lv.val, ty, lv.kind)];
431431
}
@@ -492,8 +492,8 @@ fn load_environment(enclosing_cx: @block_ctxt,
492492
bcx = upvarptr.bcx;
493493
let llupvarptr = upvarptr.val;
494494
alt ck {
495-
ty::closure_block. { llupvarptr = Load(bcx, llupvarptr); }
496-
ty::closure_send. | ty::closure_shared. { }
495+
ty::ck_block. { llupvarptr = Load(bcx, llupvarptr); }
496+
ty::ck_uniq. | ty::ck_box. { }
497497
}
498498
let def_id = ast_util::def_id_of_def(cap_var.def);
499499
fcx.llupvars.insert(def_id.node, llupvarptr);
@@ -531,9 +531,9 @@ fn trans_expr_fn(bcx: @block_ctxt,
531531
};
532532

533533
let closure = alt proto {
534-
ast::proto_block. { trans_closure_env(ty::closure_block) }
535-
ast::proto_shared. { trans_closure_env(ty::closure_shared) }
536-
ast::proto_send. { trans_closure_env(ty::closure_send) }
534+
ast::proto_block. { trans_closure_env(ty::ck_block) }
535+
ast::proto_box. { trans_closure_env(ty::ck_box) }
536+
ast::proto_uniq. { trans_closure_env(ty::ck_uniq) }
537537
ast::proto_bare. {
538538
let closure = C_null(T_opaque_cbox_ptr(ccx));
539539
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,
625625
let {llbox, cboxptr_ty, bcx} = store_environment(
626626
bcx, vec::map(lltydescs, {|d| {desc: d, dicts: none}}),
627627
env_vals + vec::map(bound, {|x| env_expr(x)}),
628-
ty::closure_shared);
628+
ty::ck_box);
629629

630630
// Make thunk
631631
let llthunk =
@@ -672,12 +672,8 @@ fn make_fn_glue(
672672
ret alt ty::struct(tcx, t) {
673673
ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare., _}) { bcx }
674674
ty::ty_fn({proto: ast::proto_block., _}) { bcx }
675-
ty::ty_fn({proto: ast::proto_send., _}) {
676-
fn_env(ty::closure_send)
677-
}
678-
ty::ty_fn({proto: ast::proto_shared., _}) {
679-
fn_env(ty::closure_shared)
680-
}
675+
ty::ty_fn({proto: ast::proto_uniq., _}) { fn_env(ty::ck_uniq) }
676+
ty::ty_fn({proto: ast::proto_box., _}) { fn_env(ty::ck_box) }
681677
_ { fail "make_fn_glue invoked on non-function type" }
682678
};
683679
}
@@ -689,13 +685,9 @@ fn make_opaque_cbox_take_glue(
689685
-> @block_ctxt {
690686
// Easy cases:
691687
alt ck {
692-
ty::closure_block. {
693-
ret bcx;
694-
}
695-
ty::closure_shared. {
696-
ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr));
697-
}
698-
ty::closure_send. { /* hard case: */ }
688+
ty::ck_block. { ret bcx; }
689+
ty::ck_box. { ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); }
690+
ty::ck_uniq. { /* hard case: */ }
699691
}
700692

701693
// Hard case, a deep copy:
@@ -731,12 +723,12 @@ fn make_opaque_cbox_drop_glue(
731723
cboxptr: ValueRef) // ptr to the opaque closure
732724
-> @block_ctxt {
733725
alt ck {
734-
ty::closure_block. { bcx }
735-
ty::closure_shared. {
726+
ty::ck_block. { bcx }
727+
ty::ck_box. {
736728
decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr),
737729
ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
738730
}
739-
ty::closure_send. {
731+
ty::ck_uniq. {
740732
free_ty(bcx, Load(bcx, cboxptr),
741733
ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
742734
}
@@ -749,8 +741,8 @@ fn make_opaque_cbox_free_glue(
749741
cbox: ValueRef) // ptr to the opaque closure
750742
-> @block_ctxt {
751743
alt ck {
752-
ty::closure_block. { ret bcx; }
753-
ty::closure_shared. | ty::closure_send. { /* hard cases: */ }
744+
ty::ck_block. { ret bcx; }
745+
ty::ck_box. | ty::ck_uniq. { /* hard cases: */ }
754746
}
755747

756748
let ccx = bcx_ccx(bcx);
@@ -777,11 +769,11 @@ fn make_opaque_cbox_free_glue(
777769

778770
// Free the ty descr (if necc) and the box itself
779771
alt ck {
780-
ty::closure_block. { fail "Impossible."; }
781-
ty::closure_shared. {
772+
ty::ck_block. { fail "Impossible."; }
773+
ty::ck_box. {
782774
trans_free_if_not_gc(bcx, cbox)
783775
}
784-
ty::closure_send. {
776+
ty::ck_uniq. {
785777
let bcx = free_ty(bcx, tydesc, mk_tydesc_ty(tcx, ck));
786778
trans_shared_free(bcx, cbox)
787779
}

src/comp/middle/ty.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ export variant_info;
181181
export walk_ty;
182182
export occurs_check_fails;
183183
export closure_kind;
184-
export closure_block;
185-
export closure_shared;
186-
export closure_send;
184+
export ck_block;
185+
export ck_box;
186+
export ck_uniq;
187187
export param_bound, param_bounds, bound_copy, bound_send, bound_iface;
188188
export param_bounds_to_kind;
189189

@@ -234,9 +234,9 @@ type raw_t = {struct: sty,
234234
type t = uint;
235235

236236
tag closure_kind {
237-
closure_block;
238-
closure_shared;
239-
closure_send;
237+
ck_block;
238+
ck_box;
239+
ck_uniq;
240240
}
241241

242242
type fn_ty = {proto: ast::proto,
@@ -1020,8 +1020,8 @@ pure fn kind_can_be_sent(k: kind) -> bool {
10201020
fn proto_kind(p: proto) -> kind {
10211021
alt p {
10221022
ast::proto_block. { kind_noncopyable }
1023-
ast::proto_shared. { kind_copyable }
1024-
ast::proto_send. { kind_sendable }
1023+
ast::proto_box. { kind_copyable }
1024+
ast::proto_uniq. { kind_sendable }
10251025
ast::proto_bare. { kind_sendable }
10261026
}
10271027
}
@@ -1057,9 +1057,9 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
10571057
// anything about its fields.
10581058
ty_obj(_) { kind_copyable }
10591059
ty_fn(f) { proto_kind(f.proto) }
1060-
ty_opaque_closure_ptr(closure_block.) { kind_noncopyable }
1061-
ty_opaque_closure_ptr(closure_shared.) { kind_copyable }
1062-
ty_opaque_closure_ptr(closure_send.) { kind_sendable }
1060+
ty_opaque_closure_ptr(ck_block.) { kind_noncopyable }
1061+
ty_opaque_closure_ptr(ck_box.) { kind_copyable }
1062+
ty_opaque_closure_ptr(ck_uniq.) { kind_sendable }
10631063
// Those with refcounts-to-inner raise pinned to shared,
10641064
// lower unique to shared. Therefore just set result to shared.
10651065
ty_box(_) | ty_iface(_, _) { kind_copyable }
@@ -1422,9 +1422,9 @@ fn hash_type_structure(st: sty) -> uint {
14221422
for typ: t in tys { h = hash_subty(h, typ); }
14231423
ret h;
14241424
}
1425-
ty_opaque_closure_ptr(closure_block.) { ret 41u; }
1426-
ty_opaque_closure_ptr(closure_shared.) { ret 42u; }
1427-
ty_opaque_closure_ptr(closure_send.) { ret 43u; }
1425+
ty_opaque_closure_ptr(ck_block.) { ret 41u; }
1426+
ty_opaque_closure_ptr(ck_box.) { ret 42u; }
1427+
ty_opaque_closure_ptr(ck_uniq.) { ret 43u; }
14281428
}
14291429
}
14301430

@@ -1563,7 +1563,7 @@ fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto {
15631563
ty::ty_fn(f) { ret f.proto; }
15641564
ty::ty_native_fn(_, _) {
15651565
// FIXME: This should probably be proto_bare
1566-
ret ast::proto_shared;
1566+
ret ast::proto_box;
15671567
}
15681568
_ { cx.sess.bug("ty_fn_proto() called on non-fn type"); }
15691569
}

src/comp/middle/typeck.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
553553
let t_field = ast_ty_to_ty(tcx, mode, f.ty);
554554
t_inputs += [{mode: ast::by_copy, ty: t_field}];
555555
}
556-
let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared,
556+
let t_fn = ty::mk_fn(tcx, {proto: ast::proto_box,
557557
inputs: t_inputs, output: t_obj.ty,
558558
ret_style: ast::return_val, constraints: []});
559559
let tpt = {bounds: ty_param_bounds(tcx, mode, ty_params), ty: t_fn};
@@ -697,7 +697,7 @@ mod collect {
697697
}
698698
// FIXME: this will be different for constrained types
699699
ty::mk_fn(cx.tcx,
700-
{proto: ast::proto_shared,
700+
{proto: ast::proto_box,
701701
inputs: args, output: tag_ty,
702702
ret_style: ast::return_val, constraints: []})
703703
};
@@ -799,13 +799,13 @@ mod collect {
799799
let t_res = ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty,
800800
params);
801801
let t_ctor = ty::mk_fn(cx.tcx, {
802-
proto: ast::proto_shared,
802+
proto: ast::proto_box,
803803
inputs: [{mode: ast::by_copy with t_arg}],
804804
output: t_res,
805805
ret_style: ast::return_val, constraints: []
806806
});
807807
let t_dtor = ty::mk_fn(cx.tcx, {
808-
proto: ast::proto_shared,
808+
proto: ast::proto_box,
809809
inputs: [t_arg], output: ty::mk_nil(cx.tcx),
810810
ret_style: ast::return_val, constraints: []
811811
});
@@ -2179,7 +2179,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
21792179
fn lower_bound_proto(proto: ast::proto) -> ast::proto {
21802180
// FIXME: This is right for bare fns, possibly not others
21812181
alt proto {
2182-
ast::proto_bare. { ast::proto_shared }
2182+
ast::proto_bare. { ast::proto_box }
21832183
_ { proto }
21842184
}
21852185
}
@@ -2632,7 +2632,7 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) {
26322632
let fcx: @fn_ctxt =
26332633
@{ret_ty: rty,
26342634
purity: ast::pure_fn,
2635-
proto: ast::proto_shared,
2635+
proto: ast::proto_box,
26362636
var_bindings: ty::unify::mk_var_bindings(),
26372637
locals: new_int_hash::<int>(),
26382638
next_var_id: @mutable 0,

src/comp/syntax/ast.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ tag pat_ {
111111
tag mutability { mut; imm; maybe_mut; }
112112

113113
tag proto {
114-
proto_bare;
115-
proto_send;
116-
proto_shared;
117-
proto_block;
114+
proto_bare; // fn
115+
proto_uniq; // fn~
116+
proto_box; // fn@
117+
proto_block; // block
118118
}
119119

120120
tag binop {

0 commit comments

Comments
 (0)