]>
Commit | Line | Data |
---|---|---|
9e0c209e SL |
1 | // This test case tests the incremental compilation hash (ICH) implementation |
2 | // for struct 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 struct 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 struct's metadata, and that it stays | |
11 | // the same between rev2 and rev3. | |
12 | ||
416331ca | 13 | // build-pass (FIXME(62277): could be check-pass?) |
c295e0f8 XL |
14 | // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6 |
15 | // compile-flags: -Z query-dep-graph | |
16 | // [cfail1]compile-flags: -Zincremental-ignore-spans | |
17 | // [cfail2]compile-flags: -Zincremental-ignore-spans | |
18 | // [cfail3]compile-flags: -Zincremental-ignore-spans | |
19 | // [cfail4]compile-flags: -Zincremental-relative-spans | |
20 | // [cfail5]compile-flags: -Zincremental-relative-spans | |
21 | // [cfail6]compile-flags: -Zincremental-relative-spans | |
9e0c209e SL |
22 | |
23 | #![allow(warnings)] | |
24 | #![feature(rustc_attrs)] | |
25 | #![crate_type="rlib"] | |
26 | ||
27 | // Layout ---------------------------------------------------------------------- | |
c295e0f8 | 28 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
29 | pub struct LayoutPacked; |
30 | ||
c295e0f8 | 31 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
32 | #[rustc_clean(except="type_of", cfg="cfail2")] |
33 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
34 | #[rustc_clean(except="type_of", cfg="cfail5")] |
35 | #[rustc_clean(cfg="cfail6")] | |
9e0c209e SL |
36 | #[repr(packed)] |
37 | pub struct LayoutPacked; | |
38 | ||
c295e0f8 | 39 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
40 | struct LayoutC; |
41 | ||
c295e0f8 | 42 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
43 | #[rustc_clean(except="type_of", cfg="cfail2")] |
44 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
45 | #[rustc_clean(except="type_of", cfg="cfail5")] |
46 | #[rustc_clean(cfg="cfail6")] | |
9e0c209e SL |
47 | #[repr(C)] |
48 | struct LayoutC; | |
49 | ||
50 | ||
51 | // Tuple Struct Change Field Type ---------------------------------------------- | |
52 | ||
c295e0f8 | 53 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
54 | struct TupleStructFieldType(i32); |
55 | ||
c295e0f8 | 56 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
57 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] |
58 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
59 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] |
60 | #[rustc_clean(cfg="cfail6")] | |
ea8adc8c XL |
61 | // Note that changing the type of a field does not change the type of the struct or enum, but |
62 | // adding/removing fields or changing a fields name or visibility does. | |
cc61c64b | 63 | struct TupleStructFieldType( |
cc61c64b XL |
64 | u32 |
65 | ); | |
9e0c209e SL |
66 | |
67 | ||
68 | // Tuple Struct Add Field ------------------------------------------------------ | |
69 | ||
c295e0f8 | 70 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
71 | struct TupleStructAddField(i32); |
72 | ||
c295e0f8 | 73 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
74 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] |
75 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
76 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail5")] |
77 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 78 | struct TupleStructAddField( |
cc61c64b | 79 | i32, |
cc61c64b XL |
80 | u32 |
81 | ); | |
9e0c209e SL |
82 | |
83 | ||
84 | // Tuple Struct Field Visibility ----------------------------------------------- | |
85 | ||
c295e0f8 | 86 | #[cfg(any(cfail1,cfail4))] |
04454e1e | 87 | struct TupleStructFieldVisibility( char); |
9e0c209e | 88 | |
c295e0f8 | 89 | #[cfg(not(any(cfail1,cfail4)))] |
04454e1e | 90 | #[rustc_clean(cfg="cfail2", except="type_of")] |
17df50a5 | 91 | #[rustc_clean(cfg="cfail3")] |
04454e1e | 92 | #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")] |
c295e0f8 | 93 | #[rustc_clean(cfg="cfail6")] |
9e0c209e SL |
94 | struct TupleStructFieldVisibility(pub char); |
95 | ||
96 | ||
97 | // Record Struct Field Type ---------------------------------------------------- | |
98 | ||
c295e0f8 | 99 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
100 | struct RecordStructFieldType { x: f32 } |
101 | ||
c295e0f8 | 102 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
103 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] |
104 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
105 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] |
106 | #[rustc_clean(cfg="cfail6")] | |
ea8adc8c XL |
107 | // Note that changing the type of a field does not change the type of the struct or enum, but |
108 | // adding/removing fields or changing a fields name or visibility does. | |
cc61c64b | 109 | struct RecordStructFieldType { |
cc61c64b XL |
110 | x: u64 |
111 | } | |
9e0c209e SL |
112 | |
113 | ||
114 | // Record Struct Field Name ---------------------------------------------------- | |
115 | ||
c295e0f8 | 116 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
117 | struct RecordStructFieldName { x: f32 } |
118 | ||
c295e0f8 | 119 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
120 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] |
121 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
122 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail5")] |
123 | #[rustc_clean(cfg="cfail6")] | |
9e0c209e SL |
124 | struct RecordStructFieldName { y: f32 } |
125 | ||
126 | ||
127 | // Record Struct Add Field ----------------------------------------------------- | |
128 | ||
c295e0f8 | 129 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
130 | struct RecordStructAddField { x: f32 } |
131 | ||
c295e0f8 | 132 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
133 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] |
134 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
135 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail5")] |
136 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 137 | struct RecordStructAddField { |
cc61c64b | 138 | x: f32, |
cc61c64b | 139 | y: () } |
9e0c209e SL |
140 | |
141 | ||
142 | // Record Struct Field Visibility ---------------------------------------------- | |
143 | ||
c295e0f8 | 144 | #[cfg(any(cfail1,cfail4))] |
04454e1e | 145 | struct RecordStructFieldVisibility { x: f32 } |
9e0c209e | 146 | |
c295e0f8 | 147 | #[cfg(not(any(cfail1,cfail4)))] |
04454e1e | 148 | #[rustc_clean(cfg="cfail2", except="type_of")] |
17df50a5 | 149 | #[rustc_clean(cfg="cfail3")] |
04454e1e | 150 | #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")] |
c295e0f8 | 151 | #[rustc_clean(cfg="cfail6")] |
04454e1e | 152 | struct RecordStructFieldVisibility { pub x: f32 } |
9e0c209e SL |
153 | |
154 | ||
155 | // Add Lifetime Parameter ------------------------------------------------------ | |
156 | ||
c295e0f8 | 157 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
158 | struct AddLifetimeParameter<'a>(&'a f32, &'a f64); |
159 | ||
c295e0f8 | 160 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
161 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of", cfg="cfail2")] |
162 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
163 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of", cfg="cfail5")] |
164 | #[rustc_clean(cfg="cfail6")] | |
9e0c209e SL |
165 | struct AddLifetimeParameter<'a, 'b>(&'a f32, &'b f64); |
166 | ||
167 | ||
168 | // Add Lifetime Parameter Bound ------------------------------------------------ | |
169 | ||
c295e0f8 | 170 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
171 | struct AddLifetimeParameterBound<'a, 'b>(&'a f32, &'b f64); |
172 | ||
c295e0f8 | 173 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
174 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] |
175 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
176 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail5")] |
177 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 178 | struct AddLifetimeParameterBound<'a, 'b: 'a>( |
cc61c64b | 179 | &'a f32, |
cc61c64b XL |
180 | &'b f64 |
181 | ); | |
9e0c209e | 182 | |
c295e0f8 | 183 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
184 | struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64); |
185 | ||
c295e0f8 | 186 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
187 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] |
188 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
189 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail5")] |
190 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 191 | struct AddLifetimeParameterBoundWhereClause<'a, 'b>( |
cc61c64b | 192 | &'a f32, |
cc61c64b | 193 | &'b f64) |
9e0c209e SL |
194 | where 'b: 'a; |
195 | ||
196 | ||
197 | // Add Type Parameter ---------------------------------------------------------- | |
198 | ||
c295e0f8 | 199 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
200 | struct AddTypeParameter<T1>(T1, T1); |
201 | ||
c295e0f8 | 202 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
203 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of,predicates_of", cfg="cfail2")] |
204 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
205 | #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of,predicates_of", cfg="cfail5")] |
206 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b XL |
207 | struct AddTypeParameter<T1, T2>( |
208 | // The field contains the parent's Generics, so it's dirty even though its | |
209 | // type hasn't changed. | |
cc61c64b | 210 | T1, |
cc61c64b XL |
211 | T2 |
212 | ); | |
9e0c209e SL |
213 | |
214 | ||
215 | // Add Type Parameter Bound ---------------------------------------------------- | |
216 | ||
c295e0f8 | 217 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
218 | struct AddTypeParameterBound<T>(T); |
219 | ||
c295e0f8 | 220 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
221 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] |
222 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
223 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail5")] |
224 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 225 | struct AddTypeParameterBound<T: Send>( |
cc61c64b XL |
226 | T |
227 | ); | |
9e0c209e SL |
228 | |
229 | ||
c295e0f8 | 230 | #[cfg(any(cfail1,cfail4))] |
9e0c209e SL |
231 | struct AddTypeParameterBoundWhereClause<T>(T); |
232 | ||
c295e0f8 | 233 | #[cfg(not(any(cfail1,cfail4)))] |
17df50a5 XL |
234 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] |
235 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
236 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail5")] |
237 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 238 | struct AddTypeParameterBoundWhereClause<T>( |
cc61c64b XL |
239 | T |
240 | ) where T: Sync; | |
9e0c209e SL |
241 | |
242 | ||
243 | // Empty struct ---------------------------------------------------------------- | |
ea8adc8c | 244 | // Since we cannot change anything in this case, we just make sure that the |
0731742a | 245 | // fingerprint is stable (i.e., that there are no random influences like memory |
ea8adc8c XL |
246 | // addresses taken into account by the hashing algorithm). |
247 | // Note: there is no #[cfg(...)], so this is ALWAYS compiled | |
17df50a5 XL |
248 | #[rustc_clean(cfg="cfail2")] |
249 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
250 | #[rustc_clean(cfg="cfail5")] |
251 | #[rustc_clean(cfg="cfail6")] | |
9e0c209e SL |
252 | pub struct EmptyStruct; |
253 | ||
254 | ||
255 | // Visibility ------------------------------------------------------------------ | |
256 | ||
c295e0f8 | 257 | #[cfg(any(cfail1,cfail4))] |
04454e1e | 258 | struct Visibility; |
9e0c209e | 259 | |
c295e0f8 | 260 | #[cfg(not(any(cfail1,cfail4)))] |
04454e1e | 261 | #[rustc_clean(cfg="cfail2")] |
17df50a5 | 262 | #[rustc_clean(cfg="cfail3")] |
04454e1e | 263 | #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")] |
c295e0f8 | 264 | #[rustc_clean(cfg="cfail6")] |
9e0c209e | 265 | pub struct Visibility; |
c30ab7b3 | 266 | |
c30ab7b3 SL |
267 | struct ReferencedType1; |
268 | struct ReferencedType2; | |
269 | ||
270 | // Tuple Struct Change Field Type Indirectly ----------------------------------- | |
271 | mod tuple_struct_change_field_type_indirectly { | |
c295e0f8 | 272 | #[cfg(any(cfail1,cfail4))] |
c30ab7b3 | 273 | use super::ReferencedType1 as FieldType; |
c295e0f8 | 274 | #[cfg(not(any(cfail1,cfail4)))] |
c30ab7b3 SL |
275 | use super::ReferencedType2 as FieldType; |
276 | ||
17df50a5 XL |
277 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] |
278 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
279 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] |
280 | #[rustc_clean(cfg="cfail6")] | |
cc61c64b | 281 | struct TupleStruct( |
cc61c64b XL |
282 | FieldType |
283 | ); | |
c30ab7b3 SL |
284 | } |
285 | ||
286 | ||
287 | // Record Struct Change Field Type Indirectly ----------------------------------- | |
288 | mod record_struct_change_field_type_indirectly { | |
c295e0f8 | 289 | #[cfg(any(cfail1,cfail4))] |
c30ab7b3 | 290 | use super::ReferencedType1 as FieldType; |
c295e0f8 | 291 | #[cfg(not(any(cfail1,cfail4)))] |
c30ab7b3 SL |
292 | use super::ReferencedType2 as FieldType; |
293 | ||
17df50a5 XL |
294 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] |
295 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
296 | #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] |
297 | #[rustc_clean(cfg="cfail6")] | |
c30ab7b3 SL |
298 | struct RecordStruct { |
299 | _x: FieldType | |
300 | } | |
301 | } | |
302 | ||
303 | ||
304 | ||
305 | ||
306 | trait ReferencedTrait1 {} | |
307 | trait ReferencedTrait2 {} | |
308 | ||
309 | // Change Trait Bound Indirectly ----------------------------------------------- | |
310 | mod change_trait_bound_indirectly { | |
c295e0f8 | 311 | #[cfg(any(cfail1,cfail4))] |
c30ab7b3 | 312 | use super::ReferencedTrait1 as Trait; |
c295e0f8 | 313 | #[cfg(not(any(cfail1,cfail4)))] |
c30ab7b3 SL |
314 | use super::ReferencedTrait2 as Trait; |
315 | ||
17df50a5 XL |
316 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] |
317 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
318 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail5")] |
319 | #[rustc_clean(cfg="cfail6")] | |
c30ab7b3 SL |
320 | struct Struct<T: Trait>(T); |
321 | } | |
322 | ||
323 | // Change Trait Bound Indirectly In Where Clause ------------------------------- | |
324 | mod change_trait_bound_indirectly_in_where_clause { | |
c295e0f8 | 325 | #[cfg(any(cfail1,cfail4))] |
c30ab7b3 | 326 | use super::ReferencedTrait1 as Trait; |
c295e0f8 | 327 | #[cfg(not(any(cfail1,cfail4)))] |
c30ab7b3 SL |
328 | use super::ReferencedTrait2 as Trait; |
329 | ||
17df50a5 XL |
330 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] |
331 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
332 | #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail5")] |
333 | #[rustc_clean(cfg="cfail6")] | |
c30ab7b3 SL |
334 | struct Struct<T>(T) where T : Trait; |
335 | } |