Debian Codegraph @

gcc/testsuite/rust/execute/torture/derive_macro4.rs

raw
1 #[lang = "sized"]
2 pub trait Sized {}
3
4 #[lang = "clone"]
5 pub trait Clone {
6 fn clone(&self) -> Self;
7 }
8
9 #[derive(Clone)]
10 struct Foo {
11 a: i32,
12 }
13
14 #[derive(Clone)]
15 struct S {
16 a: i32,
17 b: Foo,
18 }
19
20 impl Clone for i32 {
21 fn clone(&self) -> Self { *self }
22 }
23
24 fn main() -> i32 {
25 let s1 = S { a: 15, b: Foo { a: 14 }};
26 let s2 = s1.clone();
27
28 let l = s1.a - s2.a;
29 let r = s1.b.a - s2.b.a;
30
31 // should be 0 if all fields were cloned correctly
32 l + r
33 }