Skip to content

Commit 142c8a1

Browse files
committed
---
yaml --- r: 29772 b: refs/heads/incoming c: 5bd4110 h: refs/heads/master v: v3
1 parent 3f955f4 commit 142c8a1

31 files changed

+365
-150
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 395d1ac18598be88d71214691acfb3e820dc05a8
9+
refs/heads/incoming: 5bd4110170e053244636a97f9faa953a8147865f
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/os.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,12 @@ mod global_env {
163163

164164
fn get_global_env_chan() -> comm::chan<msg> {
165165
let global_ptr = rustrt::rust_global_env_chan_ptr();
166-
let task_build_fn = || {
167-
// FIXME (#2621): This would be a good place to use a very small
168-
// foreign stack
169-
task::task().sched_mode(task::single_threaded).unlinked()
170-
};
171166
unsafe {
172-
priv::chan_from_global_ptr(
173-
global_ptr, task_build_fn, global_env_task)
167+
priv::chan_from_global_ptr(global_ptr, || {
168+
// FIXME (#2621): This would be a good place to use a very
169+
// small foreign stack
170+
task::task().sched_mode(task::single_threaded).unlinked()
171+
}, global_env_task)
174172
}
175173
}
176174

branches/incoming/src/libcore/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ extern mod rusti {
109109
}
110110

111111
/// A function used to initialize the elements of a vector
112-
type init_op<T> = fn(uint) -> T;
112+
type init_op/&<T> = fn(uint) -> T;
113113

114114
/// Returns true if a vector contains no elements
115115
pure fn is_empty<T>(v: &[const T]) -> bool {

branches/incoming/src/libstd/par.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn map_slices<A: copy send, B: copy send>(
8181
fn map<A: copy send, B: copy send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
8282
vec::concat(map_slices(xs, || {
8383
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
84-
vec::map(slice, f)
84+
vec::map(slice, |x| f(x))
8585
}
8686
}))
8787
}
@@ -139,7 +139,7 @@ fn alli<A: copy send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
139139
fn any<A: copy send>(xs: ~[A], f: fn~(A) -> bool) -> bool {
140140
do vec::any(map_slices(xs, || {
141141
fn~(_base : uint, slice: &[A], copy f) -> bool {
142-
vec::any(slice, f)
142+
vec::any(slice, |x| f(x))
143143
}
144144
})) |x| { x }
145145
}

branches/incoming/src/libstd/test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ fn filter_tests(opts: test_opts,
347347
} else { return option::none; }
348348
}
349349
350-
let filter = |x| filter_fn(x, filter_str);
351-
352-
vec::filter_map(filtered, filter)
350+
vec::filter_map(filtered, |x| filter_fn(x, filter_str))
353351
};
354352
355353
// Maybe pull out the ignored test and unignore them

branches/incoming/src/libstd/uv_global_loop.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ fn get_monitor_task_gl() -> iotask unsafe {
3939
debug!{"ENTERING global_loop::get() loop chan: %?",
4040
monitor_loop_chan_ptr};
4141

42-
let builder_fn = || {
43-
task::task().sched_mode(task::single_threaded).unlinked()
44-
};
45-
4642
debug!{"before priv::chan_from_global_ptr"};
4743
type monchan = chan<iotask>;
4844

49-
let monitor_ch = do chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr,
50-
builder_fn) |msg_po| {
45+
let monitor_ch =
46+
do chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr,
47+
|| {
48+
task::task().sched_mode
49+
(task::single_threaded)
50+
.unlinked()
51+
}) |msg_po| {
5152
debug!{"global monitor task starting"};
5253

5354
// As a weak task the runtime will notify us when to exit

branches/incoming/src/rustc/metadata/tydecode.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,11 @@ fn parse_ty_rust_fn(st: @pstate, conv: conv_did) -> ty::t {
8585
return ty::mk_fn(st.tcx, parse_ty_fn(st, conv));
8686
}
8787

88-
fn parse_proto(c: char) -> ast::proto {
89-
match c {
90-
'~' => ast::proto_uniq,
91-
'@' => ast::proto_box,
92-
'&' => ast::proto_block,
93-
'n' => ast::proto_bare,
94-
_ => fail ~"illegal fn type kind " + str::from_char(c)
88+
fn parse_proto(st: @pstate) -> ty::fn_proto {
89+
match next(st) {
90+
'n' => ty::proto_bare,
91+
'v' => ty::proto_vstore(parse_vstore(st)),
92+
c => fail ~"illegal proto type kind " + str::from_char(c)
9593
}
9694
}
9795
@@ -360,7 +358,7 @@ fn parse_purity(c: char) -> purity {
360358
}
361359

362360
fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty {
363-
let proto = parse_proto(next(st));
361+
let proto = parse_proto(st);
364362
let purity = parse_purity(next(st));
365363
let bounds = parse_bounds(st, conv);
366364
assert (next(st) == '[');

branches/incoming/src/rustc/metadata/tyencode.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,15 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
306306
}
307307
}
308308
}
309-
fn enc_proto(w: io::writer, proto: proto) {
309+
310+
fn enc_proto(w: io::writer, cx: @ctxt, proto: ty::fn_proto) {
311+
w.write_str(&"f");
310312
match proto {
311-
proto_uniq => w.write_str(&"f~"),
312-
proto_box => w.write_str(&"f@"),
313-
proto_block => w.write_str(~"f&"),
314-
proto_bare => w.write_str(&"fn")
313+
ty::proto_bare => w.write_str(&"n"),
314+
ty::proto_vstore(vstore) => {
315+
w.write_str(&"v");
316+
enc_vstore(w, cx, vstore);
317+
}
315318
}
316319
}
317320

@@ -335,7 +338,7 @@ fn enc_purity(w: io::writer, p: purity) {
335338
}
336339

337340
fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) {
338-
enc_proto(w, ft.proto);
341+
enc_proto(w, cx, ft.proto);
339342
enc_purity(w, ft.purity);
340343
enc_bounds(w, cx, ft.bounds);
341344
w.write_char('[');

branches/incoming/src/rustc/middle/block_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
1414
fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
1515
if !cx.allow_block {
1616
match ty::get(ty::expr_ty(cx.tcx, ex)).struct {
17-
ty::ty_fn({proto: p, _}) if is_blockish(p) => {
17+
ty::ty_fn({proto: p, _}) if ty::is_blockish(p) => {
1818
cx.tcx.sess.span_err(ex.span,
1919
~"expressions with stack closure type \
2020
can only appear in callee or (by-ref) argument position");

branches/incoming/src/rustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ impl check_loan_ctxt {
218218
fn is_stack_closure(id: ast::node_id) -> bool {
219219
let fn_ty = ty::node_id_to_type(self.tcx(), id);
220220
let proto = ty::ty_fn_proto(fn_ty);
221-
match proto {
222-
ast::proto_block => true,
223-
ast::proto_bare | ast::proto_uniq | ast::proto_box => false
224-
}
221+
return ty::is_blockish(proto);
225222
}
226223

227224
fn is_allowed_pure_arg(expr: @ast::expr) -> bool {

branches/incoming/src/rustc/middle/capture.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn check_capture_clause(tcx: ty::ctxt,
5959

6060
fn compute_capture_vars(tcx: ty::ctxt,
6161
fn_expr_id: ast::node_id,
62-
fn_proto: ast::proto,
62+
fn_proto: ty::fn_proto,
6363
cap_clause: ast::capture_clause) -> ~[capture_var] {
6464
let freevars = freevars::get_freevars(tcx, fn_expr_id);
6565
let cap_map = map::int_hash();
@@ -101,10 +101,12 @@ fn compute_capture_vars(tcx: ty::ctxt,
101101
// now go through anything that is referenced but was not explicitly
102102
// named and add that
103103

104-
let implicit_mode = match fn_proto {
105-
ast::proto_block => cap_ref,
106-
ast::proto_bare | ast::proto_box | ast::proto_uniq => cap_copy
107-
};
104+
let implicit_mode;
105+
if ty::is_blockish(fn_proto) {
106+
implicit_mode = cap_ref;
107+
} else {
108+
implicit_mode = cap_copy;
109+
}
108110

109111
do vec::iter(*freevars) |fvar| {
110112
let fvar_def_id = ast_util::def_id_of_def(fvar.def).node;

branches/incoming/src/rustc/middle/check_loop.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
2525
v.visit_block(b, {in_loop: false, can_ret: false}, v);
2626
}
2727
expr_loop_body(@{node: expr_fn_block(_, b, _), _}) => {
28-
let blk = is_blockish(ty::ty_fn_proto(ty::expr_ty(tcx, e)));
28+
let blk = ty::is_blockish(ty::ty_fn_proto(ty::expr_ty(tcx,
29+
e)));
2930
v.visit_block(b, {in_loop: true, can_ret: blk}, v);
3031
}
3132
expr_break => {

branches/incoming/src/rustc/middle/kind.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
144144

145145
let fty = ty::node_id_to_type(cx.tcx, id);
146146
match ty::ty_fn_proto(fty) {
147-
proto_uniq => b(check_for_uniq),
148-
proto_box => b(check_for_box),
149-
proto_bare => b(check_for_bare),
150-
proto_block => b(check_for_block)
147+
ty::proto_vstore(ty::vstore_uniq) => b(check_for_uniq),
148+
ty::proto_vstore(ty::vstore_box) => b(check_for_box),
149+
ty::proto_bare => b(check_for_bare),
150+
ty::proto_vstore(ty::vstore_slice(_)) => b(check_for_block),
151+
ty::proto_vstore(ty::vstore_fixed(_)) =>
152+
fail ~"fixed vstore not allowed here"
151153
}
152154
}
153155

branches/incoming/src/rustc/middle/mem_categorization.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,18 +383,22 @@ impl &mem_categorization_ctxt {
383383
let ty = ty::node_id_to_type(self.tcx, fn_node_id);
384384
let proto = ty::ty_fn_proto(ty);
385385
match proto {
386-
ast::proto_block => {
386+
ty::proto_vstore(ty::vstore_slice(_)) => {
387387
let upcmt = self.cat_def(id, span, expr_ty, *inner);
388388
@{id:id, span:span,
389389
cat:cat_stack_upvar(upcmt), lp:upcmt.lp,
390390
mutbl:upcmt.mutbl, ty:upcmt.ty}
391391
}
392-
ast::proto_bare | ast::proto_uniq | ast::proto_box => {
392+
ty::proto_bare |
393+
ty::proto_vstore(ty::vstore_uniq) |
394+
ty::proto_vstore(ty::vstore_box) => {
393395
// FIXME #2152 allow mutation of moved upvars
394396
@{id:id, span:span,
395397
cat:cat_special(sk_heap_upvar), lp:none,
396398
mutbl:m_imm, ty:expr_ty}
397399
}
400+
ty::proto_vstore(ty::vstore_fixed(_)) =>
401+
fail ~"fixed vstore not allowed here"
398402
}
399403
}
400404

branches/incoming/src/rustc/middle/region.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,13 @@ fn determine_rp_in_ty(ty: @ast::ty,
496496
}
497497
}
498498

499+
ast::ty_fn(ast::proto_bare, _, _) |
500+
ast::ty_fn(ast::proto_block, _, _) if cx.anon_implies_rp => {
501+
debug!("referenced bare fn type with regions %s",
502+
pprust::ty_to_str(ty));
503+
cx.add_rp(cx.item_id);
504+
}
505+
499506
_ => {}
500507
}
501508

branches/incoming/src/rustc/middle/trans/base.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> {
20432043
}
20442044
ty::ty_trait(_, _) => {
20452045
some(ty::mk_fn(tcx, {purity: ast::impure_fn,
2046-
proto: ast::proto_box,
2046+
proto: ty::proto_vstore(ty::vstore_box),
20472047
bounds: @~[],
20482048
inputs: ~[],
20492049
output: ty::mk_nil(tcx),
@@ -3774,8 +3774,28 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
37743774
}
37753775
ast::expr_addr_of(_, x) => { return trans_addr_of(bcx, x, dest); }
37763776
ast::expr_fn(proto, decl, body, cap_clause) => {
3777-
return closure::trans_expr_fn(bcx, proto, decl, body, e.id,
3778-
cap_clause, none, dest);
3777+
// Don't use this function for anything real. Use the one in
3778+
// astconv instead.
3779+
fn ast_proto_to_proto_simple(ast_proto: ast::proto)
3780+
-> ty::fn_proto {
3781+
match ast_proto {
3782+
ast::proto_bare =>
3783+
ty::proto_bare,
3784+
ast::proto_uniq =>
3785+
ty::proto_vstore(ty::vstore_uniq),
3786+
ast::proto_box =>
3787+
ty::proto_vstore(ty::vstore_box),
3788+
ast::proto_block =>
3789+
ty::proto_vstore(ty::vstore_slice(ty::re_static))
3790+
}
3791+
}
3792+
3793+
// XXX: This syntax should be reworked a bit (in the parser I
3794+
// guess?); @fn() { ... } won't work.
3795+
return closure::trans_expr_fn(bcx,
3796+
ast_proto_to_proto_simple(proto),
3797+
decl, body, e.id, cap_clause, none,
3798+
dest);
37793799
}
37803800
ast::expr_fn_block(decl, body, cap_clause) => {
37813801
match check ty::get(expr_ty(bcx, e)).struct {

branches/incoming/src/rustc/middle/trans/closure.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fn load_environment(fcx: fn_ctxt,
347347
}
348348

349349
fn trans_expr_fn(bcx: block,
350-
proto: ast::proto,
350+
proto: ty::fn_proto,
351351
decl: ast::fn_decl,
352352
body: ast::blk,
353353
id: ast::node_id,
@@ -364,8 +364,8 @@ fn trans_expr_fn(bcx: block,
364364
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);
365365

366366
let trans_closure_env = fn@(ck: ty::closure_kind) -> result {
367-
let cap_vars = capture::compute_capture_vars(
368-
ccx.tcx, id, proto, cap_clause);
367+
let cap_vars = capture::compute_capture_vars(ccx.tcx, id, proto,
368+
cap_clause);
369369
let ret_handle = match is_loop_body { some(x) => x, none => none };
370370
let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id,
371371
ret_handle);
@@ -382,14 +382,19 @@ fn trans_expr_fn(bcx: block,
382382
};
383383

384384
let {bcx: bcx, val: closure} = match proto {
385-
ast::proto_block => trans_closure_env(ty::ck_block),
386-
ast::proto_box => trans_closure_env(ty::ck_box),
387-
ast::proto_uniq => trans_closure_env(ty::ck_uniq),
388-
ast::proto_bare => {
385+
ty::proto_vstore(ty::vstore_slice(_)) =>
386+
trans_closure_env(ty::ck_block),
387+
ty::proto_vstore(ty::vstore_box) =>
388+
trans_closure_env(ty::ck_box),
389+
ty::proto_vstore(ty::vstore_uniq) =>
390+
trans_closure_env(ty::ck_uniq),
391+
ty::proto_bare => {
389392
trans_closure(ccx, sub_path, decl, body, llfn, no_self, none,
390393
id, |_fcx| { }, |_bcx| { });
391394
{bcx: bcx, val: C_null(T_opaque_box_ptr(ccx))}
392395
}
396+
ty::proto_vstore(ty::vstore_fixed(_)) =>
397+
fail ~"vstore_fixed unexpected"
393398
};
394399
fill_fn_pair(bcx, get_dest_addr(dest), llfn, closure);
395400

@@ -416,11 +421,15 @@ fn make_fn_glue(
416421
};
417422

418423
return match ty::get(t).struct {
419-
ty::ty_fn({proto: ast::proto_bare, _}) |
420-
ty::ty_fn({proto: ast::proto_block, _}) => bcx,
421-
ty::ty_fn({proto: ast::proto_uniq, _}) => fn_env(ty::ck_uniq),
422-
ty::ty_fn({proto: ast::proto_box, _}) => fn_env(ty::ck_box),
423-
_ => fail ~"make_fn_glue invoked on non-function type"
424+
ty::ty_fn({proto: ty::proto_bare, _}) |
425+
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_slice(_)), _}) =>
426+
bcx,
427+
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_uniq), _}) =>
428+
fn_env(ty::ck_uniq),
429+
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_box), _}) =>
430+
fn_env(ty::ck_box),
431+
_ =>
432+
fail ~"make_fn_glue invoked on non-function type"
424433
};
425434
}
426435

branches/incoming/src/rustc/middle/trans/foreign.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,8 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
960960
let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]);
961961
let fty = ty::mk_fn(bcx.tcx(), {
962962
purity: ast::impure_fn,
963-
proto: ast::proto_block,
963+
proto:
964+
ty::proto_vstore(ty::vstore_slice(ty::re_bound(ty::br_anon))),
964965
bounds: @~[],
965966
inputs: ~[{
966967
mode: ast::expl(ast::by_val),

branches/incoming/src/rustc/middle/trans/reflect.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ impl reflector {
185185
ast::extern_fn => 3u
186186
};
187187
let protoval = match fty.proto {
188-
ast::proto_bare => 0u,
189-
ast::proto_uniq => 2u,
190-
ast::proto_box => 3u,
191-
ast::proto_block => 4u
188+
ty::proto_bare => 0u,
189+
ty::proto_vstore(ty::vstore_uniq) => 2u,
190+
ty::proto_vstore(ty::vstore_box) => 3u,
191+
ty::proto_vstore(ty::vstore_slice(_)) => 4u,
192+
ty::proto_vstore(ty::vstore_fixed(_)) =>
193+
fail ~"fixed unexpected"
192194
};
193195
let retval = match fty.ret_style {
194196
ast::noreturn => 0u,

0 commit comments

Comments
 (0)