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
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")]
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 { A }
43 // Change name of a c-style variant -------------------------------------------
44 #[cfg(any(cfail1,cfail4))]
45 enum EnumChangeNameCStyleVariant {
50 #[cfg(not(any(cfail1,cfail4)))]
51 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
52 #[rustc_clean(cfg="cfail3")]
53 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
54 #[rustc_clean(cfg="cfail6")]
55 enum EnumChangeNameCStyleVariant {
62 // Change name of a tuple-style variant ---------------------------------------
63 #[cfg(any(cfail1,cfail4))]
64 enum EnumChangeNameTupleStyleVariant {
69 #[cfg(not(any(cfail1,cfail4)))]
70 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
71 #[rustc_clean(cfg="cfail3")]
72 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
73 #[rustc_clean(cfg="cfail6")]
74 enum EnumChangeNameTupleStyleVariant {
76 Variant2Changed(u32, f32),
81 // Change name of a struct-style variant --------------------------------------
82 #[cfg(any(cfail1,cfail4))]
83 enum EnumChangeNameStructStyleVariant {
85 Variant2 { a: u32, b: f32 },
88 #[cfg(not(any(cfail1,cfail4)))]
89 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
90 #[rustc_clean(cfg="cfail3")]
91 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
92 #[rustc_clean(cfg="cfail6")]
93 enum EnumChangeNameStructStyleVariant {
95 Variant2Changed { a: u32, b: f32 },
100 // Change the value of a c-style variant --------------------------------------
101 #[cfg(any(cfail1,cfail4))]
102 enum EnumChangeValueCStyleVariant0 {
107 #[cfg(not(any(cfail1,cfail4)))]
108 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
109 #[rustc_clean(cfg="cfail3")]
110 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
111 #[rustc_clean(cfg="cfail6")]
112 enum EnumChangeValueCStyleVariant0 {
117 #[cfg(any(cfail1,cfail4))]
118 enum EnumChangeValueCStyleVariant1 {
123 #[cfg(not(any(cfail1,cfail4)))]
124 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
125 #[rustc_clean(cfg="cfail3")]
126 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
127 #[rustc_clean(cfg="cfail6")]
128 enum EnumChangeValueCStyleVariant1 {
135 // Add a c-style variant ------------------------------------------------------
136 #[cfg(any(cfail1,cfail4))]
137 enum EnumAddCStyleVariant {
141 #[cfg(not(any(cfail1,cfail4)))]
142 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
143 #[rustc_clean(cfg="cfail3")]
144 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
145 #[rustc_clean(cfg="cfail6")]
146 enum EnumAddCStyleVariant {
153 // Remove a c-style variant ---------------------------------------------------
154 #[cfg(any(cfail1,cfail4))]
155 enum EnumRemoveCStyleVariant {
160 #[cfg(not(any(cfail1,cfail4)))]
161 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
162 #[rustc_clean(cfg="cfail3")]
163 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
164 #[rustc_clean(cfg="cfail6")]
165 enum EnumRemoveCStyleVariant {
171 // Add a tuple-style variant --------------------------------------------------
172 #[cfg(any(cfail1,cfail4))]
173 enum EnumAddTupleStyleVariant {
177 #[cfg(not(any(cfail1,cfail4)))]
178 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
179 #[rustc_clean(cfg="cfail3")]
180 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
181 #[rustc_clean(cfg="cfail6")]
182 enum EnumAddTupleStyleVariant {
189 // Remove a tuple-style variant -----------------------------------------------
190 #[cfg(any(cfail1,cfail4))]
191 enum EnumRemoveTupleStyleVariant {
196 #[cfg(not(any(cfail1,cfail4)))]
197 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
198 #[rustc_clean(cfg="cfail3")]
199 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
200 #[rustc_clean(cfg="cfail6")]
201 enum EnumRemoveTupleStyleVariant {
207 // Add a struct-style variant -------------------------------------------------
208 #[cfg(any(cfail1,cfail4))]
209 enum EnumAddStructStyleVariant {
213 #[cfg(not(any(cfail1,cfail4)))]
214 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
215 #[rustc_clean(cfg="cfail3")]
216 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
217 #[rustc_clean(cfg="cfail6")]
218 enum EnumAddStructStyleVariant {
220 Variant2 { a: u32, b: f32 },
225 // Remove a struct-style variant ----------------------------------------------
226 #[cfg(any(cfail1,cfail4))]
227 enum EnumRemoveStructStyleVariant {
229 Variant2 { a: u32, b: f32 },
232 #[cfg(not(any(cfail1,cfail4)))]
233 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
234 #[rustc_clean(cfg="cfail3")]
235 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
236 #[rustc_clean(cfg="cfail6")]
237 enum EnumRemoveStructStyleVariant {
243 // Change the type of a field in a tuple-style variant ------------------------
244 #[cfg(any(cfail1,cfail4))]
245 enum EnumChangeFieldTypeTupleStyleVariant {
249 #[cfg(not(any(cfail1,cfail4)))]
250 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
251 #[rustc_clean(cfg="cfail3")]
252 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
253 #[rustc_clean(cfg="cfail6")]
254 enum EnumChangeFieldTypeTupleStyleVariant {
261 // Change the type of a field in a struct-style variant -----------------------
262 #[cfg(any(cfail1,cfail4))]
263 enum EnumChangeFieldTypeStructStyleVariant {
265 Variant2 { a: u32, b: u32 },
268 #[cfg(not(any(cfail1,cfail4)))]
269 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
270 #[rustc_clean(cfg="cfail3")]
271 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
272 #[rustc_clean(cfg="cfail6")]
273 enum EnumChangeFieldTypeStructStyleVariant {
283 // Change the name of a field in a struct-style variant -----------------------
284 #[cfg(any(cfail1,cfail4))]
285 enum EnumChangeFieldNameStructStyleVariant {
286 Variant1 { a: u32, b: u32 },
289 #[cfg(not(any(cfail1,cfail4)))]
290 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
291 #[rustc_clean(cfg="cfail3")]
292 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
293 #[rustc_clean(cfg="cfail6")]
294 enum EnumChangeFieldNameStructStyleVariant {
295 Variant1 { a: u32, c: u32 },
300 // Change order of fields in a tuple-style variant ----------------------------
301 #[cfg(any(cfail1,cfail4))]
302 enum EnumChangeOrderTupleStyleVariant {
306 #[cfg(not(any(cfail1,cfail4)))]
307 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
308 #[rustc_clean(cfg="cfail3")]
309 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
310 #[rustc_clean(cfg="cfail6")]
311 enum EnumChangeOrderTupleStyleVariant {
319 // Change order of fields in a struct-style variant ---------------------------
320 #[cfg(any(cfail1,cfail4))]
321 enum EnumChangeFieldOrderStructStyleVariant {
322 Variant1 { a: u32, b: f32 },
325 #[cfg(not(any(cfail1,cfail4)))]
326 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
327 #[rustc_clean(cfg="cfail3")]
328 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
329 #[rustc_clean(cfg="cfail6")]
330 enum EnumChangeFieldOrderStructStyleVariant {
331 Variant1 { b: f32, a: u32 },
336 // Add a field to a tuple-style variant ---------------------------------------
337 #[cfg(any(cfail1,cfail4))]
338 enum EnumAddFieldTupleStyleVariant {
342 #[cfg(not(any(cfail1,cfail4)))]
343 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
344 #[rustc_clean(cfg="cfail3")]
345 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
346 #[rustc_clean(cfg="cfail6")]
347 enum EnumAddFieldTupleStyleVariant {
348 Variant1(u32, u32, u32),
353 // Add a field to a struct-style variant --------------------------------------
354 #[cfg(any(cfail1,cfail4))]
355 enum EnumAddFieldStructStyleVariant {
356 Variant1 { a: u32, b: u32 },
359 #[cfg(not(any(cfail1,cfail4)))]
360 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
361 #[rustc_clean(cfg="cfail3")]
362 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
363 #[rustc_clean(cfg="cfail6")]
364 enum EnumAddFieldStructStyleVariant {
365 Variant1 { a: u32, b: u32, c: u32 },
370 // Add #[must_use] to the enum ------------------------------------------------
371 #[cfg(any(cfail1,cfail4))]
372 enum EnumAddMustUse {
377 #[cfg(not(any(cfail1,cfail4)))]
378 #[rustc_clean(cfg="cfail2")]
379 #[rustc_clean(cfg="cfail3")]
380 #[rustc_clean(cfg="cfail5")]
381 #[rustc_clean(cfg="cfail6")]
383 enum EnumAddMustUse {
390 // Add #[repr(C)] to the enum -------------------------------------------------
391 #[cfg(any(cfail1,cfail4))]
397 #[cfg(not(any(cfail1,cfail4)))]
398 #[rustc_clean(cfg="cfail2", except="type_of")]
399 #[rustc_clean(cfg="cfail3")]
400 #[rustc_clean(cfg="cfail5", except="type_of")]
401 #[rustc_clean(cfg="cfail6")]
410 // Change the name of a type parameter ----------------------------------------
411 #[cfg(any(cfail1,cfail4))]
412 enum EnumChangeNameOfTypeParameter<S> {
416 #[cfg(not(any(cfail1,cfail4)))]
417 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
418 #[rustc_clean(cfg="cfail3")]
419 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
420 #[rustc_clean(cfg="cfail6")]
421 enum EnumChangeNameOfTypeParameter<T> {
427 // Add a type parameter ------------------------------------------------------
428 #[cfg(any(cfail1,cfail4))]
429 enum EnumAddTypeParameter<S> {
434 #[cfg(not(any(cfail1,cfail4)))]
435 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
436 #[rustc_clean(cfg="cfail3")]
437 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
438 #[rustc_clean(cfg="cfail6")]
439 enum EnumAddTypeParameter<S, T> {
446 // Change the name of a lifetime parameter ------------------------------------
447 #[cfg(any(cfail1,cfail4))]
448 enum EnumChangeNameOfLifetimeParameter<'a> {
452 #[cfg(not(any(cfail1,cfail4)))]
453 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
454 #[rustc_clean(cfg="cfail3")]
455 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
456 #[rustc_clean(cfg="cfail6")]
457 enum EnumChangeNameOfLifetimeParameter<'b> {
463 // Add a lifetime parameter ---------------------------------------------------
464 #[cfg(any(cfail1,cfail4))]
465 enum EnumAddLifetimeParameter<'a> {
470 #[cfg(not(any(cfail1,cfail4)))]
471 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
472 #[rustc_clean(cfg="cfail3")]
473 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
474 #[rustc_clean(cfg="cfail6")]
475 enum EnumAddLifetimeParameter<'a, 'b> {
482 // Add a lifetime bound to a lifetime parameter -------------------------------
483 #[cfg(any(cfail1,cfail4))]
484 enum EnumAddLifetimeParameterBound<'a, 'b> {
489 #[cfg(not(any(cfail1,cfail4)))]
490 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
491 #[rustc_clean(cfg="cfail3")]
492 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
493 #[rustc_clean(cfg="cfail6")]
494 enum EnumAddLifetimeParameterBound<'a, 'b: 'a> {
499 // Add a lifetime bound to a type parameter -----------------------------------
500 #[cfg(any(cfail1,cfail4))]
501 enum EnumAddLifetimeBoundToParameter<'a, T> {
506 #[cfg(not(any(cfail1,cfail4)))]
507 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
508 #[rustc_clean(cfg="cfail3")]
509 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
510 #[rustc_clean(cfg="cfail6")]
511 enum EnumAddLifetimeBoundToParameter<'a, T: 'a> {
518 // Add a trait bound to a type parameter --------------------------------------
519 #[cfg(any(cfail1,cfail4))]
520 enum EnumAddTraitBound<S> {
524 #[cfg(not(any(cfail1,cfail4)))]
525 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
526 #[rustc_clean(cfg="cfail3")]
527 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
528 #[rustc_clean(cfg="cfail6")]
529 enum EnumAddTraitBound<T: Sync> {
535 // Add a lifetime bound to a lifetime parameter in where clause ---------------
536 #[cfg(any(cfail1,cfail4))]
537 enum EnumAddLifetimeParameterBoundWhere<'a, 'b> {
542 #[cfg(not(any(cfail1,cfail4)))]
543 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
544 #[rustc_clean(cfg="cfail3")]
545 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
546 #[rustc_clean(cfg="cfail6")]
547 enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a {
554 // Add a lifetime bound to a type parameter in where clause -------------------
555 #[cfg(any(cfail1,cfail4))]
556 enum EnumAddLifetimeBoundToParameterWhere<'a, T> {
561 #[cfg(not(any(cfail1,cfail4)))]
562 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
563 #[rustc_clean(cfg="cfail3")]
564 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
565 #[rustc_clean(cfg="cfail6")]
566 enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a {
573 // Add a trait bound to a type parameter in where clause ----------------------
574 #[cfg(any(cfail1,cfail4))]
575 enum EnumAddTraitBoundWhere<S> {
579 #[cfg(not(any(cfail1,cfail4)))]
580 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
581 #[rustc_clean(cfg="cfail3")]
582 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
583 #[rustc_clean(cfg="cfail6")]
584 enum EnumAddTraitBoundWhere<T> where T: Sync {
590 // In an enum with two variants, swap usage of type parameters ----------------
591 #[cfg(any(cfail1,cfail4))]
592 enum EnumSwapUsageTypeParameters<A, B> {
597 #[cfg(not(any(cfail1,cfail4)))]
598 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
599 #[rustc_clean(cfg="cfail3")]
600 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
601 #[rustc_clean(cfg="cfail6")]
602 enum EnumSwapUsageTypeParameters<A, B> {
613 // In an enum with two variants, swap usage of lifetime parameters ------------
614 #[cfg(any(cfail1,cfail4))]
615 enum EnumSwapUsageLifetimeParameters<'a, 'b> {
616 Variant1 { a: &'a u32 },
617 Variant2 { b: &'b u32 },
620 #[cfg(not(any(cfail1,cfail4)))]
621 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
622 #[rustc_clean(cfg="cfail3")]
623 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
624 #[rustc_clean(cfg="cfail6")]
625 enum EnumSwapUsageLifetimeParameters<'a, 'b> {
636 struct ReferencedType1;
637 struct ReferencedType2;
641 // Change field type in tuple-style variant indirectly by modifying a use statement
642 mod change_field_type_indirectly_tuple_style {
643 #[cfg(any(cfail1,cfail4))]
644 use super::ReferencedType1 as FieldType;
645 #[cfg(not(any(cfail1,cfail4)))]
646 use super::ReferencedType2 as FieldType;
648 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
649 #[rustc_clean(cfg="cfail3")]
650 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
651 #[rustc_clean(cfg="cfail6")]
661 // Change field type in record-style variant indirectly by modifying a use statement
662 mod change_field_type_indirectly_struct_style {
663 #[cfg(any(cfail1,cfail4))]
664 use super::ReferencedType1 as FieldType;
665 #[cfg(not(any(cfail1,cfail4)))]
666 use super::ReferencedType2 as FieldType;
668 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
669 #[rustc_clean(cfg="cfail3")]
670 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
671 #[rustc_clean(cfg="cfail6")]
681 trait ReferencedTrait1 {}
682 trait ReferencedTrait2 {}
686 // Change trait bound of type parameter indirectly by modifying a use statement
687 mod change_trait_bound_indirectly {
688 #[cfg(any(cfail1,cfail4))]
689 use super::ReferencedTrait1 as Trait;
690 #[cfg(not(any(cfail1,cfail4)))]
691 use super::ReferencedTrait2 as Trait;
693 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
694 #[rustc_clean(cfg="cfail3")]
695 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
696 #[rustc_clean(cfg="cfail6")]
697 enum Enum<T: Trait> {
704 // Change trait bound of type parameter in where clause indirectly by modifying a use statement
705 mod change_trait_bound_indirectly_where {
706 #[cfg(any(cfail1,cfail4))]
707 use super::ReferencedTrait1 as Trait;
708 #[cfg(not(any(cfail1,cfail4)))]
709 use super::ReferencedTrait2 as Trait;
711 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
712 #[rustc_clean(cfg="cfail3")]
713 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
714 #[rustc_clean(cfg="cfail6")]
715 enum Enum<T> where T: Trait {