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
15 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
18 #![feature(rustc_attrs)]
19 #![feature(stmt_expr_attributes)]
24 // Change enum visibility -----------------------------------------------------
26 enum EnumVisibility { A }
29 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
30 #[rustc_clean(cfg="cfail3")]
31 pub enum EnumVisibility
{
37 // Change name of a c-style variant -------------------------------------------
39 enum EnumChangeNameCStyleVariant
{
45 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
46 #[rustc_clean(cfg="cfail3")]
47 enum EnumChangeNameCStyleVariant
{
54 // Change name of a tuple-style variant ---------------------------------------
56 enum EnumChangeNameTupleStyleVariant
{
62 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
63 #[rustc_clean(cfg="cfail3")]
64 enum EnumChangeNameTupleStyleVariant
{
66 Variant2Changed(u32, f32),
71 // Change name of a struct-style variant --------------------------------------
73 enum EnumChangeNameStructStyleVariant
{
75 Variant2 { a: u32, b: f32 }
,
79 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
80 #[rustc_clean(cfg="cfail3")]
81 enum EnumChangeNameStructStyleVariant
{
83 Variant2Changed { a: u32, b: f32 }
,
88 // Change the value of a c-style variant --------------------------------------
90 enum EnumChangeValueCStyleVariant0
{
96 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
97 #[rustc_clean(cfg="cfail3")]
98 enum EnumChangeValueCStyleVariant0
{
106 enum EnumChangeValueCStyleVariant1
{
112 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
113 #[rustc_clean(cfg="cfail3")]
114 enum EnumChangeValueCStyleVariant1
{
121 // Add a c-style variant ------------------------------------------------------
123 enum EnumAddCStyleVariant
{
128 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
129 #[rustc_clean(cfg="cfail3")]
130 enum EnumAddCStyleVariant
{
137 // Remove a c-style variant ---------------------------------------------------
139 enum EnumRemoveCStyleVariant
{
145 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
146 #[rustc_clean(cfg="cfail3")]
147 enum EnumRemoveCStyleVariant
{
153 // Add a tuple-style variant --------------------------------------------------
155 enum EnumAddTupleStyleVariant
{
160 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
161 #[rustc_clean(cfg="cfail3")]
162 enum EnumAddTupleStyleVariant
{
169 // Remove a tuple-style variant -----------------------------------------------
171 enum EnumRemoveTupleStyleVariant
{
177 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
178 #[rustc_clean(cfg="cfail3")]
179 enum EnumRemoveTupleStyleVariant
{
185 // Add a struct-style variant -------------------------------------------------
187 enum EnumAddStructStyleVariant
{
192 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
193 #[rustc_clean(cfg="cfail3")]
194 enum EnumAddStructStyleVariant
{
196 Variant2 { a: u32, b: f32 }
,
201 // Remove a struct-style variant ----------------------------------------------
203 enum EnumRemoveStructStyleVariant
{
205 Variant2 { a: u32, b: f32 }
,
209 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
210 #[rustc_clean(cfg="cfail3")]
211 enum EnumRemoveStructStyleVariant
{
217 // Change the type of a field in a tuple-style variant ------------------------
219 enum EnumChangeFieldTypeTupleStyleVariant
{
224 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
225 #[rustc_clean(cfg="cfail3")]
226 enum EnumChangeFieldTypeTupleStyleVariant
{
233 // Change the type of a field in a struct-style variant -----------------------
235 enum EnumChangeFieldTypeStructStyleVariant
{
237 Variant2 { a: u32, b: u32 }
,
241 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
242 #[rustc_clean(cfg="cfail3")]
243 enum EnumChangeFieldTypeStructStyleVariant
{
253 // Change the name of a field in a struct-style variant -----------------------
255 enum EnumChangeFieldNameStructStyleVariant
{
256 Variant1 { a: u32, b: u32 }
,
260 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
261 #[rustc_clean(cfg="cfail3")]
262 enum EnumChangeFieldNameStructStyleVariant
{
263 Variant1 { a: u32, c: u32 }
,
268 // Change order of fields in a tuple-style variant ----------------------------
270 enum EnumChangeOrderTupleStyleVariant
{
275 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
276 #[rustc_clean(cfg="cfail3")]
277 enum EnumChangeOrderTupleStyleVariant
{
285 // Change order of fields in a struct-style variant ---------------------------
287 enum EnumChangeFieldOrderStructStyleVariant
{
288 Variant1 { a: u32, b: f32 }
,
292 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
293 #[rustc_clean(cfg="cfail3")]
294 enum EnumChangeFieldOrderStructStyleVariant
{
295 Variant1 { b: f32, a: u32 }
,
300 // Add a field to a tuple-style variant ---------------------------------------
302 enum EnumAddFieldTupleStyleVariant
{
307 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
308 #[rustc_clean(cfg="cfail3")]
309 enum EnumAddFieldTupleStyleVariant
{
310 Variant1(u32, u32, u32),
315 // Add a field to a struct-style variant --------------------------------------
317 enum EnumAddFieldStructStyleVariant
{
318 Variant1 { a: u32, b: u32 }
,
322 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
323 #[rustc_clean(cfg="cfail3")]
324 enum EnumAddFieldStructStyleVariant
{
325 Variant1 { a: u32, b: u32, c: u32 }
,
330 // Add #[must_use] to the enum ------------------------------------------------
332 enum EnumAddMustUse
{
338 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
339 #[rustc_clean(cfg="cfail3")]
341 enum EnumAddMustUse
{
348 // Add #[repr(C)] to the enum -------------------------------------------------
356 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
357 #[rustc_clean(cfg="cfail3")]
366 // Change the name of a type parameter ----------------------------------------
368 enum EnumChangeNameOfTypeParameter
<S
> {
373 #[rustc_dirty(cfg="cfail2")]
374 #[rustc_clean(cfg="cfail3")]
375 enum EnumChangeNameOfTypeParameter
<T
> {
381 // Add a type parameter ------------------------------------------------------
383 enum EnumAddTypeParameter
<S
> {
389 #[rustc_dirty(cfg="cfail2")]
390 #[rustc_clean(cfg="cfail3")]
391 enum EnumAddTypeParameter
<S
, T
> {
398 // Change the name of a lifetime parameter ------------------------------------
400 enum EnumChangeNameOfLifetimeParameter
<'a
> {
405 #[rustc_dirty(cfg="cfail2", except="predicates_of")]
406 #[rustc_clean(cfg="cfail3")]
407 enum EnumChangeNameOfLifetimeParameter
<'b
> {
413 // Add a lifetime parameter ---------------------------------------------------
415 enum EnumAddLifetimeParameter
<'a
> {
421 #[rustc_dirty(cfg="cfail2", except="predicates_of")]
422 #[rustc_clean(cfg="cfail3")]
423 enum EnumAddLifetimeParameter
<'a
, 'b
> {
430 // Add a lifetime bound to a lifetime parameter -------------------------------
432 enum EnumAddLifetimeParameterBound
<'a
, 'b
> {
438 #[rustc_dirty(cfg="cfail2", except="generics_of,type_of")]
439 #[rustc_clean(cfg="cfail3")]
440 enum EnumAddLifetimeParameterBound
<'a
, 'b
: 'a
> {
445 // Add a lifetime bound to a type parameter -----------------------------------
447 enum EnumAddLifetimeBoundToParameter
<'a
, T
> {
453 #[rustc_dirty(cfg="cfail2", except="type_of")]
454 #[rustc_clean(cfg="cfail3")]
455 enum EnumAddLifetimeBoundToParameter
<'a
, T
: 'a
> {
462 // Add a trait bound to a type parameter --------------------------------------
464 enum EnumAddTraitBound
<S
> {
469 #[rustc_dirty(cfg="cfail2")]
470 #[rustc_clean(cfg="cfail3")]
471 enum EnumAddTraitBound
<T
: Sync
> {
477 // Add a lifetime bound to a lifetime parameter in where clause ---------------
479 enum EnumAddLifetimeParameterBoundWhere
<'a
, 'b
> {
485 #[rustc_dirty(cfg="cfail2", except="generics_of,type_of")]
486 #[rustc_clean(cfg="cfail3")]
487 enum EnumAddLifetimeParameterBoundWhere
<'a
, 'b
> where 'b
: 'a
{
494 // Add a lifetime bound to a type parameter in where clause -------------------
496 enum EnumAddLifetimeBoundToParameterWhere
<'a
, T
> {
502 #[rustc_dirty(cfg="cfail2", except="type_of")]
503 #[rustc_clean(cfg="cfail3")]
504 enum EnumAddLifetimeBoundToParameterWhere
<'a
, T
> where T
: 'a
{
511 // Add a trait bound to a type parameter in where clause ----------------------
513 enum EnumAddTraitBoundWhere
<S
> {
518 #[rustc_dirty(cfg="cfail2")]
519 #[rustc_clean(cfg="cfail3")]
520 enum EnumAddTraitBoundWhere
<T
> where T
: Sync
{
526 // In an enum with two variants, swap usage of type parameters ----------------
528 enum EnumSwapUsageTypeParameters
<A
, B
> {
534 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
535 #[rustc_clean(cfg="cfail3")]
536 enum EnumSwapUsageTypeParameters
<A
, B
> {
547 // In an enum with two variants, swap usage of lifetime parameters ------------
549 enum EnumSwapUsageLifetimeParameters
<'a
, 'b
> {
550 Variant1 { a: &'a u32 }
,
551 Variant2 { b: &'b u32 }
,
555 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
556 #[rustc_clean(cfg="cfail3")]
557 enum EnumSwapUsageLifetimeParameters
<'a
, 'b
> {
568 struct ReferencedType1
;
569 struct ReferencedType2
;
573 // Change field type in tuple-style variant indirectly by modifying a use statement
574 mod change_field_type_indirectly_tuple_style
{
576 use super::ReferencedType1
as FieldType
;
578 use super::ReferencedType2
as FieldType
;
580 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
581 #[rustc_clean(cfg="cfail3")]
591 // Change field type in record-style variant indirectly by modifying a use statement
592 mod change_field_type_indirectly_struct_style
{
594 use super::ReferencedType1
as FieldType
;
596 use super::ReferencedType2
as FieldType
;
598 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
599 #[rustc_clean(cfg="cfail3")]
609 trait ReferencedTrait1 {}
610 trait ReferencedTrait2 {}
614 // Change trait bound of type parameter indirectly by modifying a use statement
615 mod change_trait_bound_indirectly
{
617 use super::ReferencedTrait1
as Trait
;
619 use super::ReferencedTrait2
as Trait
;
621 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
622 #[rustc_clean(cfg="cfail3")]
623 enum Enum
<T
: Trait
> {
630 // Change trait bound of type parameter in where clause indirectly by modifying a use statement
631 mod change_trait_bound_indirectly_where
{
633 use super::ReferencedTrait1
as Trait
;
635 use super::ReferencedTrait2
as Trait
;
637 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
638 #[rustc_clean(cfg="cfail3")]
639 enum Enum
<T
> where T
: Trait
{