Debian Codegraph @

gcc/testsuite/rust/compile/issue-3139-1.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 // { dg-warning "field is never read" "" { target *-*-* } .-1 }
14 b: u32,
15 // { dg-warning "field is never read" "" { target *-*-* } .-1 }
16 }
17
18 #[derive(Clone)]
19 struct Be<T:Clone> {
20 a: T,
21 b: Abound,
22 }
23
24 impl Clone for u32 {
25 fn clone(&self) -> Self {
26 *self
27 }
28 }
29
30 impl Clone for usize {
31 fn clone(&self) -> Self {
32 *self
33 }
34 }
35
36 impl Clone for Abound {
37 fn clone(&self) -> Self {
38 return Abound { a: self.a.clone(), b: self.b.clone() };
39 }
40 }
41
42 fn main() {
43 let b: Be<usize> = Be {a:1,b:Abound { a:0,b:1 }};
44 let _: Be<usize> = b.clone();
45 }