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

15 lines
318 B
Rust
Raw Normal View History

fn foo(_f: fn()) {}
fn bar(_f: @int) {}
fn main() {
let x = @3;
foo({|| bar(x); });
let x = @3;
foo({|copy x| bar(x); }); //! ERROR cannot capture values explicitly with a block closure
let x = @3;
foo({|move x| bar(x); }); //! ERROR cannot capture values explicitly with a block closure
}