1
Fork 0

Bare functions can coerce to blocks

This commit is contained in:
Brian Anderson 2011-10-14 15:22:25 -07:00
parent 354bfc8292
commit ed985b61d5
2 changed files with 11 additions and 0 deletions

View file

@ -916,6 +916,10 @@ fn do_fn_ty_coerce(fcx: @fn_ctxt, sp: span, actual: ty::t, expected: ty::t)
ty::mk_fn(fcx.ccx.tcx, ast::proto_fn, args, ret_ty, cf,
constrs)
}
some(ty::ty_fn(ast::proto_block., _, _, _, _)) {
ty::mk_fn(fcx.ccx.tcx, ast::proto_block, args, ret_ty, cf,
constrs)
}
_ { actual }
}
}

View file

@ -0,0 +1,7 @@
fn# bare() {}
fn likes_block(f: block()) { f() }
fn main() {
likes_block(bare);
}