rust/src/test/compile-fail/cap-clause-with-stack-closure.rs

15 lines
309 B
Rust
Raw Normal View History

fn foo(_f: fn()) {}
fn bar(_f: @int) {}
fn main() {
let x = @3;
2012-06-30 16:19:07 -07:00
foo(|| bar(x) );
let x = @3;
2012-06-30 16:19:07 -07:00
foo(|copy x| bar(x) ); //! ERROR cannot capture values explicitly with a block closure
let x = @3;
2012-06-30 16:19:07 -07:00
foo(|move x| bar(x) ); //! ERROR cannot capture values explicitly with a block closure
}