rust/src/test/compile-fail/unique-object-noncopyable.rs

25 lines
315 B
Rust
Raw Normal View History

2012-10-31 17:09:26 -05:00
trait Foo {
fn f();
}
struct Bar {
x: int,
}
impl Bar : Drop {
fn finalize() {}
2012-10-31 17:09:26 -05:00
}
impl Bar : Foo {
fn f() {
io::println("hi");
}
}
fn main() {
let x = ~Bar { x: 10 };
let y = (move x) as ~Foo; //~ ERROR uniquely-owned trait objects must be copyable
let _z = copy y;
}