Debian Codegraph @

gcc/testsuite/rust/compile/issue-3139-2.rs

raw
1 #![feature(lang_items)]
2
3 #[lang = "clone"]
4 trait Clone {
5 fn clone(&self) -> Self;
6 }
7
8 #[lang = "sized"]
9 trait Sized {}
10
11 struct Abound {
12 a: u32,
13 b: u32,
14 }
15
16 struct Be<T: Clone> {
17 a: T,
18 b: Abound,
19 }
20
21 impl<T: Clone> Clone for Be<T> {
22 fn clone(&self) -> Self {
23 return Be::<T> {
24 a: self.a.clone(),
25 b: self.b.clone(),
26 };
27 }
28 }
29
30 impl Clone for u32 {
31 fn clone(&self) -> Self {
32 *self
33 }
34 }
35
36 impl Clone for usize {
37 fn clone(&self) -> Self {
38 *self
39 }
40 }
41
42 impl Clone for Abound {
43 fn clone(&self) -> Self {
44 return Abound {
45 a: self.a.clone(),
46 b: self.b.clone(),
47 };
48 }
49 }
50
51 fn main() {
52 let b: Be<usize> = Be {
53 a: 1,
54 b: Abound { a: 0, b: 1 },
55 };
56 let _: Be<usize> = b.clone();
57 }