Skip to content

Commit f8f6f07

Browse files
committed
There are no native iterators (or at least they are not going to be supported
soon.).
1 parent 3d04fa0 commit f8f6f07

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

src/comp/front/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ tag ty_ {
235235

236236
type arg = rec(mode mode, @ty ty, ident ident, def_id id);
237237
type fn_decl = rec(effect effect,
238-
proto proto,
239238
vec[arg] inputs,
240239
@ty output);
241240
type _fn = rec(fn_decl decl,
241+
proto proto,
242242
block body);
243243

244244

src/comp/front/parser.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,7 @@ impure fn parse_ty_params(parser p) -> vec[ast.ty_param] {
16171617
ret ty_params;
16181618
}
16191619

1620-
impure fn parse_fn_decl(parser p, ast.proto proto,
1621-
ast.effect eff) -> ast.fn_decl {
1620+
impure fn parse_fn_decl(parser p, ast.effect eff) -> ast.fn_decl {
16221621
auto pf = parse_arg;
16231622
let util.common.spanned[vec[ast.arg]] inputs =
16241623
// FIXME: passing parse_arg as an lval doesn't work at the
@@ -1636,32 +1635,32 @@ impure fn parse_fn_decl(parser p, ast.proto proto,
16361635
} else {
16371636
output = @spanned(inputs.span, inputs.span, ast.ty_nil);
16381637
}
1639-
ret rec(effect=eff, proto=proto,
1640-
inputs=inputs.node, output=output);
1638+
ret rec(effect=eff, inputs=inputs.node, output=output);
16411639
}
16421640

16431641
impure fn parse_fn(parser p, ast.effect eff, ast.proto proto) -> ast._fn {
1644-
auto decl = parse_fn_decl(p, proto, eff);
1642+
auto decl = parse_fn_decl(p, eff);
16451643
auto body = parse_block(p);
16461644
ret rec(decl = decl,
1645+
proto = proto,
16471646
body = body);
16481647
}
16491648

16501649
impure fn parse_fn_header(parser p)
1651-
-> tup(span, ast.proto, ast.ident, vec[ast.ty_param]) {
1652-
auto lo = p.get_span();
1653-
auto proto = parse_proto(p);
1650+
-> tup(ast.ident, vec[ast.ty_param]) {
16541651
auto id = parse_ident(p);
16551652
auto ty_params = parse_ty_params(p);
1656-
ret tup(lo, proto, id, ty_params);
1653+
ret tup(id, ty_params);
16571654
}
16581655

16591656
impure fn parse_item_fn_or_iter(parser p, ast.effect eff) -> @ast.item {
1657+
auto lo = p.get_span();
1658+
auto proto = parse_proto(p);
16601659
auto t = parse_fn_header(p);
1661-
auto f = parse_fn(p, eff, t._1);
1662-
auto item = ast.item_fn(t._2, f, t._3,
1660+
auto f = parse_fn(p, eff, proto);
1661+
auto item = ast.item_fn(t._0, f, t._1,
16631662
p.next_def_id(), ast.ann_none);
1664-
ret @spanned(t._0, f.body.span, item);
1663+
ret @spanned(lo, f.body.span, item);
16651664
}
16661665

16671666

@@ -1760,13 +1759,15 @@ impure fn parse_item_native_type(parser p) -> @ast.native_item {
17601759
}
17611760

17621761
impure fn parse_item_native_fn(parser p, ast.effect eff) -> @ast.native_item {
1762+
auto lo = p.get_span();
1763+
expect(p, token.FN);
17631764
auto t = parse_fn_header(p);
1764-
auto decl = parse_fn_decl(p, t._1, eff);
1765+
auto decl = parse_fn_decl(p, eff);
17651766
auto hi = p.get_span();
17661767
expect(p, token.SEMI);
1767-
auto item = ast.native_item_fn(t._2, decl, t._3, p.next_def_id(),
1768+
auto item = ast.native_item_fn(t._0, decl, t._1, p.next_def_id(),
17681769
ast.ann_none);
1769-
ret @spanned(t._0, hi, item);
1770+
ret @spanned(lo, hi, item);
17701771
}
17711772

17721773
impure fn parse_native_item(parser p) -> @ast.native_item {

src/comp/middle/fold.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,11 @@ type ast_fold[ENV] =
253253
&ast.block_) -> block) fold_block,
254254

255255
(fn(&ENV e, &fn_decl decl,
256+
ast.proto proto,
256257
&block body) -> ast._fn) fold_fn,
257258

258259
(fn(&ENV e, ast.effect effect,
259-
ast.proto proto, vec[arg] inputs,
260+
vec[arg] inputs,
260261
@ty output) -> ast.fn_decl) fold_fn_decl,
261262

262263
(fn(&ENV e, &ast._mod m) -> ast._mod) fold_mod,
@@ -757,15 +758,15 @@ fn fold_fn_decl[ENV](&ENV env, ast_fold[ENV] fld,
757758
inputs += fold_arg(env, fld, a);
758759
}
759760
auto output = fold_ty[ENV](env, fld, decl.output);
760-
ret fld.fold_fn_decl(env, decl.effect, decl.proto, inputs, output);
761+
ret fld.fold_fn_decl(env, decl.effect, inputs, output);
761762
}
762763

763764
fn fold_fn[ENV](&ENV env, ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
764765
auto decl = fold_fn_decl(env, fld, f.decl);
765766

766767
auto body = fold_block[ENV](env, fld, f.body);
767768

768-
ret fld.fold_fn(env, decl, body);
769+
ret fld.fold_fn(env, decl, f.proto, body);
769770
}
770771

771772

@@ -1306,16 +1307,16 @@ fn identity_fold_block[ENV](&ENV e, &span sp, &ast.block_ blk) -> block {
13061307

13071308
fn identity_fold_fn_decl[ENV](&ENV e,
13081309
ast.effect effect,
1309-
ast.proto proto,
13101310
vec[arg] inputs,
13111311
@ty output) -> ast.fn_decl {
1312-
ret rec(effect=effect, proto=proto, inputs=inputs, output=output);
1312+
ret rec(effect=effect, inputs=inputs, output=output);
13131313
}
13141314

13151315
fn identity_fold_fn[ENV](&ENV e,
13161316
&fn_decl decl,
1317+
ast.proto proto,
13171318
&block body) -> ast._fn {
1318-
ret rec(decl=decl, body=body);
1319+
ret rec(decl=decl, proto=proto, body=body);
13191320
}
13201321

13211322
fn identity_fold_mod[ENV](&ENV e, &ast._mod m) -> ast._mod {
@@ -1475,8 +1476,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
14751476
bind identity_fold_view_item_import[ENV](_,_,_,_,_,_),
14761477

14771478
fold_block = bind identity_fold_block[ENV](_,_,_),
1478-
fold_fn = bind identity_fold_fn[ENV](_,_,_),
1479-
fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_,_,_),
1479+
fold_fn = bind identity_fold_fn[ENV](_,_,_,_),
1480+
fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_,_),
14801481
fold_mod = bind identity_fold_mod[ENV](_,_),
14811482
fold_native_mod = bind identity_fold_native_mod[ENV](_,_),
14821483
fold_crate = bind identity_fold_crate[ENV](_,_,_),

src/comp/middle/trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4019,7 +4019,7 @@ fn trans_fn(@crate_ctxt cx, &ast._fn f, ast.def_id fid,
40194019
cx.item_names.insert(cx.path, llfndecl);
40204020

40214021
auto fcx = new_fn_ctxt(cx, cx.path, llfndecl);
4022-
create_llargs_for_fn_args(fcx, f.decl.proto,
4022+
create_llargs_for_fn_args(fcx, f.proto,
40234023
ty_self, ret_ty_of_fn(ann),
40244024
f.decl.inputs, ty_params);
40254025
auto bcx = new_top_block_ctxt(fcx);

src/comp/middle/typeck.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,11 @@ fn ty_of_fn_decl(@ty_item_table id_to_ty_item,
332332
fn(&@ast.ty ast_ty) -> @ty.t convert,
333333
fn(&ast.arg a) -> arg ty_of_arg,
334334
&ast.fn_decl decl,
335+
ast.proto proto,
335336
ast.def_id def_id) -> @ty.t {
336337
auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
337338
auto output_ty = convert(decl.output);
338-
auto t_fn = plain_ty(ty.ty_fn(decl.proto, input_tys, output_ty));
339+
auto t_fn = plain_ty(ty.ty_fn(proto, input_tys, output_ty));
339340
item_to_ty.insert(def_id, t_fn);
340341
ret t_fn;
341342
}
@@ -394,7 +395,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
394395
auto f = bind ty_of_arg(id_to_ty_item, item_to_ty, _);
395396
auto inputs = _vec.map[ast.arg,arg](f, m.node.meth.decl.inputs);
396397
auto output = convert(m.node.meth.decl.output);
397-
ret rec(proto=m.node.meth.decl.proto, ident=m.node.ident,
398+
ret rec(proto=m.node.meth.proto, ident=m.node.ident,
398399
inputs=inputs, output=output);
399400
}
400401

@@ -446,7 +447,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
446447
case (ast.item_fn(?ident, ?fn_info, _, ?def_id, _)) {
447448
auto f = bind ty_of_arg(id_to_ty_item, item_to_ty, _);
448449
ret ty_of_fn_decl(id_to_ty_item, item_to_ty, convert, f,
449-
fn_info.decl, def_id);
450+
fn_info.decl, fn_info.proto, def_id);
450451
}
451452

452453
case (ast.item_obj(?ident, ?obj_info, _, ?def_id, _)) {
@@ -2155,7 +2156,8 @@ fn check_const(&@crate_ctxt ccx, &span sp, ast.ident ident, @ast.ty t,
21552156
ret @fold.respan[ast.item_](sp, item);
21562157
}
21572158

2158-
fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, &ast.block body) -> ast._fn {
2159+
fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, ast.proto proto,
2160+
&ast.block body) -> ast._fn {
21592161
auto local_ty_table = @common.new_def_hash[@ty.t]();
21602162

21612163
// FIXME: duplicate work: the item annotation already has the arg types
@@ -2182,8 +2184,9 @@ fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, &ast.block body) -> ast._fn {
21822184
auto block_t = check_block(fcx, body);
21832185
auto block_wb = writeback(fcx, block_t);
21842186

2185-
auto fn_t = rec(decl=decl,
2186-
body=block_wb);
2187+
auto fn_t = rec(decl=decl,
2188+
proto=proto,
2189+
body=block_wb);
21872190
ret fn_t;
21882191
}
21892192

@@ -2202,7 +2205,7 @@ fn check_item_fn(&@crate_ctxt ccx, &span sp, ast.ident ident, &ast._fn f,
22022205
}
22032206

22042207
auto output_ty = ast_ty_to_ty_crate(ccx, f.decl.output);
2205-
auto fn_sty = ty.ty_fn(f.decl.proto, inputs, output_ty);
2208+
auto fn_sty = ty.ty_fn(f.proto, inputs, output_ty);
22062209
auto fn_ann = ast.ann_type(plain_ty(fn_sty));
22072210

22082211
auto item = ast.item_fn(ident, f, ty_params, id, fn_ann);
@@ -2234,7 +2237,7 @@ fn check_crate(session.session sess, @ast.crate crate) -> @ast.crate {
22342237
auto fld = fold.new_identity_fold[@crate_ctxt]();
22352238

22362239
fld = @rec(update_env_for_item = bind update_obj_fields(_, _),
2237-
fold_fn = bind check_fn(_,_,_),
2240+
fold_fn = bind check_fn(_,_,_,_),
22382241
fold_item_fn = bind check_item_fn(_,_,_,_,_,_,_)
22392242
with *fld);
22402243
ret fold.fold_crate[@crate_ctxt](ccx, fld, result._0);

0 commit comments

Comments
 (0)