]> git.lizzy.rs Git - rust.git/blob - tests/ui/unique-object-noncopyable.rs
Rollup merge of #107168 - Nilstrieb:if-a-tait-falls-in-the-forest,can-we-know-it...
[rust.git] / tests / ui / unique-object-noncopyable.rs
1 trait Foo {
2     fn f(&self);
3 }
4
5 struct Bar {
6     x: isize,
7 }
8
9 impl Drop for Bar {
10     fn drop(&mut self) {}
11 }
12
13 impl Foo for Bar {
14     fn f(&self) {
15         println!("hi");
16     }
17 }
18
19
20
21 fn main() {
22     let x = Box::new(Bar { x: 10 });
23     let y: Box<dyn Foo> = x as Box<dyn Foo>;
24     let _z = y.clone(); //~ ERROR the method
25 }