Skip to content

Commit ed985b6

Browse files
committed
Bare functions can coerce to blocks
1 parent 354bfc8 commit ed985b6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/comp/middle/typeck.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,10 @@ fn do_fn_ty_coerce(fcx: @fn_ctxt, sp: span, actual: ty::t, expected: ty::t)
916916
ty::mk_fn(fcx.ccx.tcx, ast::proto_fn, args, ret_ty, cf,
917917
constrs)
918918
}
919+
some(ty::ty_fn(ast::proto_block., _, _, _, _)) {
920+
ty::mk_fn(fcx.ccx.tcx, ast::proto_block, args, ret_ty, cf,
921+
constrs)
922+
}
919923
_ { actual }
920924
}
921925
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn# bare() {}
2+
3+
fn likes_block(f: block()) { f() }
4+
5+
fn main() {
6+
likes_block(bare);
7+
}

0 commit comments

Comments
 (0)