]> git.lizzy.rs Git - rust.git/blob - tests/ui/derive.rs
Merge pull request #1747 from Manishearth/mut_fp
[rust.git] / tests / ui / derive.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![feature(untagged_unions)]
5
6 #![deny(warnings)]
7 #![allow(dead_code)]
8
9 use std::hash::{Hash, Hasher};
10
11 #[derive(PartialEq, Hash)]
12 struct Foo;
13
14 impl PartialEq<u64> for Foo {
15     fn eq(&self, _: &u64) -> bool { true }
16 }
17
18 #[derive(Hash)]
19 struct Bar;
20
21 impl PartialEq for Bar {
22     fn eq(&self, _: &Bar) -> bool { true }
23 }
24
25 #[derive(Hash)]
26 struct Baz;
27
28 impl PartialEq<Baz> for Baz {
29     fn eq(&self, _: &Baz) -> bool { true }
30 }
31
32 #[derive(PartialEq)]
33 struct Bah;
34
35 impl Hash for Bah {
36     fn hash<H: Hasher>(&self, _: &mut H) {}
37 }
38
39 #[derive(Copy)]
40 struct Qux;
41
42 impl Clone for Qux {
43     fn clone(&self) -> Self { Qux }
44 }
45
46 // looks like unions don't support deriving Clone for now
47 #[derive(Copy)]
48 union Union {
49     a: u8,
50 }
51
52 impl Clone for Union {
53     fn clone(&self) -> Self {
54         Union {
55             a: 42,
56         }
57     }
58 }
59
60 // See #666
61 #[derive(Copy)]
62 struct Lt<'a> {
63     a: &'a u8,
64 }
65
66 impl<'a> Clone for Lt<'a> {
67     fn clone(&self) -> Self { unimplemented!() }
68 }
69
70 // Ok, `Clone` cannot be derived because of the big array
71 #[derive(Copy)]
72 struct BigArray {
73     a: [u8; 65],
74 }
75
76 impl Clone for BigArray {
77     fn clone(&self) -> Self { unimplemented!() }
78 }
79
80 // Ok, function pointers are not always Clone
81 #[derive(Copy)]
82 struct FnPtr {
83     a: fn() -> !,
84 }
85
86 impl Clone for FnPtr {
87     fn clone(&self) -> Self { unimplemented!() }
88 }
89
90 // Ok, generics
91 #[derive(Copy)]
92 struct Generic<T> {
93     a: T,
94 }
95
96 impl<T> Clone for Generic<T> {
97     fn clone(&self) -> Self { unimplemented!() }
98 }
99
100 fn main() {}