Skip to content

Commit 6473b73

Browse files
committed
rustc: Use demand functions instead of open-coded typecheck for spawn
Un-xfail spawn-non-nil-fn
1 parent 0c1ea14 commit 6473b73

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

src/comp/middle/typeck.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,23 +2386,8 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
23862386
case (ast::expr_spawn(_, _, ?f, ?args, ?a)) {
23872387
check_call(scx, f, args);
23882388

2389-
// Check the return type
23902389
auto fty = expr_ty(scx.fcx.ccx.tcx, f);
2391-
alt (struct(scx.fcx.ccx.tcx, fty)) {
2392-
case (ty::ty_fn(_,_,?rt,_)) {
2393-
alt (struct(scx.fcx.ccx.tcx, rt)) {
2394-
case (ty::ty_nil) {
2395-
// This is acceptable
2396-
}
2397-
case (_) {
2398-
auto err = "non-nil return type in "
2399-
+ "spawned function";
2400-
scx.fcx.ccx.tcx.sess.span_err(expr.span, err);
2401-
fail;
2402-
}
2403-
}
2404-
}
2405-
}
2390+
Demand::simple(scx, f.span, ty::mk_nil(scx.fcx.ccx.tcx), fty);
24062391

24072392
// FIXME: Other typechecks needed
24082393

src/test/compile-fail/spawn-non-nil-fn.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
42
// error-pattern: mismatched types
53

64
fn f(int x) -> int {

0 commit comments

Comments
 (0)