Skip to content

Commit cfa09d3

Browse files
committed
Revert "allow fn exprs to omit arg types"
This reverts commit 1ba4ca4.
1 parent 1ba4ca4 commit cfa09d3

File tree

10 files changed

+103
-178
lines changed

10 files changed

+103
-178
lines changed

src/libcore/vec.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,14 +1096,6 @@ impl extensions<T> for [T] {
10961096
#[inline]
10971097
fn map<U>(f: fn(T) -> U) -> [U] { map(self, f) }
10981098
#[doc = "
1099-
Apply a function to the index and value of each element in the vector
1100-
and return the results
1101-
"]
1102-
fn mapi<U>(f: fn(uint, T) -> U) -> [U] {
1103-
let mut i = 0u;
1104-
self.map { |e| i += 1u; f(i - 1u, e) }
1105-
}
1106-
#[doc = "
11071099
Apply a function to each element of a vector and return a concatenation
11081100
of each result vector
11091101
"]

src/librustsyntax/parse/parser.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ fn parse_capture_clause(p: parser) -> @ast::capture_clause {
12061206
fn parse_fn_expr(p: parser, proto: ast::proto) -> @ast::expr {
12071207
let lo = p.last_span.lo;
12081208
let capture_clause = parse_capture_clause(p);
1209-
let decl = parse_fn_decl(p, ast::impure_fn, parse_fn_block_arg);
1209+
let decl = parse_fn_decl(p, ast::impure_fn);
12101210
let body = parse_block(p);
12111211
ret mk_expr(p, lo, body.span.hi,
12121212
ast::expr_fn(proto, decl, body, capture_clause));
@@ -1699,12 +1699,11 @@ fn parse_ty_params(p: parser) -> [ast::ty_param] {
16991699
} else { [] }
17001700
}
17011701

1702-
fn parse_fn_decl(p: parser, purity: ast::purity,
1703-
parse_arg_fn: fn(parser) -> ast::arg)
1702+
fn parse_fn_decl(p: parser, purity: ast::purity)
17041703
-> ast::fn_decl {
17051704
let inputs: ast::spanned<[ast::arg]> =
17061705
parse_seq(token::LPAREN, token::RPAREN, seq_sep(token::COMMA),
1707-
parse_arg_fn, p);
1706+
parse_arg, p);
17081707
// Use the args list to translate each bound variable
17091708
// mentioned in a constraint to an arg index.
17101709
// Seems weird to do this in the parser, but I'm not sure how else to.
@@ -1761,7 +1760,7 @@ fn parse_item_fn(p: parser, purity: ast::purity,
17611760
attrs: [ast::attribute]) -> @ast::item {
17621761
let lo = p.last_span.lo;
17631762
let t = parse_fn_header(p);
1764-
let decl = parse_fn_decl(p, purity, parse_arg);
1763+
let decl = parse_fn_decl(p, purity);
17651764
let (inner_attrs, body) = parse_inner_attrs_and_block(p, true);
17661765
let attrs = attrs + inner_attrs;
17671766
ret mk_item(p, lo, body.span.hi, t.ident,
@@ -1786,7 +1785,7 @@ fn parse_method(p: parser, pr: ast::privacy) -> @ast::method {
17861785
let lo = p.span.lo, pur = parse_fn_purity(p);
17871786
let ident = parse_method_name(p);
17881787
let tps = parse_ty_params(p);
1789-
let decl = parse_fn_decl(p, pur, parse_arg);
1788+
let decl = parse_fn_decl(p, pur);
17901789
let (inner_attrs, body) = parse_inner_attrs_and_block(p, true);
17911790
let attrs = attrs + inner_attrs;
17921791
@{ident: ident, attrs: attrs, tps: tps, decl: decl, body: body,
@@ -1970,7 +1969,7 @@ fn parse_class_item(p:parser, class_name_with_tps: @ast::path)
19701969
let lo = p.last_span.lo;
19711970
// Can ctors have attrs?
19721971
// result type is always the type of the class
1973-
let decl_ = parse_fn_decl(p, ast::impure_fn, parse_arg);
1972+
let decl_ = parse_fn_decl(p, ast::impure_fn);
19741973
let decl = {output: @{id: p.get_id(),
19751974
node: ast::ty_path(class_name_with_tps, p.get_id()),
19761975
span: decl_.output.span}
@@ -2049,7 +2048,7 @@ fn parse_item_native_fn(p: parser, attrs: [ast::attribute],
20492048
purity: ast::purity) -> @ast::native_item {
20502049
let lo = p.last_span.lo;
20512050
let t = parse_fn_header(p);
2052-
let decl = parse_fn_decl(p, purity, parse_arg);
2051+
let decl = parse_fn_decl(p, purity);
20532052
let mut hi = p.span.hi;
20542053
expect(p, token::SEMI);
20552054
ret @{ident: t.ident,

src/librustsyntax/print/pprust.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,13 @@ fn print_cap_clause(s: ps, cap_clause: ast::capture_clause) {
13511351

13521352
fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl) {
13531353
popen(s);
1354+
fn print_arg(s: ps, x: ast::arg) {
1355+
ibox(s, indent_unit);
1356+
print_arg_mode(s, x.mode);
1357+
word_space(s, x.ident + ":");
1358+
print_type(s, x.ty);
1359+
end(s);
1360+
}
13541361
commasep(s, inconsistent, decl.inputs, print_arg);
13551362
pclose(s);
13561363
word(s.s, constrs_str(decl.constraints, {|c|
@@ -1367,6 +1374,16 @@ fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl) {
13671374

13681375
fn print_fn_block_args(s: ps, decl: ast::fn_decl) {
13691376
word(s.s, "|");
1377+
fn print_arg(s: ps, x: ast::arg) {
1378+
ibox(s, indent_unit);
1379+
print_arg_mode(s, x.mode);
1380+
word(s.s, x.ident);
1381+
if x.ty.node != ast::ty_infer {
1382+
word_space(s, ":");
1383+
print_type(s, x.ty);
1384+
}
1385+
end(s);
1386+
}
13701387
commasep(s, inconsistent, decl.inputs, print_arg);
13711388
word(s.s, "|");
13721389
if decl.output.node != ast::ty_infer {
@@ -1524,23 +1541,6 @@ fn print_mt(s: ps, mt: ast::mt) {
15241541
print_type(s, mt.ty);
15251542
}
15261543

1527-
fn print_arg(s: ps, input: ast::arg) {
1528-
ibox(s, indent_unit);
1529-
print_arg_mode(s, input.mode);
1530-
alt input.ty.node {
1531-
ast::ty_infer {
1532-
word(s.s, input.ident);
1533-
}
1534-
_ {
1535-
if str::len(input.ident) > 0u {
1536-
word_space(s, input.ident + ":");
1537-
}
1538-
print_type(s, input.ty);
1539-
}
1540-
}
1541-
end(s);
1542-
}
1543-
15441544
fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
15451545
decl: ast::fn_decl, id: option<ast::ident>,
15461546
tps: option<[ast::ty_param]>) {
@@ -1550,6 +1550,13 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
15501550
alt tps { some(tps) { print_type_params(s, tps); } _ { } }
15511551
zerobreak(s.s);
15521552
popen(s);
1553+
fn print_arg(s: ps, input: ast::arg) {
1554+
print_arg_mode(s, input.mode);
1555+
if str::len(input.ident) > 0u {
1556+
word_space(s, input.ident + ":");
1557+
}
1558+
print_type(s, input.ty);
1559+
}
15531560
commasep(s, inconsistent, decl.inputs, print_arg);
15541561
pclose(s);
15551562
maybe_print_comment(s, decl.output.span.lo);

0 commit comments

Comments
 (0)