1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for enum 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 enum 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.
13 // build-pass (FIXME(62277): could be check-pass?)
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
24 #![feature(rustc_attrs)]
25 #![feature(stmt_expr_attributes)]
30 // Change enum visibility -----------------------------------------------------
31 #[cfg(any(cfail1,cfail4))]
32 enum EnumVisibility { A }
34 #[cfg(not(any(cfail1,cfail4)))]
35 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
36 #[rustc_clean(cfg="cfail3")]
37 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
38 #[rustc_clean(cfg="cfail6")]
39 pub enum EnumVisibility {
45 // Change name of a c-style variant -------------------------------------------
46 #[cfg(any(cfail1,cfail4))]
47 enum EnumChangeNameCStyleVariant {
52 #[cfg(not(any(cfail1,cfail4)))]
53 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
54 #[rustc_clean(cfg="cfail3")]
55 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
56 #[rustc_clean(cfg="cfail6")]
57 enum EnumChangeNameCStyleVariant {
64 // Change name of a tuple-style variant ---------------------------------------
65 #[cfg(any(cfail1,cfail4))]
66 enum EnumChangeNameTupleStyleVariant {
71 #[cfg(not(any(cfail1,cfail4)))]
72 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
73 #[rustc_clean(cfg="cfail3")]
74 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
75 #[rustc_clean(cfg="cfail6")]
76 enum EnumChangeNameTupleStyleVariant {
78 Variant2Changed(u32, f32),
83 // Change name of a struct-style variant --------------------------------------
84 #[cfg(any(cfail1,cfail4))]
85 enum EnumChangeNameStructStyleVariant {
87 Variant2 { a: u32, b: f32 },
90 #[cfg(not(any(cfail1,cfail4)))]
91 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
92 #[rustc_clean(cfg="cfail3")]
93 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
94 #[rustc_clean(cfg="cfail6")]
95 enum EnumChangeNameStructStyleVariant {
97 Variant2Changed { a: u32, b: f32 },
102 // Change the value of a c-style variant --------------------------------------
103 #[cfg(any(cfail1,cfail4))]
104 enum EnumChangeValueCStyleVariant0 {
109 #[cfg(not(any(cfail1,cfail4)))]
110 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
111 #[rustc_clean(cfg="cfail3")]
112 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
113 #[rustc_clean(cfg="cfail6")]
114 enum EnumChangeValueCStyleVariant0 {
119 #[cfg(any(cfail1,cfail4))]
120 enum EnumChangeValueCStyleVariant1 {
125 #[cfg(not(any(cfail1,cfail4)))]
126 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
127 #[rustc_clean(cfg="cfail3")]
128 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
129 #[rustc_clean(cfg="cfail6")]
130 enum EnumChangeValueCStyleVariant1 {
137 // Add a c-style variant ------------------------------------------------------
138 #[cfg(any(cfail1,cfail4))]
139 enum EnumAddCStyleVariant {
143 #[cfg(not(any(cfail1,cfail4)))]
144 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
145 #[rustc_clean(cfg="cfail3")]
146 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
147 #[rustc_clean(cfg="cfail6")]
148 enum EnumAddCStyleVariant {
155 // Remove a c-style variant ---------------------------------------------------
156 #[cfg(any(cfail1,cfail4))]
157 enum EnumRemoveCStyleVariant {
162 #[cfg(not(any(cfail1,cfail4)))]
163 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
164 #[rustc_clean(cfg="cfail3")]
165 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
166 #[rustc_clean(cfg="cfail6")]
167 enum EnumRemoveCStyleVariant {
173 // Add a tuple-style variant --------------------------------------------------
174 #[cfg(any(cfail1,cfail4))]
175 enum EnumAddTupleStyleVariant {
179 #[cfg(not(any(cfail1,cfail4)))]
180 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
181 #[rustc_clean(cfg="cfail3")]
182 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
183 #[rustc_clean(cfg="cfail6")]
184 enum EnumAddTupleStyleVariant {
191 // Remove a tuple-style variant -----------------------------------------------
192 #[cfg(any(cfail1,cfail4))]
193 enum EnumRemoveTupleStyleVariant {
198 #[cfg(not(any(cfail1,cfail4)))]
199 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
200 #[rustc_clean(cfg="cfail3")]
201 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
202 #[rustc_clean(cfg="cfail6")]
203 enum EnumRemoveTupleStyleVariant {
209 // Add a struct-style variant -------------------------------------------------
210 #[cfg(any(cfail1,cfail4))]
211 enum EnumAddStructStyleVariant {
215 #[cfg(not(any(cfail1,cfail4)))]
216 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
217 #[rustc_clean(cfg="cfail3")]
218 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
219 #[rustc_clean(cfg="cfail6")]
220 enum EnumAddStructStyleVariant {
222 Variant2 { a: u32, b: f32 },
227 // Remove a struct-style variant ----------------------------------------------
228 #[cfg(any(cfail1,cfail4))]
229 enum EnumRemoveStructStyleVariant {
231 Variant2 { a: u32, b: f32 },
234 #[cfg(not(any(cfail1,cfail4)))]
235 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
236 #[rustc_clean(cfg="cfail3")]
237 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
238 #[rustc_clean(cfg="cfail6")]
239 enum EnumRemoveStructStyleVariant {
245 // Change the type of a field in a tuple-style variant ------------------------
246 #[cfg(any(cfail1,cfail4))]
247 enum EnumChangeFieldTypeTupleStyleVariant {
251 #[cfg(not(any(cfail1,cfail4)))]
252 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
253 #[rustc_clean(cfg="cfail3")]
254 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
255 #[rustc_clean(cfg="cfail6")]
256 enum EnumChangeFieldTypeTupleStyleVariant {
263 // Change the type of a field in a struct-style variant -----------------------
264 #[cfg(any(cfail1,cfail4))]
265 enum EnumChangeFieldTypeStructStyleVariant {
267 Variant2 { a: u32, b: u32 },
270 #[cfg(not(any(cfail1,cfail4)))]
271 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
272 #[rustc_clean(cfg="cfail3")]
273 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
274 #[rustc_clean(cfg="cfail6")]
275 enum EnumChangeFieldTypeStructStyleVariant {
285 // Change the name of a field in a struct-style variant -----------------------
286 #[cfg(any(cfail1,cfail4))]
287 enum EnumChangeFieldNameStructStyleVariant {
288 Variant1 { a: u32, b: u32 },
291 #[cfg(not(any(cfail1,cfail4)))]
292 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
293 #[rustc_clean(cfg="cfail3")]
294 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
295 #[rustc_clean(cfg="cfail6")]
296 enum EnumChangeFieldNameStructStyleVariant {
297 Variant1 { a: u32, c: u32 },
302 // Change order of fields in a tuple-style variant ----------------------------
303 #[cfg(any(cfail1,cfail4))]
304 enum EnumChangeOrderTupleStyleVariant {
308 #[cfg(not(any(cfail1,cfail4)))]
309 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
310 #[rustc_clean(cfg="cfail3")]
311 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
312 #[rustc_clean(cfg="cfail6")]
313 enum EnumChangeOrderTupleStyleVariant {
321 // Change order of fields in a struct-style variant ---------------------------
322 #[cfg(any(cfail1,cfail4))]
323 enum EnumChangeFieldOrderStructStyleVariant {
324 Variant1 { a: u32, b: f32 },
327 #[cfg(not(any(cfail1,cfail4)))]
328 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
329 #[rustc_clean(cfg="cfail3")]
330 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
331 #[rustc_clean(cfg="cfail6")]
332 enum EnumChangeFieldOrderStructStyleVariant {
333 Variant1 { b: f32, a: u32 },
338 // Add a field to a tuple-style variant ---------------------------------------
339 #[cfg(any(cfail1,cfail4))]
340 enum EnumAddFieldTupleStyleVariant {
344 #[cfg(not(any(cfail1,cfail4)))]
345 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
346 #[rustc_clean(cfg="cfail3")]
347 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
348 #[rustc_clean(cfg="cfail6")]
349 enum EnumAddFieldTupleStyleVariant {
350 Variant1(u32, u32, u32),
355 // Add a field to a struct-style variant --------------------------------------
356 #[cfg(any(cfail1,cfail4))]
357 enum EnumAddFieldStructStyleVariant {
358 Variant1 { a: u32, b: u32 },
361 #[cfg(not(any(cfail1,cfail4)))]
362 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
363 #[rustc_clean(cfg="cfail3")]
364 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
365 #[rustc_clean(cfg="cfail6")]
366 enum EnumAddFieldStructStyleVariant {
367 Variant1 { a: u32, b: u32, c: u32 },
372 // Add #[must_use] to the enum ------------------------------------------------
373 #[cfg(any(cfail1,cfail4))]
374 enum EnumAddMustUse {
379 #[cfg(not(any(cfail1,cfail4)))]
380 #[rustc_clean(cfg="cfail2")]
381 #[rustc_clean(cfg="cfail3")]
382 #[rustc_clean(cfg="cfail5")]
383 #[rustc_clean(cfg="cfail6")]
385 enum EnumAddMustUse {
392 // Add #[repr(C)] to the enum -------------------------------------------------
393 #[cfg(any(cfail1,cfail4))]
399 #[cfg(not(any(cfail1,cfail4)))]
400 #[rustc_clean(cfg="cfail2", except="type_of")]
401 #[rustc_clean(cfg="cfail3")]
402 #[rustc_clean(cfg="cfail5", except="type_of")]
403 #[rustc_clean(cfg="cfail6")]
412 // Change the name of a type parameter ----------------------------------------
413 #[cfg(any(cfail1,cfail4))]
414 enum EnumChangeNameOfTypeParameter<S> {
418 #[cfg(not(any(cfail1,cfail4)))]
419 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
420 #[rustc_clean(cfg="cfail3")]
421 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
422 #[rustc_clean(cfg="cfail6")]
423 enum EnumChangeNameOfTypeParameter<T> {
429 // Add a type parameter ------------------------------------------------------
430 #[cfg(any(cfail1,cfail4))]
431 enum EnumAddTypeParameter<S> {
436 #[cfg(not(any(cfail1,cfail4)))]
437 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
438 #[rustc_clean(cfg="cfail3")]
439 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
440 #[rustc_clean(cfg="cfail6")]
441 enum EnumAddTypeParameter<S, T> {
448 // Change the name of a lifetime parameter ------------------------------------
449 #[cfg(any(cfail1,cfail4))]
450 enum EnumChangeNameOfLifetimeParameter<'a> {
454 #[cfg(not(any(cfail1,cfail4)))]
455 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
456 #[rustc_clean(cfg="cfail3")]
457 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
458 #[rustc_clean(cfg="cfail6")]
459 enum EnumChangeNameOfLifetimeParameter<'b> {
465 // Add a lifetime parameter ---------------------------------------------------
466 #[cfg(any(cfail1,cfail4))]
467 enum EnumAddLifetimeParameter<'a> {
472 #[cfg(not(any(cfail1,cfail4)))]
473 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
474 #[rustc_clean(cfg="cfail3")]
475 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
476 #[rustc_clean(cfg="cfail6")]
477 enum EnumAddLifetimeParameter<'a, 'b> {
484 // Add a lifetime bound to a lifetime parameter -------------------------------
485 #[cfg(any(cfail1,cfail4))]
486 enum EnumAddLifetimeParameterBound<'a, 'b> {
491 #[cfg(not(any(cfail1,cfail4)))]
492 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
493 #[rustc_clean(cfg="cfail3")]
494 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
495 #[rustc_clean(cfg="cfail6")]
496 enum EnumAddLifetimeParameterBound<'a, 'b: 'a> {
501 // Add a lifetime bound to a type parameter -----------------------------------
502 #[cfg(any(cfail1,cfail4))]
503 enum EnumAddLifetimeBoundToParameter<'a, T> {
508 #[cfg(not(any(cfail1,cfail4)))]
509 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
510 #[rustc_clean(cfg="cfail3")]
511 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
512 #[rustc_clean(cfg="cfail6")]
513 enum EnumAddLifetimeBoundToParameter<'a, T: 'a> {
520 // Add a trait bound to a type parameter --------------------------------------
521 #[cfg(any(cfail1,cfail4))]
522 enum EnumAddTraitBound<S> {
526 #[cfg(not(any(cfail1,cfail4)))]
527 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
528 #[rustc_clean(cfg="cfail3")]
529 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
530 #[rustc_clean(cfg="cfail6")]
531 enum EnumAddTraitBound<T: Sync> {
537 // Add a lifetime bound to a lifetime parameter in where clause ---------------
538 #[cfg(any(cfail1,cfail4))]
539 enum EnumAddLifetimeParameterBoundWhere<'a, 'b> {
544 #[cfg(not(any(cfail1,cfail4)))]
545 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
546 #[rustc_clean(cfg="cfail3")]
547 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
548 #[rustc_clean(cfg="cfail6")]
549 enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a {
556 // Add a lifetime bound to a type parameter in where clause -------------------
557 #[cfg(any(cfail1,cfail4))]
558 enum EnumAddLifetimeBoundToParameterWhere<'a, T> {
563 #[cfg(not(any(cfail1,cfail4)))]
564 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
565 #[rustc_clean(cfg="cfail3")]
566 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
567 #[rustc_clean(cfg="cfail6")]
568 enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a {
575 // Add a trait bound to a type parameter in where clause ----------------------
576 #[cfg(any(cfail1,cfail4))]
577 enum EnumAddTraitBoundWhere<S> {
581 #[cfg(not(any(cfail1,cfail4)))]
582 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
583 #[rustc_clean(cfg="cfail3")]
584 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
585 #[rustc_clean(cfg="cfail6")]
586 enum EnumAddTraitBoundWhere<T> where T: Sync {
592 // In an enum with two variants, swap usage of type parameters ----------------
593 #[cfg(any(cfail1,cfail4))]
594 enum EnumSwapUsageTypeParameters<A, B> {
599 #[cfg(not(any(cfail1,cfail4)))]
600 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
601 #[rustc_clean(cfg="cfail3")]
602 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
603 #[rustc_clean(cfg="cfail6")]
604 enum EnumSwapUsageTypeParameters<A, B> {
615 // In an enum with two variants, swap usage of lifetime parameters ------------
616 #[cfg(any(cfail1,cfail4))]
617 enum EnumSwapUsageLifetimeParameters<'a, 'b> {
618 Variant1 { a: &'a u32 },
619 Variant2 { b: &'b u32 },
622 #[cfg(not(any(cfail1,cfail4)))]
623 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
624 #[rustc_clean(cfg="cfail3")]
625 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
626 #[rustc_clean(cfg="cfail6")]
627 enum EnumSwapUsageLifetimeParameters<'a, 'b> {
638 struct ReferencedType1;
639 struct ReferencedType2;
643 // Change field type in tuple-style variant indirectly by modifying a use statement
644 mod change_field_type_indirectly_tuple_style {
645 #[cfg(any(cfail1,cfail4))]
646 use super::ReferencedType1 as FieldType;
647 #[cfg(not(any(cfail1,cfail4)))]
648 use super::ReferencedType2 as FieldType;
650 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
651 #[rustc_clean(cfg="cfail3")]
652 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
653 #[rustc_clean(cfg="cfail6")]
663 // Change field type in record-style variant indirectly by modifying a use statement
664 mod change_field_type_indirectly_struct_style {
665 #[cfg(any(cfail1,cfail4))]
666 use super::ReferencedType1 as FieldType;
667 #[cfg(not(any(cfail1,cfail4)))]
668 use super::ReferencedType2 as FieldType;
670 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
671 #[rustc_clean(cfg="cfail3")]
672 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
673 #[rustc_clean(cfg="cfail6")]
683 trait ReferencedTrait1 {}
684 trait ReferencedTrait2 {}
688 // Change trait bound of type parameter indirectly by modifying a use statement
689 mod change_trait_bound_indirectly {
690 #[cfg(any(cfail1,cfail4))]
691 use super::ReferencedTrait1 as Trait;
692 #[cfg(not(any(cfail1,cfail4)))]
693 use super::ReferencedTrait2 as Trait;
695 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
696 #[rustc_clean(cfg="cfail3")]
697 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
698 #[rustc_clean(cfg="cfail6")]
699 enum Enum<T: Trait> {
706 // Change trait bound of type parameter in where clause indirectly by modifying a use statement
707 mod change_trait_bound_indirectly_where {
708 #[cfg(any(cfail1,cfail4))]
709 use super::ReferencedTrait1 as Trait;
710 #[cfg(not(any(cfail1,cfail4)))]
711 use super::ReferencedTrait2 as Trait;
713 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
714 #[rustc_clean(cfg="cfail3")]
715 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
716 #[rustc_clean(cfg="cfail6")]
717 enum Enum<T> where T: Trait {