]> git.lizzy.rs Git - rust.git/blob - tests/incremental/hashes/type_defs.rs
Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper
[rust.git] / tests / incremental / hashes / type_defs.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `type` definitions.
3
4 // The general pattern followed here is: Change one thing between rev1 and rev2
5 // and make sure that the hash has changed, then change nothing between rev2 and
6 // rev3 and make sure that the hash has not changed.
7
8 // We also test the ICH for `type` definitions exported in metadata. Same as
9 // above, we want to make sure that the change between rev1 and rev2 also
10 // results in a change of the ICH for the enum's metadata, and that it stays
11 // the same between rev2 and rev3.
12
13 // build-pass (FIXME(62277): could be check-pass?)
14 // revisions: cfail1 cfail2 cfail3
15 // compile-flags: -Z query-dep-graph -O
16
17 #![allow(warnings)]
18 #![feature(rustc_attrs)]
19 #![crate_type="rlib"]
20
21
22 // Change type (primitive) -----------------------------------------------------
23 #[cfg(cfail1)]
24 type ChangePrimitiveType = i32;
25
26 #[cfg(not(cfail1))]
27 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
28 #[rustc_clean(cfg="cfail3")]
29 type ChangePrimitiveType = i64;
30
31
32
33 // Change mutability -----------------------------------------------------------
34 #[cfg(cfail1)]
35 type ChangeMutability = &'static i32;
36
37 #[cfg(not(cfail1))]
38 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
39 #[rustc_clean(cfg="cfail3")]
40 type ChangeMutability = &'static mut i32;
41
42
43
44 // Change mutability -----------------------------------------------------------
45 #[cfg(cfail1)]
46 type ChangeLifetime<'a> = (&'static i32, &'a i32);
47
48 #[cfg(not(cfail1))]
49 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
50 #[rustc_clean(cfg="cfail3")]
51 type ChangeLifetime<'a> = (&'a i32, &'a i32);
52
53
54
55 // Change type (struct) -----------------------------------------------------------
56 struct Struct1;
57 struct Struct2;
58
59 #[cfg(cfail1)]
60 type ChangeTypeStruct = Struct1;
61
62 #[cfg(not(cfail1))]
63 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
64 #[rustc_clean(cfg="cfail3")]
65 type ChangeTypeStruct = Struct2;
66
67
68
69 // Change type (tuple) ---------------------------------------------------------
70 #[cfg(cfail1)]
71 type ChangeTypeTuple = (u32, u64);
72
73 #[cfg(not(cfail1))]
74 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
75 #[rustc_clean(cfg="cfail3")]
76 type ChangeTypeTuple = (u32, i64);
77
78
79
80 // Change type (enum) ----------------------------------------------------------
81 enum Enum1 {
82     Var1,
83     Var2,
84 }
85 enum Enum2 {
86     Var1,
87     Var2,
88 }
89
90 #[cfg(cfail1)]
91 type ChangeTypeEnum = Enum1;
92
93 #[cfg(not(cfail1))]
94 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
95 #[rustc_clean(cfg="cfail3")]
96 type ChangeTypeEnum = Enum2;
97
98
99
100 // Add tuple field -------------------------------------------------------------
101 #[cfg(cfail1)]
102 type AddTupleField = (i32, i64);
103
104 #[cfg(not(cfail1))]
105 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
106 #[rustc_clean(cfg="cfail3")]
107 type AddTupleField = (i32, i64, i16);
108
109
110
111 // Change nested tuple field ---------------------------------------------------
112 #[cfg(cfail1)]
113 type ChangeNestedTupleField = (i32, (i64, i16));
114
115 #[cfg(not(cfail1))]
116 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
117 #[rustc_clean(cfg="cfail3")]
118 type ChangeNestedTupleField = (i32, (i64, i8));
119
120
121
122 // Add type param --------------------------------------------------------------
123 #[cfg(cfail1)]
124 type AddTypeParam<T1> = (T1, T1);
125
126 #[cfg(not(cfail1))]
127 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
128 #[rustc_clean(cfg="cfail3")]
129 type AddTypeParam<T1, T2> = (T1, T2);
130
131
132
133 // Add type param bound --------------------------------------------------------
134 #[cfg(cfail1)]
135 type AddTypeParamBound<T1> = (T1, u32);
136
137 #[cfg(not(cfail1))]
138 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
139 #[rustc_clean(cfg="cfail3")]
140 type AddTypeParamBound<T1: Clone> = (T1, u32);
141
142
143
144 // Add type param bound in where clause ----------------------------------------
145 #[cfg(cfail1)]
146 type AddTypeParamBoundWhereClause<T1> where T1: Clone = (T1, u32);
147
148 #[cfg(not(cfail1))]
149 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
150 #[rustc_clean(cfg="cfail3")]
151 type AddTypeParamBoundWhereClause<T1> where T1: Clone+Copy = (T1, u32);
152
153
154
155 // Add lifetime param ----------------------------------------------------------
156 #[cfg(cfail1)]
157 type AddLifetimeParam<'a> = (&'a u32, &'a u32);
158
159 #[cfg(not(cfail1))]
160 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
161 #[rustc_clean(cfg="cfail3")]
162 type AddLifetimeParam<'a, 'b> = (&'a u32, &'b u32);
163
164
165
166 // Add lifetime param bound ----------------------------------------------------
167 #[cfg(cfail1)]
168 type AddLifetimeParamBound<'a, 'b> = (&'a u32, &'b u32);
169
170 #[cfg(not(cfail1))]
171 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
172 #[rustc_clean(cfg="cfail3")]
173 type AddLifetimeParamBound<'a, 'b: 'a> = (&'a u32, &'b u32);
174
175
176
177 // Add lifetime param bound in where clause ------------------------------------
178 #[cfg(cfail1)]
179 type AddLifetimeParamBoundWhereClause<'a, 'b, 'c>
180 where 'b: 'a
181     = (&'a u32, &'b u32, &'c u32);
182
183 #[cfg(not(cfail1))]
184 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
185 #[rustc_clean(cfg="cfail3")]
186 type AddLifetimeParamBoundWhereClause<'a, 'b, 'c>
187 where 'b: 'a,
188       'c: 'a
189     = (&'a u32, &'b u32, &'c u32);
190
191
192
193 // Change Trait Bound Indirectly -----------------------------------------------
194 trait ReferencedTrait1 {}
195 trait ReferencedTrait2 {}
196
197 mod change_trait_bound_indirectly {
198     #[cfg(cfail1)]
199     use super::ReferencedTrait1 as Trait;
200     #[cfg(not(cfail1))]
201     use super::ReferencedTrait2 as Trait;
202
203     #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
204     #[rustc_clean(cfg="cfail3")]
205     type ChangeTraitBoundIndirectly<T: Trait> = (T, u32);
206 }
207
208
209
210 // Change Trait Bound Indirectly In Where Clause -------------------------------
211 mod change_trait_bound_indirectly_in_where_clause {
212     #[cfg(cfail1)]
213     use super::ReferencedTrait1 as Trait;
214     #[cfg(not(cfail1))]
215     use super::ReferencedTrait2 as Trait;
216
217     #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
218     #[rustc_clean(cfg="cfail3")]
219     type ChangeTraitBoundIndirectly<T> where T : Trait = (T, u32);
220 }