rust/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs

23 lines
583 B
Rust
Raw Normal View History

2012-05-10 19:58:23 -07:00
fn borrow(v: &int, f: fn(x: &int)) {
f(v);
}
fn box_imm() {
let mut v = ~3;
let _w = &mut v; //~ NOTE loan of mutable local variable granted here
2012-06-30 16:19:07 -07:00
do task::spawn |move v| {
//~^ ERROR moving out of mutable local variable prohibited due to outstanding loan
2012-05-10 19:58:23 -07:00
#debug["v=%d", *v];
}
let mut v = ~3;
let _w = &mut v; //~ NOTE loan of mutable local variable granted here
2012-05-10 19:58:23 -07:00
task::spawn(fn~(move v) {
//~^ ERROR moving out of mutable local variable prohibited due to outstanding loan
2012-05-10 19:58:23 -07:00
#debug["v=%d", *v];
});
}
fn main() {
}