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

22 lines
285 B
Rust
Raw Normal View History

2012-10-31 17:09:26 -05:00
trait Foo {
fn f();
}
struct Bar {
x: int,
drop {}
}
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;
}