]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/struct_defs.rs
Rollup merge of #41087 - estebank:tuple-float-index, r=arielb1
[rust.git] / src / test / incremental / hashes / struct_defs.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for struct definitions.
14
15 // The general pattern followed here is: Change one thing between rev1 and rev2
16 // and make sure that the hash has changed, then change nothing between rev2 and
17 // rev3 and make sure that the hash has not changed.
18
19 // We also test the ICH for struct definitions exported in metadata. Same as
20 // above, we want to make sure that the change between rev1 and rev2 also
21 // results in a change of the ICH for the struct's metadata, and that it stays
22 // the same between rev2 and rev3.
23
24 // must-compile-successfully
25 // revisions: cfail1 cfail2 cfail3
26 // compile-flags: -Z query-dep-graph
27
28
29 #![allow(warnings)]
30 #![feature(rustc_attrs)]
31 #![crate_type="rlib"]
32
33 // Layout ----------------------------------------------------------------------
34 #[cfg(cfail1)]
35 pub struct LayoutPacked;
36
37 #[cfg(not(cfail1))]
38 #[rustc_dirty(label="Hir", cfg="cfail2")]
39 #[rustc_clean(label="Hir", cfg="cfail3")]
40 #[rustc_metadata_dirty(cfg="cfail2")]
41 #[rustc_metadata_clean(cfg="cfail3")]
42 #[repr(packed)]
43 pub struct LayoutPacked;
44
45 #[cfg(cfail1)]
46 struct LayoutC;
47
48 #[cfg(not(cfail1))]
49 #[rustc_dirty(label="Hir", cfg="cfail2")]
50 #[rustc_clean(label="Hir", cfg="cfail3")]
51 #[rustc_metadata_dirty(cfg="cfail2")]
52 #[rustc_metadata_clean(cfg="cfail3")]
53 #[repr(C)]
54 struct LayoutC;
55
56
57 // Tuple Struct Change Field Type ----------------------------------------------
58
59 #[cfg(cfail1)]
60 struct TupleStructFieldType(i32);
61
62 #[cfg(not(cfail1))]
63 #[rustc_dirty(label="Hir", cfg="cfail2")]
64 #[rustc_clean(label="Hir", cfg="cfail3")]
65 #[rustc_metadata_dirty(cfg="cfail2")]
66 #[rustc_metadata_clean(cfg="cfail3")]
67 struct TupleStructFieldType(u32);
68
69
70 // Tuple Struct Add Field ------------------------------------------------------
71
72 #[cfg(cfail1)]
73 struct TupleStructAddField(i32);
74
75 #[cfg(not(cfail1))]
76 #[rustc_dirty(label="Hir", cfg="cfail2")]
77 #[rustc_clean(label="Hir", cfg="cfail3")]
78 #[rustc_metadata_dirty(cfg="cfail2")]
79 #[rustc_metadata_clean(cfg="cfail3")]
80 struct TupleStructAddField(i32, u32);
81
82
83 // Tuple Struct Field Visibility -----------------------------------------------
84
85 #[cfg(cfail1)]
86 struct TupleStructFieldVisibility(char);
87
88 #[cfg(not(cfail1))]
89 #[rustc_dirty(label="Hir", cfg="cfail2")]
90 #[rustc_clean(label="Hir", cfg="cfail3")]
91 #[rustc_metadata_dirty(cfg="cfail2")]
92 #[rustc_metadata_clean(cfg="cfail3")]
93 struct TupleStructFieldVisibility(pub char);
94
95
96 // Record Struct Field Type ----------------------------------------------------
97
98 #[cfg(cfail1)]
99 struct RecordStructFieldType { x: f32 }
100
101 #[cfg(not(cfail1))]
102 #[rustc_dirty(label="Hir", cfg="cfail2")]
103 #[rustc_clean(label="Hir", cfg="cfail3")]
104 #[rustc_metadata_dirty(cfg="cfail2")]
105 #[rustc_metadata_clean(cfg="cfail3")]
106 struct RecordStructFieldType { x: u64 }
107
108
109 // Record Struct Field Name ----------------------------------------------------
110
111 #[cfg(cfail1)]
112 struct RecordStructFieldName { x: f32 }
113
114 #[cfg(not(cfail1))]
115 #[rustc_dirty(label="Hir", cfg="cfail2")]
116 #[rustc_clean(label="Hir", cfg="cfail3")]
117 #[rustc_metadata_dirty(cfg="cfail2")]
118 #[rustc_metadata_clean(cfg="cfail3")]
119 struct RecordStructFieldName { y: f32 }
120
121
122 // Record Struct Add Field -----------------------------------------------------
123
124 #[cfg(cfail1)]
125 struct RecordStructAddField { x: f32 }
126
127 #[cfg(not(cfail1))]
128 #[rustc_dirty(label="Hir", cfg="cfail2")]
129 #[rustc_clean(label="Hir", cfg="cfail3")]
130 #[rustc_metadata_dirty(cfg="cfail2")]
131 #[rustc_metadata_clean(cfg="cfail3")]
132 struct RecordStructAddField { x: f32, y: () }
133
134
135 // Record Struct Field Visibility ----------------------------------------------
136
137 #[cfg(cfail1)]
138 struct RecordStructFieldVisibility { x: f32 }
139
140 #[cfg(not(cfail1))]
141 #[rustc_dirty(label="Hir", cfg="cfail2")]
142 #[rustc_clean(label="Hir", cfg="cfail3")]
143 #[rustc_metadata_dirty(cfg="cfail2")]
144 #[rustc_metadata_clean(cfg="cfail3")]
145 struct RecordStructFieldVisibility { pub x: f32 }
146
147
148 // Add Lifetime Parameter ------------------------------------------------------
149
150 #[cfg(cfail1)]
151 struct AddLifetimeParameter<'a>(&'a f32, &'a f64);
152
153 #[cfg(not(cfail1))]
154 #[rustc_dirty(label="Hir", cfg="cfail2")]
155 #[rustc_clean(label="Hir", cfg="cfail3")]
156 #[rustc_metadata_dirty(cfg="cfail2")]
157 #[rustc_metadata_clean(cfg="cfail3")]
158 struct AddLifetimeParameter<'a, 'b>(&'a f32, &'b f64);
159
160
161 // Add Lifetime Parameter Bound ------------------------------------------------
162
163 #[cfg(cfail1)]
164 struct AddLifetimeParameterBound<'a, 'b>(&'a f32, &'b f64);
165
166 #[cfg(not(cfail1))]
167 #[rustc_dirty(label="Hir", cfg="cfail2")]
168 #[rustc_clean(label="Hir", cfg="cfail3")]
169 #[rustc_metadata_dirty(cfg="cfail2")]
170 #[rustc_metadata_clean(cfg="cfail3")]
171 struct AddLifetimeParameterBound<'a, 'b: 'a>(&'a f32, &'b f64);
172
173 #[cfg(cfail1)]
174 struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64);
175
176 #[cfg(not(cfail1))]
177 #[rustc_dirty(label="Hir", cfg="cfail2")]
178 #[rustc_clean(label="Hir", cfg="cfail3")]
179 #[rustc_metadata_dirty(cfg="cfail2")]
180 #[rustc_metadata_clean(cfg="cfail3")]
181 struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64)
182     where 'b: 'a;
183
184
185 // Add Type Parameter ----------------------------------------------------------
186
187 #[cfg(cfail1)]
188 struct AddTypeParameter<T1>(T1, T1);
189
190 #[cfg(not(cfail1))]
191 #[rustc_dirty(label="Hir", cfg="cfail2")]
192 #[rustc_clean(label="Hir", cfg="cfail3")]
193 #[rustc_metadata_dirty(cfg="cfail2")]
194 #[rustc_metadata_clean(cfg="cfail3")]
195 struct AddTypeParameter<T1, T2>(T1, T2);
196
197
198 // Add Type Parameter Bound ----------------------------------------------------
199
200 #[cfg(cfail1)]
201 struct AddTypeParameterBound<T>(T);
202
203 #[cfg(not(cfail1))]
204 #[rustc_dirty(label="Hir", cfg="cfail2")]
205 #[rustc_clean(label="Hir", cfg="cfail3")]
206 #[rustc_metadata_dirty(cfg="cfail2")]
207 #[rustc_metadata_clean(cfg="cfail3")]
208 struct AddTypeParameterBound<T: Send>(T);
209
210
211 #[cfg(cfail1)]
212 struct AddTypeParameterBoundWhereClause<T>(T);
213
214 #[cfg(not(cfail1))]
215 #[rustc_dirty(label="Hir", cfg="cfail2")]
216 #[rustc_clean(label="Hir", cfg="cfail3")]
217 #[rustc_metadata_dirty(cfg="cfail2")]
218 #[rustc_metadata_clean(cfg="cfail3")]
219 struct AddTypeParameterBoundWhereClause<T>(T) where T: Sync;
220
221
222 // Empty struct ----------------------------------------------------------------
223
224 #[rustc_clean(label="Hir", cfg="cfail2")]
225 #[rustc_metadata_clean(cfg="cfail2")]
226 pub struct EmptyStruct;
227
228
229 // Visibility ------------------------------------------------------------------
230
231 #[cfg(cfail1)]
232 struct Visibility;
233
234 #[cfg(not(cfail1))]
235 #[rustc_dirty(label="Hir", cfg="cfail2")]
236 #[rustc_clean(label="Hir", cfg="cfail3")]
237 #[rustc_metadata_clean(cfg="cfail3")]
238 pub struct Visibility;
239
240
241
242
243 struct ReferencedType1;
244 struct ReferencedType2;
245
246 // Tuple Struct Change Field Type Indirectly -----------------------------------
247 mod tuple_struct_change_field_type_indirectly {
248     #[cfg(cfail1)]
249     use super::ReferencedType1 as FieldType;
250     #[cfg(not(cfail1))]
251     use super::ReferencedType2 as FieldType;
252
253     #[rustc_dirty(label="Hir", cfg="cfail2")]
254     #[rustc_clean(label="Hir", cfg="cfail3")]
255     #[rustc_metadata_dirty(cfg="cfail2")]
256     #[rustc_metadata_clean(cfg="cfail3")]
257     struct TupleStruct(FieldType);
258 }
259
260
261 // Record Struct Change Field Type Indirectly -----------------------------------
262 mod record_struct_change_field_type_indirectly {
263     #[cfg(cfail1)]
264     use super::ReferencedType1 as FieldType;
265     #[cfg(not(cfail1))]
266     use super::ReferencedType2 as FieldType;
267
268     #[rustc_dirty(label="Hir", cfg="cfail2")]
269     #[rustc_clean(label="Hir", cfg="cfail3")]
270     #[rustc_metadata_dirty(cfg="cfail2")]
271     #[rustc_metadata_clean(cfg="cfail3")]
272     struct RecordStruct {
273         _x: FieldType
274     }
275 }
276
277
278
279
280 trait ReferencedTrait1 {}
281 trait ReferencedTrait2 {}
282
283 // Change Trait Bound Indirectly -----------------------------------------------
284 mod change_trait_bound_indirectly {
285     #[cfg(cfail1)]
286     use super::ReferencedTrait1 as Trait;
287     #[cfg(not(cfail1))]
288     use super::ReferencedTrait2 as Trait;
289
290     #[rustc_dirty(label="Hir", cfg="cfail2")]
291     #[rustc_clean(label="Hir", cfg="cfail3")]
292     #[rustc_metadata_dirty(cfg="cfail2")]
293     #[rustc_metadata_clean(cfg="cfail3")]
294     struct Struct<T: Trait>(T);
295 }
296
297 // Change Trait Bound Indirectly In Where Clause -------------------------------
298 mod change_trait_bound_indirectly_in_where_clause {
299     #[cfg(cfail1)]
300     use super::ReferencedTrait1 as Trait;
301     #[cfg(not(cfail1))]
302     use super::ReferencedTrait2 as Trait;
303
304     #[rustc_dirty(label="Hir", cfg="cfail2")]
305     #[rustc_clean(label="Hir", cfg="cfail3")]
306     #[rustc_metadata_dirty(cfg="cfail2")]
307     #[rustc_metadata_clean(cfg="cfail3")]
308     struct Struct<T>(T) where T : Trait;
309 }