Bare functions can coerce to blocks
This commit is contained in:
parent
354bfc8292
commit
ed985b61d5
2 changed files with 11 additions and 0 deletions
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
|
7
src/test/run-pass/fn-bare-coerce-to-block.rs
Normal file
7
src/test/run-pass/fn-bare-coerce-to-block.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
fn# bare() {}
|
||||
|
||||
fn likes_block(f: block()) { f() }
|
||||
|
||||
fn main() {
|
||||
likes_block(bare);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue