1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for struct definitions.
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.
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.
13 // build-pass (FIXME(62277): could be check-pass?)
14 // revisions: cfail1 cfail2 cfail3
15 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
19 #![feature(rustc_attrs)]
22 // Layout ----------------------------------------------------------------------
24 pub struct LayoutPacked
;
27 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
28 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
29 #[rustc_dirty(label="type_of", cfg="cfail2")]
30 #[rustc_clean(label="generics_of", cfg="cfail2")]
31 #[rustc_clean(label="predicates_of", cfg="cfail2")]
32 #[rustc_clean(label="hir_owner", cfg="cfail3")]
33 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
34 #[rustc_clean(label="type_of", cfg="cfail3")]
35 #[rustc_clean(label="generics_of", cfg="cfail3")]
36 #[rustc_clean(label="predicates_of", cfg="cfail3")]
38 pub struct LayoutPacked
;
44 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
45 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
46 #[rustc_dirty(label="type_of", cfg="cfail2")]
47 #[rustc_clean(label="generics_of", cfg="cfail2")]
48 #[rustc_clean(label="predicates_of", cfg="cfail2")]
49 #[rustc_clean(label="hir_owner", cfg="cfail3")]
50 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
51 #[rustc_clean(label="type_of", cfg="cfail3")]
52 #[rustc_clean(label="generics_of", cfg="cfail3")]
53 #[rustc_clean(label="predicates_of", cfg="cfail3")]
58 // Tuple Struct Change Field Type ----------------------------------------------
61 struct TupleStructFieldType(i32);
64 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
65 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
66 #[rustc_clean(label="type_of", cfg="cfail2")]
67 #[rustc_clean(label="generics_of", cfg="cfail2")]
68 #[rustc_clean(label="predicates_of", cfg="cfail2")]
69 #[rustc_clean(label="hir_owner", cfg="cfail3")]
70 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
71 #[rustc_clean(label="type_of", cfg="cfail3")]
72 #[rustc_clean(label="generics_of", cfg="cfail3")]
73 #[rustc_clean(label="predicates_of", cfg="cfail3")]
74 // Note that changing the type of a field does not change the type of the struct or enum, but
75 // adding/removing fields or changing a fields name or visibility does.
76 struct TupleStructFieldType(
81 // Tuple Struct Add Field ------------------------------------------------------
84 struct TupleStructAddField(i32);
87 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
88 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
89 #[rustc_dirty(label="type_of", cfg="cfail2")]
90 #[rustc_clean(label="generics_of", cfg="cfail2")]
91 #[rustc_clean(label="predicates_of", cfg="cfail2")]
92 #[rustc_clean(label="hir_owner", cfg="cfail3")]
93 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
94 #[rustc_clean(label="type_of", cfg="cfail3")]
95 #[rustc_clean(label="generics_of", cfg="cfail3")]
96 #[rustc_clean(label="predicates_of", cfg="cfail3")]
97 struct TupleStructAddField(
103 // Tuple Struct Field Visibility -----------------------------------------------
106 struct TupleStructFieldVisibility(char);
109 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
110 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
111 #[rustc_dirty(label="type_of", cfg="cfail2")]
112 #[rustc_clean(label="generics_of", cfg="cfail2")]
113 #[rustc_clean(label="predicates_of", cfg="cfail2")]
114 #[rustc_clean(label="hir_owner", cfg="cfail3")]
115 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
116 #[rustc_clean(label="type_of", cfg="cfail3")]
117 #[rustc_clean(label="generics_of", cfg="cfail3")]
118 #[rustc_clean(label="predicates_of", cfg="cfail3")]
119 struct TupleStructFieldVisibility(pub char);
122 // Record Struct Field Type ----------------------------------------------------
125 struct RecordStructFieldType { x: f32 }
128 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
129 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
130 #[rustc_clean(label="type_of", cfg="cfail2")]
131 #[rustc_clean(label="generics_of", cfg="cfail2")]
132 #[rustc_clean(label="predicates_of", cfg="cfail2")]
133 #[rustc_clean(label="hir_owner", cfg="cfail3")]
134 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
135 #[rustc_clean(label="type_of", cfg="cfail3")]
136 #[rustc_clean(label="generics_of", cfg="cfail3")]
137 #[rustc_clean(label="predicates_of", cfg="cfail3")]
138 // Note that changing the type of a field does not change the type of the struct or enum, but
139 // adding/removing fields or changing a fields name or visibility does.
140 struct RecordStructFieldType
{
145 // Record Struct Field Name ----------------------------------------------------
148 struct RecordStructFieldName { x: f32 }
151 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
152 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
153 #[rustc_dirty(label="type_of", cfg="cfail2")]
154 #[rustc_clean(label="generics_of", cfg="cfail2")]
155 #[rustc_clean(label="predicates_of", cfg="cfail2")]
156 #[rustc_clean(label="hir_owner", cfg="cfail3")]
157 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
158 #[rustc_clean(label="type_of", cfg="cfail3")]
159 #[rustc_clean(label="generics_of", cfg="cfail3")]
160 #[rustc_clean(label="predicates_of", cfg="cfail3")]
161 struct RecordStructFieldName { y: f32 }
164 // Record Struct Add Field -----------------------------------------------------
167 struct RecordStructAddField { x: f32 }
170 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
171 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
172 #[rustc_dirty(label="type_of", cfg="cfail2")]
173 #[rustc_clean(label="generics_of", cfg="cfail2")]
174 #[rustc_clean(label="predicates_of", cfg="cfail2")]
175 #[rustc_clean(label="hir_owner", cfg="cfail3")]
176 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
177 #[rustc_clean(label="type_of", cfg="cfail3")]
178 #[rustc_clean(label="generics_of", cfg="cfail3")]
179 #[rustc_clean(label="predicates_of", cfg="cfail3")]
180 struct RecordStructAddField
{
185 // Record Struct Field Visibility ----------------------------------------------
188 struct RecordStructFieldVisibility { x: f32 }
191 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
192 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
193 #[rustc_dirty(label="type_of", cfg="cfail2")]
194 #[rustc_clean(label="generics_of", cfg="cfail2")]
195 #[rustc_clean(label="predicates_of", cfg="cfail2")]
196 #[rustc_clean(label="hir_owner", cfg="cfail3")]
197 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
198 #[rustc_clean(label="type_of", cfg="cfail3")]
199 #[rustc_clean(label="generics_of", cfg="cfail3")]
200 #[rustc_clean(label="predicates_of", cfg="cfail3")]
201 struct RecordStructFieldVisibility
{
206 // Add Lifetime Parameter ------------------------------------------------------
209 struct AddLifetimeParameter
<'a
>(&'a
f32, &'a
f64);
212 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
213 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
214 #[rustc_dirty(label="type_of", cfg="cfail2")]
215 #[rustc_dirty(label="generics_of", cfg="cfail2")]
216 #[rustc_clean(label="predicates_of", cfg="cfail2")]
217 #[rustc_clean(label="hir_owner", cfg="cfail3")]
218 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
219 #[rustc_clean(label="type_of", cfg="cfail3")]
220 #[rustc_clean(label="generics_of", cfg="cfail3")]
221 #[rustc_clean(label="predicates_of", cfg="cfail3")]
222 struct AddLifetimeParameter
<'a
, 'b
>(&'a
f32, &'b
f64);
225 // Add Lifetime Parameter Bound ------------------------------------------------
228 struct AddLifetimeParameterBound
<'a
, 'b
>(&'a
f32, &'b
f64);
231 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
232 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
233 #[rustc_clean(label="type_of", cfg="cfail2")]
234 #[rustc_clean(label="generics_of", cfg="cfail2")]
235 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
236 #[rustc_clean(label="hir_owner", cfg="cfail3")]
237 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
238 #[rustc_clean(label="type_of", cfg="cfail3")]
239 #[rustc_clean(label="generics_of", cfg="cfail3")]
240 #[rustc_clean(label="predicates_of", cfg="cfail3")]
241 struct AddLifetimeParameterBound
<'a
, 'b
: 'a
>(
247 struct AddLifetimeParameterBoundWhereClause
<'a
, 'b
>(&'a
f32, &'b
f64);
250 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
251 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
252 #[rustc_clean(label="type_of", cfg="cfail2")]
253 #[rustc_clean(label="generics_of", cfg="cfail2")]
254 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
255 #[rustc_clean(label="hir_owner", cfg="cfail3")]
256 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
257 #[rustc_clean(label="type_of", cfg="cfail3")]
258 #[rustc_clean(label="generics_of", cfg="cfail3")]
259 #[rustc_clean(label="predicates_of", cfg="cfail3")]
260 struct AddLifetimeParameterBoundWhereClause
<'a
, 'b
>(
266 // Add Type Parameter ----------------------------------------------------------
269 struct AddTypeParameter
<T1
>(T1
, T1
);
272 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
273 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
274 #[rustc_dirty(label="type_of", cfg="cfail2")]
275 #[rustc_dirty(label="generics_of", cfg="cfail2")]
276 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
277 #[rustc_clean(label="hir_owner", cfg="cfail3")]
278 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
279 #[rustc_clean(label="type_of", cfg="cfail3")]
280 #[rustc_clean(label="generics_of", cfg="cfail3")]
281 #[rustc_clean(label="predicates_of", cfg="cfail3")]
282 struct AddTypeParameter
<T1
, T2
>(
283 // The field contains the parent's Generics, so it's dirty even though its
284 // type hasn't changed.
290 // Add Type Parameter Bound ----------------------------------------------------
293 struct AddTypeParameterBound
<T
>(T
);
296 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
297 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
298 #[rustc_clean(label="type_of", cfg="cfail2")]
299 #[rustc_clean(label="generics_of", cfg="cfail2")]
300 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
301 #[rustc_clean(label="hir_owner", cfg="cfail3")]
302 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
303 #[rustc_clean(label="type_of", cfg="cfail3")]
304 #[rustc_clean(label="generics_of", cfg="cfail3")]
305 #[rustc_clean(label="predicates_of", cfg="cfail3")]
306 struct AddTypeParameterBound
<T
: Send
>(
312 struct AddTypeParameterBoundWhereClause
<T
>(T
);
315 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
316 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
317 #[rustc_clean(label="type_of", cfg="cfail2")]
318 #[rustc_clean(label="generics_of", cfg="cfail2")]
319 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
320 #[rustc_clean(label="hir_owner", cfg="cfail3")]
321 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
322 #[rustc_clean(label="type_of", cfg="cfail3")]
323 #[rustc_clean(label="generics_of", cfg="cfail3")]
324 #[rustc_clean(label="predicates_of", cfg="cfail3")]
325 struct AddTypeParameterBoundWhereClause
<T
>(
330 // Empty struct ----------------------------------------------------------------
331 // Since we cannot change anything in this case, we just make sure that the
332 // fingerprint is stable (i.e., that there are no random influences like memory
333 // addresses taken into account by the hashing algorithm).
334 // Note: there is no #[cfg(...)], so this is ALWAYS compiled
335 #[rustc_clean(label="hir_owner", cfg="cfail2")]
336 #[rustc_clean(label="hir_owner_nodes", cfg="cfail2")]
337 #[rustc_clean(label="type_of", cfg="cfail2")]
338 #[rustc_clean(label="generics_of", cfg="cfail2")]
339 #[rustc_clean(label="predicates_of", cfg="cfail2")]
340 #[rustc_clean(label="hir_owner", cfg="cfail3")]
341 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
342 #[rustc_clean(label="type_of", cfg="cfail3")]
343 #[rustc_clean(label="generics_of", cfg="cfail3")]
344 #[rustc_clean(label="predicates_of", cfg="cfail3")]
345 pub struct EmptyStruct
;
348 // Visibility ------------------------------------------------------------------
354 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
355 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
356 #[rustc_clean(label="type_of", cfg="cfail2")]
357 #[rustc_clean(label="generics_of", cfg="cfail2")]
358 #[rustc_clean(label="predicates_of", cfg="cfail2")]
359 #[rustc_clean(label="hir_owner", cfg="cfail3")]
360 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
361 #[rustc_clean(label="type_of", cfg="cfail3")]
362 #[rustc_clean(label="generics_of", cfg="cfail3")]
363 #[rustc_clean(label="predicates_of", cfg="cfail3")]
364 pub struct Visibility
;
366 struct ReferencedType1
;
367 struct ReferencedType2
;
369 // Tuple Struct Change Field Type Indirectly -----------------------------------
370 mod tuple_struct_change_field_type_indirectly
{
372 use super::ReferencedType1
as FieldType
;
374 use super::ReferencedType2
as FieldType
;
376 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
377 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
378 #[rustc_clean(label="type_of", cfg="cfail2")]
379 #[rustc_clean(label="generics_of", cfg="cfail2")]
380 #[rustc_clean(label="predicates_of", cfg="cfail2")]
381 #[rustc_clean(label="hir_owner", cfg="cfail3")]
382 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
383 #[rustc_clean(label="type_of", cfg="cfail3")]
384 #[rustc_clean(label="generics_of", cfg="cfail3")]
385 #[rustc_clean(label="predicates_of", cfg="cfail3")]
392 // Record Struct Change Field Type Indirectly -----------------------------------
393 mod record_struct_change_field_type_indirectly
{
395 use super::ReferencedType1
as FieldType
;
397 use super::ReferencedType2
as FieldType
;
399 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
400 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
401 #[rustc_clean(label="type_of", cfg="cfail2")]
402 #[rustc_clean(label="generics_of", cfg="cfail2")]
403 #[rustc_clean(label="predicates_of", cfg="cfail2")]
404 #[rustc_clean(label="hir_owner", cfg="cfail3")]
405 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
406 #[rustc_clean(label="type_of", cfg="cfail3")]
407 #[rustc_clean(label="generics_of", cfg="cfail3")]
408 #[rustc_clean(label="predicates_of", cfg="cfail3")]
409 struct RecordStruct
{
417 trait ReferencedTrait1 {}
418 trait ReferencedTrait2 {}
420 // Change Trait Bound Indirectly -----------------------------------------------
421 mod change_trait_bound_indirectly
{
423 use super::ReferencedTrait1
as Trait
;
425 use super::ReferencedTrait2
as Trait
;
427 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
428 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
429 #[rustc_clean(label="type_of", cfg="cfail2")]
430 #[rustc_clean(label="generics_of", cfg="cfail2")]
431 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
432 #[rustc_clean(label="hir_owner", cfg="cfail3")]
433 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
434 #[rustc_clean(label="type_of", cfg="cfail3")]
435 #[rustc_clean(label="generics_of", cfg="cfail3")]
436 #[rustc_clean(label="predicates_of", cfg="cfail3")]
437 struct Struct
<T
: Trait
>(T
);
440 // Change Trait Bound Indirectly In Where Clause -------------------------------
441 mod change_trait_bound_indirectly_in_where_clause
{
443 use super::ReferencedTrait1
as Trait
;
445 use super::ReferencedTrait2
as Trait
;
447 #[rustc_dirty(label="hir_owner", cfg="cfail2")]
448 #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")]
449 #[rustc_clean(label="type_of", cfg="cfail2")]
450 #[rustc_clean(label="generics_of", cfg="cfail2")]
451 #[rustc_dirty(label="predicates_of", cfg="cfail2")]
452 #[rustc_clean(label="hir_owner", cfg="cfail3")]
453 #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")]
454 #[rustc_clean(label="type_of", cfg="cfail3")]
455 #[rustc_clean(label="generics_of", cfg="cfail3")]
456 #[rustc_clean(label="predicates_of", cfg="cfail3")]
457 struct Struct
<T
>(T
) where T
: Trait
;