@@ -1789,29 +1789,22 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
1789
1789
// A generic function to factor out common logic from call and bind
1790
1790
// expressions.
1791
1791
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) {
1794
1793
1795
1794
// Check the function.
1796
- auto f_0 = check_expr( fcx, f) ;
1795
+ check_expr( fcx, f) ;
1797
1796
1798
1797
// Check the arguments and generate the argument signature.
1799
1798
let vec[ option:: t[ @ast:: expr] ] args_0 = [ ] ;
1800
1799
let vec[ arg] arg_tys_0 = [ ] ;
1801
1800
for ( option:: t[ @ast:: expr] a_opt in args) {
1802
1801
alt ( a_opt) {
1803
1802
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) ) ;
1811
1806
}
1812
1807
case ( none[ @ast:: expr] ) {
1813
- args_0 += [ none[ @ast:: expr] ] ;
1814
-
1815
1808
auto typ = next_ty_var( fcx. ccx) ;
1816
1809
vec:: push[ arg] ( arg_tys_0, rec( mode=mo_either, ty=typ) ) ;
1817
1810
}
@@ -1821,7 +1814,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
1821
1814
auto rt_0 = next_ty_var( fcx. ccx) ;
1822
1815
auto t_0;
1823
1816
alt ( struct ( fcx. ccx. tcx, expr_ty( fcx. ccx. tcx, fcx. ccx. node_types,
1824
- f_0 ) ) ) {
1817
+ f ) ) ) {
1825
1818
case ( ty:: ty_fn( ?proto, _, _) ) {
1826
1819
t_0 = ty:: mk_fn( fcx. ccx. tcx, proto, arg_tys_0, rt_0) ;
1827
1820
}
@@ -1833,19 +1826,17 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
1833
1826
"check_call_or_bind(): fn expr doesn't have fn type,"
1834
1827
+ " instead having: " +
1835
1828
ty_to_str( fcx. ccx. tcx, expr_ty( fcx. ccx. tcx,
1836
- fcx. ccx. node_types, f_0 ) ) ) ;
1829
+ fcx. ccx. node_types, f ) ) ) ;
1837
1830
fail;
1838
1831
}
1839
1832
}
1840
1833
1841
1834
// Unify the callee and arguments.
1842
1835
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 ) ;
1844
1837
auto tpt_1 = Demand :: full( fcx, f. span, tpt_0. _1, t_0, tpt_0. _0,
1845
1838
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) ;
1849
1840
}
1850
1841
1851
1842
// A generic function for checking assignment expressions
@@ -1878,15 +1869,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
1878
1869
}
1879
1870
1880
1871
// 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) ;
1888
1873
1889
- ret tup( result . _0 , args_1 ) ;
1874
+ ret tup( f , args ) ;
1890
1875
}
1891
1876
1892
1877
alt ( expr. node) {
@@ -2400,14 +2385,14 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2400
2385
2401
2386
case ( ast:: expr_bind( ?f, ?args, ?a) ) {
2402
2387
// Call the generic checker.
2403
- auto result = check_call_or_bind( fcx, f, args) ;
2388
+ check_call_or_bind( fcx, f, args) ;
2404
2389
2405
2390
// Pull the argument and return types out.
2406
2391
auto proto_1;
2407
2392
let vec[ ty:: arg] arg_tys_1 = [ ] ;
2408
2393
auto rt_1;
2409
2394
alt ( struct( fcx. ccx. tcx, expr_ty( fcx. ccx. tcx, fcx. ccx. node_types,
2410
- result . _0 ) ) ) {
2395
+ f ) ) ) {
2411
2396
case ( ty:: ty_fn( ?proto, ?arg_tys, ?rt) ) {
2412
2397
proto_1 = proto;
2413
2398
rt_1 = rt;
@@ -2435,8 +2420,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2435
2420
auto ann = triv_ann ( a. id , t_1 ) ;
2436
2421
write_type_only ( fcx. ccx. node_types , a. id , t_1 ) ;
2437
2422
ret @fold:: respan [ ast:: expr_ ] ( expr . span,
2438
- ast:: expr_bind ( result . _0, result . _1,
2439
- ann ) ) ;
2423
+ ast:: expr_bind ( f , args , ann ) ) ;
2440
2424
}
2441
2425
2442
2426
case ( ast:: expr_call ( ?f , ?args , ?a ) ) {
0 commit comments