@@ -1316,7 +1316,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1316
1316
_ { none }
1317
1317
}
1318
1318
}
1319
- ast::not | ast::neg { some( expected.get()) }
1319
+ ast::not | ast::neg { expected }
1320
1320
ast::deref { none }
1321
1321
}
1322
1322
};
@@ -1475,10 +1475,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1475
1475
capture::check_capture_clause(tcx, expr.id, cap_clause);
1476
1476
}
1477
1477
ast::expr_fn_block(decl, body, cap_clause) {
1478
+ let proto = unpack_expected(fcx, expected, |sty|
1479
+ alt sty { ty::ty_fn({proto, _}) { some(proto) } _ { none } }
1480
+ ).get_default(ast::proto_box);
1478
1481
// Take the prototype from the expected type, but default to block:
1479
- let proto = unpack_expected(fcx, expected, |sty|
1480
- alt sty { ty::ty_fn({proto, _}) { some(proto) } _ { none } }
1481
- ).get_default(ast::proto_box);
1482
+ let proto = proto_1.get_default(ast::proto_box);
1482
1483
check_expr_fn(fcx, expr, proto, decl, body, false, expected);
1483
1484
capture::check_capture_clause(tcx, expr.id, cap_clause);
1484
1485
}
@@ -1489,9 +1490,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1489
1490
// parameter. The catch here is that we need to validate two things:
1490
1491
// 1. a closure that returns a bool is expected
1491
1492
// 2. the cloure that was given returns unit
1492
- let expected_sty = unpack_expected(fcx, expected, |x| some(x)).get() ;
1493
+ let expected_sty = unpack_expected(fcx, expected, |x| some(x));
1493
1494
let (inner_ty, proto) = alt expected_sty {
1494
- ty::ty_fn(fty) {
1495
+ some( ty::ty_fn(fty) ) {
1495
1496
alt infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) {
1496
1497
result::ok(_) {}
1497
1498
result::err(err) {
@@ -1526,14 +1527,15 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1526
1527
}
1527
1528
}
1528
1529
ast::expr_do_body(b) {
1529
- let expected_sty = unpack_expected(fcx, expected, |x| some(x)).get() ;
1530
+ let expected_sty = unpack_expected(fcx, expected, |x| some(x));
1530
1531
let (inner_ty, proto) = alt expected_sty {
1531
- ty::ty_fn(fty) {
1532
+ some( ty::ty_fn(fty) ) {
1532
1533
(ty::mk_fn(tcx, fty), fty.proto)
1533
1534
}
1534
1535
_ {
1535
- tcx.sess.span_fatal(expr.span, ~" a `do` function' s last argument \
1536
- should be of function type ");
1536
+ tcx.sess.span_fatal(expr.span, ~" Non -function passed to a `do` \
1537
+ function as its last argument, or wrong number of arguments \
1538
+ passed to a `do` function");
1537
1539
}
1538
1540
};
1539
1541
alt check b.node {
0 commit comments