mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-27 07:03:45 +00:00
allow binding of fn~, make result fn@. fixes 1899.
This commit is contained in:
parent
f80008f04b
commit
e399ddbf17
@ -2609,8 +2609,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let proto = alt proto {
|
let proto = alt proto {
|
||||||
ast::proto_bare | ast::proto_box { ast::proto_box }
|
ast::proto_bare | ast::proto_box | ast::proto_uniq {
|
||||||
ast::proto_uniq | ast::proto_any | ast::proto_block {
|
ast::proto_box
|
||||||
|
}
|
||||||
|
ast::proto_any | ast::proto_block {
|
||||||
tcx.sess.span_err(expr.span,
|
tcx.sess.span_err(expr.span,
|
||||||
#fmt["cannot bind %s closures",
|
#fmt["cannot bind %s closures",
|
||||||
proto_to_str(proto)]);
|
proto_to_str(proto)]);
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
// -*- rust -*-
|
|
||||||
|
|
||||||
// I originally made this test to ensure that bind does the right
|
|
||||||
// thing when binding a unique closure (which is to copy the closure,
|
|
||||||
// I suppose?). But I've since decided it's not worth the effort, and
|
|
||||||
// so I just made it a simple error. But I left the test as is in
|
|
||||||
// case we ever decide that bind should work with unique closures,
|
|
||||||
// though a simpler test would suffice for now.
|
|
||||||
|
|
||||||
fn make_addr(-x: ~int) -> fn~() -> uint {
|
|
||||||
(fn~[move x]() -> uint { ptr::addr_of(*x) as uint })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x = ~3;
|
|
||||||
let a = ptr::addr_of(*x) as uint;
|
|
||||||
let adder: fn~() -> uint = make_addr(x);
|
|
||||||
let bound_adder: fn~() -> uint = bind adder();
|
|
||||||
//!^ ERROR cannot bind fn~ closures
|
|
||||||
assert adder() == a;
|
|
||||||
assert bound_adder() != a;
|
|
||||||
}
|
|
4
src/test/run-pass/issue-1899.rs
Normal file
4
src/test/run-pass/issue-1899.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
fn main()
|
||||||
|
{
|
||||||
|
let _b = [bind (fn~() {})()];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user