rust/src/test/compile-fail/borrowck-move-by-capture.rs
Niko Matsakis 5851d3242c Move checking for moves and initialization of local variables and patterns into
borrow checker and generalize what moves are allowed. Fixes a nasty
bug or two in the pattern move checking code. Unifies dataflow code
used for initialization and other things. First step towards
once fns. Everybody wins.

Fixes #4384. Fixes #4715. cc once fns (#2202), optimizing local moves (#5016).
2013-05-28 20:22:14 -04:00

14 lines
263 B
Rust

extern mod extra;
fn main() {
let foo = ~3;
let _pfoo = &foo;
let _f: @fn() -> int = || *foo + 5;
//~^ ERROR cannot move `foo`
let bar = ~3;
let _g = || { //~ ERROR capture of moved value
let _h: @fn() -> int = || *bar;
};
}