]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/derive.rs
Rollup merge of #71784 - Xaeroxe:patch-1, r=jonas-schievink
[rust.git] / src / tools / clippy / tests / ui / derive.rs
1 #![feature(untagged_unions)]
2 #![allow(dead_code)]
3 #![warn(clippy::expl_impl_clone_on_copy)]
4
5 #[derive(Copy)]
6 struct Qux;
7
8 impl Clone for Qux {
9     fn clone(&self) -> Self {
10         Qux
11     }
12 }
13
14 // looks like unions don't support deriving Clone for now
15 #[derive(Copy)]
16 union Union {
17     a: u8,
18 }
19
20 impl Clone for Union {
21     fn clone(&self) -> Self {
22         Union { a: 42 }
23     }
24 }
25
26 // See #666
27 #[derive(Copy)]
28 struct Lt<'a> {
29     a: &'a u8,
30 }
31
32 impl<'a> Clone for Lt<'a> {
33     fn clone(&self) -> Self {
34         unimplemented!()
35     }
36 }
37
38 // Ok, `Clone` cannot be derived because of the big array
39 #[derive(Copy)]
40 struct BigArray {
41     a: [u8; 65],
42 }
43
44 impl Clone for BigArray {
45     fn clone(&self) -> Self {
46         unimplemented!()
47     }
48 }
49
50 // Ok, function pointers are not always Clone
51 #[derive(Copy)]
52 struct FnPtr {
53     a: fn() -> !,
54 }
55
56 impl Clone for FnPtr {
57     fn clone(&self) -> Self {
58         unimplemented!()
59     }
60 }
61
62 // Ok, generics
63 #[derive(Copy)]
64 struct Generic<T> {
65     a: T,
66 }
67
68 impl<T> Clone for Generic<T> {
69     fn clone(&self) -> Self {
70         unimplemented!()
71     }
72 }
73
74 fn main() {}