rust/src/test/compile-fail/implicit-copy-2.rs
2011-10-28 14:57:49 +02:00

21 lines
350 B
Rust

// error-pattern: cannot copy pinned type 'a
resource r(i: @mutable int) {
*i = *i + 1;
}
fn movearg<pin T>(i: T) {
// Implicit copy to mutate reference i
let j <- i;
}
fn main() {
let i = @mutable 0;
{
let j <- r(i);
movearg(j);
}
log_err *i;
// nooooooo. destructor ran twice
assert *i == 2;
}