]> git.lizzy.rs Git - rust.git/blob - tests/ui/derives/derive-hygiene.rs
Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm
[rust.git] / tests / ui / derives / derive-hygiene.rs
1 // Make sure that built-in derives don't rely on the user not declaring certain
2 // names to work properly.
3
4 // check-pass
5
6 #![allow(nonstandard_style)]
7 #![feature(decl_macro)]
8
9 use std::prelude::v1::test as inline;
10
11 static f: () = ();
12 static cmp: () = ();
13 static other: () = ();
14 static state: () = ();
15 static __self_0_0: () = ();
16 static __self_1_0: () = ();
17 static __self_vi: () = ();
18 static __arg_1_0: () = ();
19 static debug_trait_builder: () = ();
20
21 struct isize;
22 trait i16 {}
23
24 trait MethodsInDerives: Sized {
25     fn debug_tuple(self) {}
26     fn debug_struct(self) {}
27     fn field(self) {}
28     fn finish(self) {}
29     fn clone(self) {}
30     fn cmp(self) {}
31     fn partial_cmp(self) {}
32     fn eq(self) {}
33     fn ne(self) {}
34     fn le(self) {}
35     fn lt(self) {}
36     fn ge(self) {}
37     fn gt(self) {}
38     fn hash(self) {}
39 }
40
41 trait GenericAny<T, U> {}
42 impl<S, T, U> GenericAny<T, U> for S {}
43
44 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
45 enum __H { V(i32), }
46
47 #[repr(i16)]
48 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
49 enum W { A, B }
50
51 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
52 struct X<A: GenericAny<A, self::X<i32>>> {
53     A: A,
54 }
55
56 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
57 struct Y<B>(B)
58 where
59     B: From<B>;
60
61 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
62 enum Z<C> {
63     C(C),
64     B { C: C },
65 }
66
67 // Make sure that we aren't using `self::` in paths, since it doesn't work in
68 // non-module scopes.
69 const NON_MODULE: () = {
70     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
71     enum __H { V(i32), }
72
73     #[repr(i16)]
74     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
75     enum W { A, B }
76
77     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
78     struct X<A: Fn(A) -> self::X<i32>> {
79         A: A,
80     }
81
82     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
83     struct Y<B>(B)
84     where
85         B: From<B>;
86
87     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
88     enum Z<C> {
89         C(C),
90         B { C: C },
91     }
92 };
93
94 macro m() {
95     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
96     enum __H { V(i32), }
97
98     #[repr(i16)]
99     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
100     enum W { A, B }
101
102     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
103     struct X<A: GenericAny<A, self::X<i32>>> {
104         A: A,
105     }
106
107     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
108     struct Y<B>(B)
109     where
110         B: From<B>;
111
112     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
113     enum Z<C> {
114         C(C),
115         B { C: C },
116     }
117 }
118
119 m!();
120
121 fn main() {}