rust/src/test/compile-fail/pinned-deep-copy.rs

23 lines
340 B
Rust
Raw Normal View History

2012-05-23 10:15:06 -07:00
// error-pattern: copying a noncopyable value
2012-08-15 18:46:55 -07:00
struct r {
2012-06-01 20:21:59 -07:00
let i: @mut int;
drop { *(self.i) = *(self.i) + 1; }
2012-05-23 10:15:06 -07:00
}
2012-09-05 15:58:43 -07:00
fn r(i: @mut int) -> r {
r {
i: i
}
}
2012-05-23 10:15:06 -07:00
fn main() {
let i = @mut 0;
{
// Can't do this copy
let x = ~~~{y: r(i)};
let z = x;
log(debug, x);
}
log(error, *i);
}