Skip to content

Commit 7634e29

Browse files
committed
Revert "rustc: Make function types have vstores in them"
This reverts commit 0101125.
1 parent 1b32b13 commit 7634e29

22 files changed

+114
-237
lines changed

src/rustc/metadata/tydecode.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ 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(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)
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)
9395
}
9496
}
9597
@@ -358,7 +360,7 @@ fn parse_purity(c: char) -> purity {
358360
}
359361

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

src/rustc/metadata/tyencode.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,12 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
306306
}
307307
}
308308
}
309-
310-
fn enc_proto(w: io::writer, cx: @ctxt, proto: ty::fn_proto) {
311-
w.write_str(&"f");
309+
fn enc_proto(w: io::writer, proto: proto) {
312310
match proto {
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-
}
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")
318315
}
319316
}
320317

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

340337
fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) {
341-
enc_proto(w, cx, ft.proto);
338+
enc_proto(w, ft.proto);
342339
enc_purity(w, ft.purity);
343340
enc_bounds(w, cx, ft.bounds);
344341
w.write_char('[');

src/rustc/middle/block_use.rs

+1-1
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 ty::is_blockish(p) => {
17+
ty::ty_fn({proto: p, _}) if 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");

src/rustc/middle/borrowck/check_loans.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ 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-
return ty::is_blockish(proto);
221+
match proto {
222+
ast::proto_block => true,
223+
ast::proto_bare | ast::proto_uniq | ast::proto_box => false
224+
}
222225
}
223226

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

src/rustc/middle/capture.rs

+5-7
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: ty::fn_proto,
62+
fn_proto: ast::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,12 +101,10 @@ 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;
105-
if ty::is_blockish(fn_proto) {
106-
implicit_mode = cap_ref;
107-
} else {
108-
implicit_mode = cap_copy;
109-
}
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+
};
110108

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

src/rustc/middle/check_loop.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ 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 = ty::is_blockish(ty::ty_fn_proto(ty::expr_ty(tcx,
29-
e)));
28+
let blk = is_blockish(ty::ty_fn_proto(ty::expr_ty(tcx, e)));
3029
v.visit_block(b, {in_loop: true, can_ret: blk}, v);
3130
}
3231
expr_break => {

src/rustc/middle/kind.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,10 @@ 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-
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"
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)
153151
}
154152
}
155153

src/rustc/middle/mem_categorization.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -383,22 +383,18 @@ 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-
ty::proto_vstore(ty::vstore_slice(_)) => {
386+
ast::proto_block => {
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-
ty::proto_bare |
393-
ty::proto_vstore(ty::vstore_uniq) |
394-
ty::proto_vstore(ty::vstore_box) => {
392+
ast::proto_bare | ast::proto_uniq | ast::proto_box => {
395393
// FIXME #2152 allow mutation of moved upvars
396394
@{id:id, span:span,
397395
cat:cat_special(sk_heap_upvar), lp:none,
398396
mutbl:m_imm, ty:expr_ty}
399397
}
400-
ty::proto_vstore(ty::vstore_fixed(_)) =>
401-
fail ~"fixed vstore not allowed here"
402398
}
403399
}
404400

src/rustc/middle/trans/base.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -2043,8 +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: ty::proto_vstore(ty::vstore_slice
2047-
(ty::re_static)),
2046+
proto: ast::proto_box,
20482047
bounds: @~[],
20492048
inputs: ~[],
20502049
output: ty::mk_nil(tcx),
@@ -3775,11 +3774,8 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
37753774
}
37763775
ast::expr_addr_of(_, x) => { return trans_addr_of(bcx, x, dest); }
37773776
ast::expr_fn(proto, decl, body, cap_clause) => {
3778-
// XXX: This syntax should be reworked a bit (in the parser I
3779-
// guess?); @fn() { ... } won't work.
3780-
return closure::trans_expr_fn(bcx, ty::ast_proto_to_proto(proto),
3781-
decl, body, e.id, cap_clause, none,
3782-
dest);
3777+
return closure::trans_expr_fn(bcx, proto, decl, body, e.id,
3778+
cap_clause, none, dest);
37833779
}
37843780
ast::expr_fn_block(decl, body, cap_clause) => {
37853781
match check ty::get(expr_ty(bcx, e)).struct {

src/rustc/middle/trans/closure.rs

+12-21
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: ty::fn_proto,
350+
proto: ast::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(ccx.tcx, id, proto,
368-
cap_clause);
367+
let cap_vars = capture::compute_capture_vars(
368+
ccx.tcx, id, proto, 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,19 +382,14 @@ fn trans_expr_fn(bcx: block,
382382
};
383383

384384
let {bcx: bcx, val: closure} = match proto {
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 => {
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 => {
392389
trans_closure(ccx, sub_path, decl, body, llfn, no_self, none,
393390
id, |_fcx| { }, |_bcx| { });
394391
{bcx: bcx, val: C_null(T_opaque_box_ptr(ccx))}
395392
}
396-
ty::proto_vstore(ty::vstore_fixed(_)) =>
397-
fail ~"vstore_fixed unexpected"
398393
};
399394
fill_fn_pair(bcx, get_dest_addr(dest), llfn, closure);
400395

@@ -421,15 +416,11 @@ fn make_fn_glue(
421416
};
422417

423418
return match ty::get(t).struct {
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"
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"
433424
};
434425
}
435426

src/rustc/middle/trans/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ 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: ty::proto_vstore(ty::vstore_slice(ty::re_static)),
963+
proto: ast::proto_block,
964964
bounds: @~[],
965965
inputs: ~[{
966966
mode: ast::expl(ast::by_val),

src/rustc/middle/trans/reflect.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,10 @@ impl reflector {
185185
ast::extern_fn => 3u
186186
};
187187
let protoval = match fty.proto {
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"
188+
ast::proto_bare => 0u,
189+
ast::proto_uniq => 2u,
190+
ast::proto_box => 3u,
191+
ast::proto_block => 4u
194192
};
195193
let retval = match fty.ret_style {
196194
ast::noreturn => 0u,

src/rustc/middle/trans/shape.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,14 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
351351
ty::ty_param(*) => {
352352
ccx.tcx.sess.bug(~"non-monomorphized type parameter");
353353
}
354-
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_box), _}) =>
355-
~[shape_box_fn],
356-
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_uniq), _}) =>
357-
~[shape_uniq_fn],
358-
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_slice(_)), _}) =>
359-
~[shape_stack_fn],
360-
ty::ty_fn({proto: ty::proto_vstore(ty::vstore_fixed(_)), _}) =>
361-
fail ~"fixed vstore is impossible",
362-
ty::ty_fn({proto: ty::proto_bare, _}) =>
363-
~[shape_bare_fn],
364-
ty::ty_opaque_closure_ptr(_) =>
365-
~[shape_opaque_closure_ptr],
366-
ty::ty_var(_) | ty::ty_var_integral(_) | ty::ty_self =>
367-
ccx.sess.bug(~"shape_of: unexpected type struct found")
354+
ty::ty_fn({proto: ast::proto_box, _}) => ~[shape_box_fn],
355+
ty::ty_fn({proto: ast::proto_uniq, _}) => ~[shape_uniq_fn],
356+
ty::ty_fn({proto: ast::proto_block, _}) => ~[shape_stack_fn],
357+
ty::ty_fn({proto: ast::proto_bare, _}) => ~[shape_bare_fn],
358+
ty::ty_opaque_closure_ptr(_) => ~[shape_opaque_closure_ptr],
359+
ty::ty_var(_) | ty::ty_var_integral(_) | ty::ty_self => {
360+
ccx.sess.bug(~"shape_of: unexpected type struct found");
361+
}
368362
}
369363
}
370364

src/rustc/middle/trans/type_use.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,13 @@ fn mark_for_expr(cx: ctx, e: @expr) {
202202
}
203203
expr_fn(*) | expr_fn_block(*) => {
204204
match ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) {
205-
ty::proto_bare | ty::proto_vstore(ty::vstore_uniq) => {}
206-
ty::proto_vstore(ty::vstore_box) |
207-
ty::proto_vstore(ty::vstore_slice(_)) => {
205+
proto_bare | proto_uniq => {}
206+
proto_box | proto_block => {
208207
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
209208
let node_id = ast_util::def_id_of_def(fv.def).node;
210209
node_type_needs(cx, use_repr, node_id);
211210
}
212211
}
213-
ty::proto_vstore(ty::vstore_fixed(_)) =>
214-
fail ~"vstore_fixed not allowed here"
215212
}
216213
}
217214
expr_assign(val, _) | expr_swap(val, _) | expr_assign_op(_, val, _) |

0 commit comments

Comments
 (0)