From 6473b73174afc54198c4105f7fa927f04a71e04e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 24 May 2011 20:19:36 -0400 Subject: [PATCH] rustc: Use demand functions instead of open-coded typecheck for spawn Un-xfail spawn-non-nil-fn --- src/comp/middle/typeck.rs | 17 +---------------- src/test/compile-fail/spawn-non-nil-fn.rs | 2 -- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index fd02f76d816d..5fd242c239fa 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -2386,23 +2386,8 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) { case (ast::expr_spawn(_, _, ?f, ?args, ?a)) { check_call(scx, f, args); - // Check the return type auto fty = expr_ty(scx.fcx.ccx.tcx, f); - alt (struct(scx.fcx.ccx.tcx, fty)) { - case (ty::ty_fn(_,_,?rt,_)) { - alt (struct(scx.fcx.ccx.tcx, rt)) { - case (ty::ty_nil) { - // This is acceptable - } - case (_) { - auto err = "non-nil return type in " - + "spawned function"; - scx.fcx.ccx.tcx.sess.span_err(expr.span, err); - fail; - } - } - } - } + Demand::simple(scx, f.span, ty::mk_nil(scx.fcx.ccx.tcx), fty); // FIXME: Other typechecks needed diff --git a/src/test/compile-fail/spawn-non-nil-fn.rs b/src/test/compile-fail/spawn-non-nil-fn.rs index 4ddb3fbfe2cf..bd7d7d9f0273 100644 --- a/src/test/compile-fail/spawn-non-nil-fn.rs +++ b/src/test/compile-fail/spawn-non-nil-fn.rs @@ -1,6 +1,4 @@ // xfail-stage0 -// xfail-stage1 -// xfail-stage2 // error-pattern: mismatched types fn f(int x) -> int {