rust/tests/ui/unique-object-noncopyable.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
324 B
Rust
Raw Normal View History

2012-10-31 22:09:26 +00:00
trait Foo {
fn f(&self);
2012-10-31 22:09:26 +00:00
}
struct Bar {
x: isize,
}
impl Drop for Bar {
2013-09-17 01:18:07 +00:00
fn drop(&mut self) {}
2012-10-31 22:09:26 +00:00
}
impl Foo for Bar {
fn f(&self) {
println!("hi");
2012-10-31 22:09:26 +00:00
}
}
2012-10-31 22:09:26 +00:00
fn main() {
let x = Box::new(Bar { x: 10 });
2019-05-28 18:46:13 +00:00
let y: Box<dyn Foo> = x as Box<dyn Foo>;
let _z = y.clone(); //~ ERROR the method
2012-10-31 22:09:26 +00:00
}