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 -O
16 // [cfail1]compile-flags: -Zincremental-ignore-spans
17 // [cfail2]compile-flags: -Zincremental-ignore-spans
18 // [cfail3]compile-flags: -Zincremental-ignore-spans
21 #![feature(rustc_attrs)]
22 #![feature(stmt_expr_attributes)]
27 // Change enum visibility -----------------------------------------------------
28 #[cfg(any(cfail1,cfail4))]
29 enum EnumVisibility { A }
31 #[cfg(not(any(cfail1,cfail4)))]
32 #[rustc_clean(cfg="cfail2")]
33 #[rustc_clean(cfg="cfail3")]
34 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
35 #[rustc_clean(cfg="cfail6")]
36 pub enum EnumVisibility { A }
40 // Change name of a c-style variant -------------------------------------------
41 #[cfg(any(cfail1,cfail4))]
42 enum EnumChangeNameCStyleVariant {
47 #[cfg(not(any(cfail1,cfail4)))]
48 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
49 #[rustc_clean(cfg="cfail3")]
50 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
51 #[rustc_clean(cfg="cfail6")]
52 enum EnumChangeNameCStyleVariant {
59 // Change name of a tuple-style variant ---------------------------------------
60 #[cfg(any(cfail1,cfail4))]
61 enum EnumChangeNameTupleStyleVariant {
66 #[cfg(not(any(cfail1,cfail4)))]
67 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
68 #[rustc_clean(cfg="cfail3")]
69 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
70 #[rustc_clean(cfg="cfail6")]
71 enum EnumChangeNameTupleStyleVariant {
73 Variant2Changed(u32, f32),
78 // Change name of a struct-style variant --------------------------------------
79 #[cfg(any(cfail1,cfail4))]
80 enum EnumChangeNameStructStyleVariant {
82 Variant2 { a: u32, b: f32 },
85 #[cfg(not(any(cfail1,cfail4)))]
86 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
87 #[rustc_clean(cfg="cfail3")]
88 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
89 #[rustc_clean(cfg="cfail6")]
90 enum EnumChangeNameStructStyleVariant {
92 Variant2Changed { a: u32, b: f32 },
97 // Change the value of a c-style variant --------------------------------------
98 #[cfg(any(cfail1,cfail4))]
99 enum EnumChangeValueCStyleVariant0 {
104 #[cfg(not(any(cfail1,cfail4)))]
105 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
106 #[rustc_clean(cfg="cfail3")]
107 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
108 #[rustc_clean(cfg="cfail6")]
109 enum EnumChangeValueCStyleVariant0 {
114 #[cfg(any(cfail1,cfail4))]
115 enum EnumChangeValueCStyleVariant1 {
120 #[cfg(not(any(cfail1,cfail4)))]
121 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
122 #[rustc_clean(cfg="cfail3")]
123 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
124 #[rustc_clean(cfg="cfail6")]
125 enum EnumChangeValueCStyleVariant1 {
132 // Add a c-style variant ------------------------------------------------------
133 #[cfg(any(cfail1,cfail4))]
134 enum EnumAddCStyleVariant {
138 #[cfg(not(any(cfail1,cfail4)))]
139 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
140 #[rustc_clean(cfg="cfail3")]
141 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
142 #[rustc_clean(cfg="cfail6")]
143 enum EnumAddCStyleVariant {
150 // Remove a c-style variant ---------------------------------------------------
151 #[cfg(any(cfail1,cfail4))]
152 enum EnumRemoveCStyleVariant {
157 #[cfg(not(any(cfail1,cfail4)))]
158 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
159 #[rustc_clean(cfg="cfail3")]
160 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
161 #[rustc_clean(cfg="cfail6")]
162 enum EnumRemoveCStyleVariant {
168 // Add a tuple-style variant --------------------------------------------------
169 #[cfg(any(cfail1,cfail4))]
170 enum EnumAddTupleStyleVariant {
174 #[cfg(not(any(cfail1,cfail4)))]
175 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
176 #[rustc_clean(cfg="cfail3")]
177 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
178 #[rustc_clean(cfg="cfail6")]
179 enum EnumAddTupleStyleVariant {
186 // Remove a tuple-style variant -----------------------------------------------
187 #[cfg(any(cfail1,cfail4))]
188 enum EnumRemoveTupleStyleVariant {
193 #[cfg(not(any(cfail1,cfail4)))]
194 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
195 #[rustc_clean(cfg="cfail3")]
196 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
197 #[rustc_clean(cfg="cfail6")]
198 enum EnumRemoveTupleStyleVariant {
204 // Add a struct-style variant -------------------------------------------------
205 #[cfg(any(cfail1,cfail4))]
206 enum EnumAddStructStyleVariant {
210 #[cfg(not(any(cfail1,cfail4)))]
211 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
212 #[rustc_clean(cfg="cfail3")]
213 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
214 #[rustc_clean(cfg="cfail6")]
215 enum EnumAddStructStyleVariant {
217 Variant2 { a: u32, b: f32 },
222 // Remove a struct-style variant ----------------------------------------------
223 #[cfg(any(cfail1,cfail4))]
224 enum EnumRemoveStructStyleVariant {
226 Variant2 { a: u32, b: f32 },
229 #[cfg(not(any(cfail1,cfail4)))]
230 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
231 #[rustc_clean(cfg="cfail3")]
232 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
233 #[rustc_clean(cfg="cfail6")]
234 enum EnumRemoveStructStyleVariant {
240 // Change the type of a field in a tuple-style variant ------------------------
241 #[cfg(any(cfail1,cfail4))]
242 enum EnumChangeFieldTypeTupleStyleVariant {
246 #[cfg(not(any(cfail1,cfail4)))]
247 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
248 #[rustc_clean(cfg="cfail3")]
249 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
250 #[rustc_clean(cfg="cfail6")]
251 enum EnumChangeFieldTypeTupleStyleVariant {
258 // Change the type of a field in a struct-style variant -----------------------
259 #[cfg(any(cfail1,cfail4))]
260 enum EnumChangeFieldTypeStructStyleVariant {
262 Variant2 { a: u32, b: u32 },
265 #[cfg(not(any(cfail1,cfail4)))]
266 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
267 #[rustc_clean(cfg="cfail3")]
268 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
269 #[rustc_clean(cfg="cfail6")]
270 enum EnumChangeFieldTypeStructStyleVariant {
280 // Change the name of a field in a struct-style variant -----------------------
281 #[cfg(any(cfail1,cfail4))]
282 enum EnumChangeFieldNameStructStyleVariant {
283 Variant1 { a: u32, b: u32 },
286 #[cfg(not(any(cfail1,cfail4)))]
287 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
288 #[rustc_clean(cfg="cfail3")]
289 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
290 #[rustc_clean(cfg="cfail6")]
291 enum EnumChangeFieldNameStructStyleVariant {
292 Variant1 { a: u32, c: u32 },
297 // Change order of fields in a tuple-style variant ----------------------------
298 #[cfg(any(cfail1,cfail4))]
299 enum EnumChangeOrderTupleStyleVariant {
303 #[cfg(not(any(cfail1,cfail4)))]
304 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
305 #[rustc_clean(cfg="cfail3")]
306 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
307 #[rustc_clean(cfg="cfail6")]
308 enum EnumChangeOrderTupleStyleVariant {
316 // Change order of fields in a struct-style variant ---------------------------
317 #[cfg(any(cfail1,cfail4))]
318 enum EnumChangeFieldOrderStructStyleVariant {
319 Variant1 { a: u32, b: f32 },
322 #[cfg(not(any(cfail1,cfail4)))]
323 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
324 #[rustc_clean(cfg="cfail3")]
325 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
326 #[rustc_clean(cfg="cfail6")]
327 enum EnumChangeFieldOrderStructStyleVariant {
328 Variant1 { b: f32, a: u32 },
333 // Add a field to a tuple-style variant ---------------------------------------
334 #[cfg(any(cfail1,cfail4))]
335 enum EnumAddFieldTupleStyleVariant {
339 #[cfg(not(any(cfail1,cfail4)))]
340 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
341 #[rustc_clean(cfg="cfail3")]
342 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
343 #[rustc_clean(cfg="cfail6")]
344 enum EnumAddFieldTupleStyleVariant {
345 Variant1(u32, u32, u32),
350 // Add a field to a struct-style variant --------------------------------------
351 #[cfg(any(cfail1,cfail4))]
352 enum EnumAddFieldStructStyleVariant {
353 Variant1 { a: u32, b: u32 },
356 #[cfg(not(any(cfail1,cfail4)))]
357 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
358 #[rustc_clean(cfg="cfail3")]
359 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
360 #[rustc_clean(cfg="cfail6")]
361 enum EnumAddFieldStructStyleVariant {
362 Variant1 { a: u32, b: u32, c: u32 },
367 // Add #[must_use] to the enum ------------------------------------------------
368 #[cfg(any(cfail1,cfail4))]
369 enum EnumAddMustUse {
374 #[cfg(not(any(cfail1,cfail4)))]
375 #[rustc_clean(cfg="cfail2")]
376 #[rustc_clean(cfg="cfail3")]
377 #[rustc_clean(cfg="cfail5")]
378 #[rustc_clean(cfg="cfail6")]
380 enum EnumAddMustUse {
387 // Add #[repr(C)] to the enum -------------------------------------------------
388 #[cfg(any(cfail1,cfail4))]
394 #[cfg(not(any(cfail1,cfail4)))]
395 #[rustc_clean(cfg="cfail2", except="type_of")]
396 #[rustc_clean(cfg="cfail3")]
397 #[rustc_clean(cfg="cfail5", except="type_of")]
398 #[rustc_clean(cfg="cfail6")]
407 // Change the name of a type parameter ----------------------------------------
408 #[cfg(any(cfail1,cfail4))]
409 enum EnumChangeNameOfTypeParameter<S> {
413 #[cfg(not(any(cfail1,cfail4)))]
414 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
415 #[rustc_clean(cfg="cfail3")]
416 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
417 #[rustc_clean(cfg="cfail6")]
418 enum EnumChangeNameOfTypeParameter<T> {
424 // Add a type parameter ------------------------------------------------------
425 #[cfg(any(cfail1,cfail4))]
426 enum EnumAddTypeParameter<S> {
431 #[cfg(not(any(cfail1,cfail4)))]
432 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
433 #[rustc_clean(cfg="cfail3")]
434 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
435 #[rustc_clean(cfg="cfail6")]
436 enum EnumAddTypeParameter<S, T> {
443 // Change the name of a lifetime parameter ------------------------------------
444 #[cfg(any(cfail1,cfail4))]
445 enum EnumChangeNameOfLifetimeParameter<'a> {
449 #[cfg(not(any(cfail1,cfail4)))]
450 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
451 #[rustc_clean(cfg="cfail3")]
452 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
453 #[rustc_clean(cfg="cfail6")]
454 enum EnumChangeNameOfLifetimeParameter<'b> {
460 // Add a lifetime parameter ---------------------------------------------------
461 #[cfg(any(cfail1,cfail4))]
462 enum EnumAddLifetimeParameter<'a> {
467 #[cfg(not(any(cfail1,cfail4)))]
468 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
469 #[rustc_clean(cfg="cfail3")]
470 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
471 #[rustc_clean(cfg="cfail6")]
472 enum EnumAddLifetimeParameter<'a, 'b> {
479 // Add a lifetime bound to a lifetime parameter -------------------------------
480 #[cfg(any(cfail1,cfail4))]
481 enum EnumAddLifetimeParameterBound<'a, 'b> {
486 #[cfg(not(any(cfail1,cfail4)))]
487 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
488 #[rustc_clean(cfg="cfail3")]
489 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
490 #[rustc_clean(cfg="cfail6")]
491 enum EnumAddLifetimeParameterBound<'a, 'b: 'a> {
496 // Add a lifetime bound to a type parameter -----------------------------------
497 #[cfg(any(cfail1,cfail4))]
498 enum EnumAddLifetimeBoundToParameter<'a, T> {
503 #[cfg(not(any(cfail1,cfail4)))]
504 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
505 #[rustc_clean(cfg="cfail3")]
506 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
507 #[rustc_clean(cfg="cfail6")]
508 enum EnumAddLifetimeBoundToParameter<'a, T: 'a> {
515 // Add a trait bound to a type parameter --------------------------------------
516 #[cfg(any(cfail1,cfail4))]
517 enum EnumAddTraitBound<S> {
521 #[cfg(not(any(cfail1,cfail4)))]
522 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
523 #[rustc_clean(cfg="cfail3")]
524 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
525 #[rustc_clean(cfg="cfail6")]
526 enum EnumAddTraitBound<T: Sync> {
532 // Add a lifetime bound to a lifetime parameter in where clause ---------------
533 #[cfg(any(cfail1,cfail4))]
534 enum EnumAddLifetimeParameterBoundWhere<'a, 'b> {
539 #[cfg(not(any(cfail1,cfail4)))]
540 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
541 #[rustc_clean(cfg="cfail3")]
542 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
543 #[rustc_clean(cfg="cfail6")]
544 enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a {
551 // Add a lifetime bound to a type parameter in where clause -------------------
552 #[cfg(any(cfail1,cfail4))]
553 enum EnumAddLifetimeBoundToParameterWhere<'a, T> {
558 #[cfg(not(any(cfail1,cfail4)))]
559 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
560 #[rustc_clean(cfg="cfail3")]
561 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
562 #[rustc_clean(cfg="cfail6")]
563 enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a {
570 // Add a trait bound to a type parameter in where clause ----------------------
571 #[cfg(any(cfail1,cfail4))]
572 enum EnumAddTraitBoundWhere<S> {
576 #[cfg(not(any(cfail1,cfail4)))]
577 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
578 #[rustc_clean(cfg="cfail3")]
579 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
580 #[rustc_clean(cfg="cfail6")]
581 enum EnumAddTraitBoundWhere<T> where T: Sync {
587 // In an enum with two variants, swap usage of type parameters ----------------
588 #[cfg(any(cfail1,cfail4))]
589 enum EnumSwapUsageTypeParameters<A, B> {
594 #[cfg(not(any(cfail1,cfail4)))]
595 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
596 #[rustc_clean(cfg="cfail3")]
597 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
598 #[rustc_clean(cfg="cfail6")]
599 enum EnumSwapUsageTypeParameters<A, B> {
610 // In an enum with two variants, swap usage of lifetime parameters ------------
611 #[cfg(any(cfail1,cfail4))]
612 enum EnumSwapUsageLifetimeParameters<'a, 'b> {
613 Variant1 { a: &'a u32 },
614 Variant2 { b: &'b u32 },
617 #[cfg(not(any(cfail1,cfail4)))]
618 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
619 #[rustc_clean(cfg="cfail3")]
620 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
621 #[rustc_clean(cfg="cfail6")]
622 enum EnumSwapUsageLifetimeParameters<'a, 'b> {
633 struct ReferencedType1;
634 struct ReferencedType2;
638 // Change field type in tuple-style variant indirectly by modifying a use statement
639 mod change_field_type_indirectly_tuple_style {
640 #[cfg(any(cfail1,cfail4))]
641 use super::ReferencedType1 as FieldType;
642 #[cfg(not(any(cfail1,cfail4)))]
643 use super::ReferencedType2 as FieldType;
645 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
646 #[rustc_clean(cfg="cfail3")]
647 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
648 #[rustc_clean(cfg="cfail6")]
658 // Change field type in record-style variant indirectly by modifying a use statement
659 mod change_field_type_indirectly_struct_style {
660 #[cfg(any(cfail1,cfail4))]
661 use super::ReferencedType1 as FieldType;
662 #[cfg(not(any(cfail1,cfail4)))]
663 use super::ReferencedType2 as FieldType;
665 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
666 #[rustc_clean(cfg="cfail3")]
667 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
668 #[rustc_clean(cfg="cfail6")]
678 trait ReferencedTrait1 {}
679 trait ReferencedTrait2 {}
683 // Change trait bound of type parameter indirectly by modifying a use statement
684 mod change_trait_bound_indirectly {
685 #[cfg(any(cfail1,cfail4))]
686 use super::ReferencedTrait1 as Trait;
687 #[cfg(not(any(cfail1,cfail4)))]
688 use super::ReferencedTrait2 as Trait;
690 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
691 #[rustc_clean(cfg="cfail3")]
692 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
693 #[rustc_clean(cfg="cfail6")]
694 enum Enum<T: Trait> {
701 // Change trait bound of type parameter in where clause indirectly by modifying a use statement
702 mod change_trait_bound_indirectly_where {
703 #[cfg(any(cfail1,cfail4))]
704 use super::ReferencedTrait1 as Trait;
705 #[cfg(not(any(cfail1,cfail4)))]
706 use super::ReferencedTrait2 as Trait;
708 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
709 #[rustc_clean(cfg="cfail3")]
710 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
711 #[rustc_clean(cfg="cfail6")]
712 enum Enum<T> where T: Trait {