Skip to content

Commit c63c140

Browse files
committed
---
yaml --- r: 2589 b: refs/heads/master c: 37768cb h: refs/heads/master i: 2587: 6f23304 v: v3
1 parent d2469d9 commit c63c140

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f300de2963a35047fbd317002efea9b017cbb916
2+
refs/heads/master: 37768cba92f58c99cc320a02d67165d41d8642f6

trunk/src/comp/middle/typeck.rs

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,29 +1789,22 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
17891789
// A generic function to factor out common logic from call and bind
17901790
// expressions.
17911791
fn check_call_or_bind(&@fn_ctxt fcx, &@ast::expr f,
1792-
&vec[option::t[@ast::expr]] args)
1793-
-> tup(@ast::expr, vec[option::t[@ast::expr]]) {
1792+
&vec[option::t[@ast::expr]] args) {
17941793

17951794
// Check the function.
1796-
auto f_0 = check_expr(fcx, f);
1795+
check_expr(fcx, f);
17971796

17981797
// Check the arguments and generate the argument signature.
17991798
let vec[option::t[@ast::expr]] args_0 = [];
18001799
let vec[arg] arg_tys_0 = [];
18011800
for (option::t[@ast::expr] a_opt in args) {
18021801
alt (a_opt) {
18031802
case (some[@ast::expr](?a)) {
1804-
auto a_0 = check_expr(fcx, a);
1805-
args_0 += [some[@ast::expr](a_0)];
1806-
1807-
auto arg_ty = rec(mode=mo_either,
1808-
ty=expr_ty(fcx.ccx.tcx,
1809-
fcx.ccx.node_types, a_0));
1810-
vec::push[arg](arg_tys_0, arg_ty);
1803+
check_expr(fcx, a);
1804+
auto typ = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types, a);
1805+
vec::push[arg](arg_tys_0, rec(mode=mo_either, ty=typ));
18111806
}
18121807
case (none[@ast::expr]) {
1813-
args_0 += [none[@ast::expr]];
1814-
18151808
auto typ = next_ty_var(fcx.ccx);
18161809
vec::push[arg](arg_tys_0, rec(mode=mo_either, ty=typ));
18171810
}
@@ -1821,7 +1814,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
18211814
auto rt_0 = next_ty_var(fcx.ccx);
18221815
auto t_0;
18231816
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
1824-
f_0))) {
1817+
f))) {
18251818
case (ty::ty_fn(?proto, _, _)) {
18261819
t_0 = ty::mk_fn(fcx.ccx.tcx, proto, arg_tys_0, rt_0);
18271820
}
@@ -1833,19 +1826,17 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
18331826
"check_call_or_bind(): fn expr doesn't have fn type,"
18341827
+ " instead having: " +
18351828
ty_to_str(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx,
1836-
fcx.ccx.node_types, f_0)));
1829+
fcx.ccx.node_types, f)));
18371830
fail;
18381831
}
18391832
}
18401833

18411834
// Unify the callee and arguments.
18421835
auto tpt_0 = ty::expr_ty_params_and_ty(fcx.ccx.tcx,
1843-
fcx.ccx.node_types, f_0);
1836+
fcx.ccx.node_types, f);
18441837
auto tpt_1 = Demand::full(fcx, f.span, tpt_0._1, t_0, tpt_0._0,
18451838
NO_AUTODEREF);
1846-
replace_expr_type(fcx.ccx.node_types, f_0, tpt_1);
1847-
1848-
ret tup(f_0, args_0);
1839+
replace_expr_type(fcx.ccx.node_types, f, tpt_1);
18491840
}
18501841

18511842
// A generic function for checking assignment expressions
@@ -1878,15 +1869,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
18781869
}
18791870

18801871
// Call the generic checker.
1881-
auto result = check_call_or_bind(fcx, f, args_opt_0);
1882-
1883-
// Pull out the arguments.
1884-
let vec[@ast::expr] args_1 = [];
1885-
for (option::t[@ast::expr] arg in result._1) {
1886-
args_1 += [option::get[@ast::expr](arg)];
1887-
}
1872+
check_call_or_bind(fcx, f, args_opt_0);
18881873

1889-
ret tup(result._0, args_1);
1874+
ret tup(f, args);
18901875
}
18911876

18921877
alt (expr.node) {
@@ -2400,14 +2385,14 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
24002385

24012386
case (ast::expr_bind(?f, ?args, ?a)) {
24022387
// Call the generic checker.
2403-
auto result = check_call_or_bind(fcx, f, args);
2388+
check_call_or_bind(fcx, f, args);
24042389

24052390
// Pull the argument and return types out.
24062391
auto proto_1;
24072392
let vec[ty::arg] arg_tys_1 = [];
24082393
auto rt_1;
24092394
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
2410-
result._0))) {
2395+
f))) {
24112396
case (ty::ty_fn(?proto, ?arg_tys, ?rt)) {
24122397
proto_1 = proto;
24132398
rt_1 = rt;
@@ -2435,8 +2420,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
24352420
auto ann = triv_ann(a.id, t_1);
24362421
write_type_only(fcx.ccx.node_types, a.id, t_1);
24372422
ret @fold::respan[ast::expr_](expr.span,
2438-
ast::expr_bind(result._0, result._1,
2439-
ann));
2423+
ast::expr_bind(f, args, ann));
24402424
}
24412425

24422426
case (ast::expr_call(?f, ?args, ?a)) {

0 commit comments

Comments
 (0)