]> git.lizzy.rs Git - rust.git/blob - src/test/ui/noncopyable-class.rs
Merge commit '5988bbd24aa87732bfa1d111ba00bcdaa22c481a' into sync_cg_clif-2020-11-27
[rust.git] / src / test / ui / noncopyable-class.rs
1 // Test that a class with a non-copyable field can't be
2 // copied
3
4 #[derive(Debug)]
5 struct Bar {
6   x: isize,
7 }
8
9 impl Drop for Bar {
10     fn drop(&mut self) {}
11 }
12
13 fn bar(x:isize) -> Bar {
14     Bar {
15         x: x
16     }
17 }
18
19 #[derive(Debug)]
20 struct Foo {
21   i: isize,
22   j: Bar,
23 }
24
25 fn foo(i:isize) -> Foo {
26     Foo {
27         i: i,
28         j: bar(5)
29     }
30 }
31
32 fn main() {
33     let x = foo(10);
34     let _y = x.clone(); //~ ERROR no method named `clone` found
35     println!("{:?}", x);
36 }