1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for `type` 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 `type` 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 -O
18 #![feature(rustc_attrs)]
22 // Change type (primitive) -----------------------------------------------------
24 type ChangePrimitiveType = i32;
27 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
28 #[rustc_clean(cfg="cfail3")]
29 type ChangePrimitiveType = i64;
33 // Change mutability -----------------------------------------------------------
35 type ChangeMutability = &'static i32;
38 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
39 #[rustc_clean(cfg="cfail3")]
40 type ChangeMutability = &'static mut i32;
44 // Change mutability -----------------------------------------------------------
46 type ChangeLifetime<'a> = (&'static i32, &'a i32);
49 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
50 #[rustc_clean(cfg="cfail3")]
51 type ChangeLifetime<'a> = (&'a i32, &'a i32);
55 // Change type (struct) -----------------------------------------------------------
60 type ChangeTypeStruct = Struct1;
63 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
64 #[rustc_clean(cfg="cfail3")]
65 type ChangeTypeStruct = Struct2;
69 // Change type (tuple) ---------------------------------------------------------
71 type ChangeTypeTuple = (u32, u64);
74 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
75 #[rustc_clean(cfg="cfail3")]
76 type ChangeTypeTuple = (u32, i64);
80 // Change type (enum) ----------------------------------------------------------
91 type ChangeTypeEnum = Enum1;
94 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
95 #[rustc_clean(cfg="cfail3")]
96 type ChangeTypeEnum = Enum2;
100 // Add tuple field -------------------------------------------------------------
102 type AddTupleField = (i32, i64);
105 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
106 #[rustc_clean(cfg="cfail3")]
107 type AddTupleField = (i32, i64, i16);
111 // Change nested tuple field ---------------------------------------------------
113 type ChangeNestedTupleField = (i32, (i64, i16));
116 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
117 #[rustc_clean(cfg="cfail3")]
118 type ChangeNestedTupleField = (i32, (i64, i8));
122 // Add type param --------------------------------------------------------------
124 type AddTypeParam<T1> = (T1, T1);
127 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
128 #[rustc_clean(cfg="cfail3")]
129 type AddTypeParam<T1, T2> = (T1, T2);
133 // Add type param bound --------------------------------------------------------
135 type AddTypeParamBound<T1> = (T1, u32);
138 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
139 #[rustc_clean(cfg="cfail3")]
140 type AddTypeParamBound<T1: Clone> = (T1, u32);
144 // Add type param bound in where clause ----------------------------------------
146 type AddTypeParamBoundWhereClause<T1> where T1: Clone = (T1, u32);
149 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
150 #[rustc_clean(cfg="cfail3")]
151 type AddTypeParamBoundWhereClause<T1> where T1: Clone+Copy = (T1, u32);
155 // Add lifetime param ----------------------------------------------------------
157 type AddLifetimeParam<'a> = (&'a u32, &'a u32);
160 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
161 #[rustc_clean(cfg="cfail3")]
162 type AddLifetimeParam<'a, 'b> = (&'a u32, &'b u32);
166 // Add lifetime param bound ----------------------------------------------------
168 type AddLifetimeParamBound<'a, 'b> = (&'a u32, &'b u32);
171 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
172 #[rustc_clean(cfg="cfail3")]
173 type AddLifetimeParamBound<'a, 'b: 'a> = (&'a u32, &'b u32);
177 // Add lifetime param bound in where clause ------------------------------------
179 type AddLifetimeParamBoundWhereClause<'a, 'b, 'c>
181 = (&'a u32, &'b u32, &'c u32);
184 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
185 #[rustc_clean(cfg="cfail3")]
186 type AddLifetimeParamBoundWhereClause<'a, 'b, 'c>
189 = (&'a u32, &'b u32, &'c u32);
193 // Change Trait Bound Indirectly -----------------------------------------------
194 trait ReferencedTrait1 {}
195 trait ReferencedTrait2 {}
197 mod change_trait_bound_indirectly {
199 use super::ReferencedTrait1 as Trait;
201 use super::ReferencedTrait2 as Trait;
203 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
204 #[rustc_clean(cfg="cfail3")]
205 type ChangeTraitBoundIndirectly<T: Trait> = (T, u32);
210 // Change Trait Bound Indirectly In Where Clause -------------------------------
211 mod change_trait_bound_indirectly_in_where_clause {
213 use super::ReferencedTrait1 as Trait;
215 use super::ReferencedTrait2 as Trait;
217 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
218 #[rustc_clean(cfg="cfail3")]
219 type ChangeTraitBoundIndirectly<T> where T : Trait = (T, u32);