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.
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.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for struct definitions.
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.
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.
24 // must-compile-successfully
25 // revisions: cfail1 cfail2 cfail3
26 // compile-flags: -Z query-dep-graph
30 #![feature(rustc_attrs)]
33 // Layout ----------------------------------------------------------------------
35 pub struct LayoutPacked;
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")]
43 pub struct LayoutPacked;
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")]
57 // Tuple Struct Change Field Type ----------------------------------------------
60 struct TupleStructFieldType(i32);
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);
70 // Tuple Struct Add Field ------------------------------------------------------
73 struct TupleStructAddField(i32);
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);
83 // Tuple Struct Field Visibility -----------------------------------------------
86 struct TupleStructFieldVisibility(char);
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);
96 // Record Struct Field Type ----------------------------------------------------
99 struct RecordStructFieldType { x: f32 }
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 }
109 // Record Struct Field Name ----------------------------------------------------
112 struct RecordStructFieldName { x: f32 }
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 }
122 // Record Struct Add Field -----------------------------------------------------
125 struct RecordStructAddField { x: f32 }
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: () }
135 // Record Struct Field Visibility ----------------------------------------------
138 struct RecordStructFieldVisibility { x: f32 }
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 }
148 // Add Lifetime Parameter ------------------------------------------------------
151 struct AddLifetimeParameter<'a>(&'a f32, &'a f64);
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);
161 // Add Lifetime Parameter Bound ------------------------------------------------
164 struct AddLifetimeParameterBound<'a, 'b>(&'a f32, &'b f64);
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);
174 struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64);
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)
185 // Add Type Parameter ----------------------------------------------------------
188 struct AddTypeParameter<T1>(T1, T1);
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);
198 // Add Type Parameter Bound ----------------------------------------------------
201 struct AddTypeParameterBound<T>(T);
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);
212 struct AddTypeParameterBoundWhereClause<T>(T);
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;
222 // Empty struct ----------------------------------------------------------------
224 #[rustc_clean(label="Hir", cfg="cfail2")]
225 #[rustc_metadata_clean(cfg="cfail2")]
226 pub struct EmptyStruct;
229 // Visibility ------------------------------------------------------------------
235 #[rustc_dirty(label="Hir", cfg="cfail2")]
236 #[rustc_clean(label="Hir", cfg="cfail3")]
237 #[rustc_metadata_clean(cfg="cfail3")]
238 pub struct Visibility;
243 struct ReferencedType1;
244 struct ReferencedType2;
246 // Tuple Struct Change Field Type Indirectly -----------------------------------
247 mod tuple_struct_change_field_type_indirectly {
249 use super::ReferencedType1 as FieldType;
251 use super::ReferencedType2 as FieldType;
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);
261 // Record Struct Change Field Type Indirectly -----------------------------------
262 mod record_struct_change_field_type_indirectly {
264 use super::ReferencedType1 as FieldType;
266 use super::ReferencedType2 as FieldType;
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 {
280 trait ReferencedTrait1 {}
281 trait ReferencedTrait2 {}
283 // Change Trait Bound Indirectly -----------------------------------------------
284 mod change_trait_bound_indirectly {
286 use super::ReferencedTrait1 as Trait;
288 use super::ReferencedTrait2 as Trait;
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);
297 // Change Trait Bound Indirectly In Where Clause -------------------------------
298 mod change_trait_bound_indirectly_in_where_clause {
300 use super::ReferencedTrait1 as Trait;
302 use super::ReferencedTrait2 as Trait;
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;