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 constructor expressions.
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 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
24 #![feature(rustc_attrs)]
28 struct RegularStruct {
34 // Change field value (regular struct) -----------------------------------------
36 fn change_field_value_regular_struct() -> RegularStruct {
45 #[rustc_clean(label="Hir", cfg="cfail2")]
46 #[rustc_clean(label="Hir", cfg="cfail3")]
47 #[rustc_dirty(label="HirBody", cfg="cfail2")]
48 #[rustc_clean(label="HirBody", cfg="cfail3")]
49 #[rustc_metadata_clean(cfg="cfail2")]
50 #[rustc_metadata_clean(cfg="cfail3")]
51 fn change_field_value_regular_struct() -> RegularStruct {
61 // Change field order (regular struct) -----------------------------------------
63 fn change_field_order_regular_struct() -> RegularStruct {
72 #[rustc_clean(label="Hir", cfg="cfail2")]
73 #[rustc_clean(label="Hir", cfg="cfail3")]
74 #[rustc_dirty(label="HirBody", cfg="cfail2")]
75 #[rustc_clean(label="HirBody", cfg="cfail3")]
76 #[rustc_metadata_clean(cfg="cfail2")]
77 #[rustc_metadata_clean(cfg="cfail3")]
78 fn change_field_order_regular_struct() -> RegularStruct {
88 // Add field (regular struct) --------------------------------------------------
90 fn add_field_regular_struct() -> RegularStruct {
91 let struct1 = RegularStruct {
104 #[rustc_clean(label="Hir", cfg="cfail2")]
105 #[rustc_clean(label="Hir", cfg="cfail3")]
106 #[rustc_dirty(label="HirBody", cfg="cfail2")]
107 #[rustc_clean(label="HirBody", cfg="cfail3")]
108 #[rustc_metadata_clean(cfg="cfail2")]
109 #[rustc_metadata_clean(cfg="cfail3")]
110 fn add_field_regular_struct() -> RegularStruct {
111 let struct1 = RegularStruct {
126 // Change field label (regular struct) -----------------------------------------
128 fn change_field_label_regular_struct() -> RegularStruct {
129 let struct1 = RegularStruct {
143 #[rustc_clean(label="Hir", cfg="cfail2")]
144 #[rustc_clean(label="Hir", cfg="cfail3")]
145 #[rustc_dirty(label="HirBody", cfg="cfail2")]
146 #[rustc_clean(label="HirBody", cfg="cfail3")]
147 #[rustc_metadata_clean(cfg="cfail2")]
148 #[rustc_metadata_clean(cfg="cfail3")]
149 fn change_field_label_regular_struct() -> RegularStruct {
150 let struct1 = RegularStruct {
165 struct RegularStruct2 {
171 // Change constructor path (regular struct) ------------------------------------
173 fn change_constructor_path_regular_struct() {
174 let _ = RegularStruct {
182 #[rustc_clean(label="Hir", cfg="cfail2")]
183 #[rustc_clean(label="Hir", cfg="cfail3")]
184 #[rustc_dirty(label="HirBody", cfg="cfail2")]
185 #[rustc_clean(label="HirBody", cfg="cfail3")]
186 #[rustc_metadata_clean(cfg="cfail2")]
187 #[rustc_metadata_clean(cfg="cfail3")]
188 fn change_constructor_path_regular_struct() {
189 let _ = RegularStruct2 {
198 // Change constructor path indirectly (regular struct) -------------------------
199 mod change_constructor_path_indirectly_regular_struct {
201 use super::RegularStruct as Struct;
203 use super::RegularStruct2 as Struct;
205 #[rustc_dirty(label="Hir", cfg="cfail2")]
206 #[rustc_clean(label="Hir", cfg="cfail3")]
207 #[rustc_dirty(label="HirBody", cfg="cfail2")]
208 #[rustc_clean(label="HirBody", cfg="cfail3")]
209 #[rustc_metadata_dirty(cfg="cfail2")]
210 #[rustc_metadata_clean(cfg="cfail3")]
211 fn function() -> Struct {
222 struct TupleStruct(i32, i64, i16);
224 // Change field value (tuple struct) -------------------------------------------
226 fn change_field_value_tuple_struct() -> TupleStruct {
231 #[rustc_clean(label="Hir", cfg="cfail2")]
232 #[rustc_clean(label="Hir", cfg="cfail3")]
233 #[rustc_dirty(label="HirBody", cfg="cfail2")]
234 #[rustc_clean(label="HirBody", cfg="cfail3")]
235 #[rustc_metadata_clean(cfg="cfail2")]
236 #[rustc_metadata_clean(cfg="cfail3")]
237 fn change_field_value_tuple_struct() -> TupleStruct {
243 struct TupleStruct2(u16, u16, u16);
245 // Change constructor path (tuple struct) --------------------------------------
247 fn change_constructor_path_tuple_struct() {
248 let _ = TupleStruct(0, 1, 2);
252 #[rustc_clean(label="Hir", cfg="cfail2")]
253 #[rustc_clean(label="Hir", cfg="cfail3")]
254 #[rustc_dirty(label="HirBody", cfg="cfail2")]
255 #[rustc_clean(label="HirBody", cfg="cfail3")]
256 #[rustc_metadata_clean(cfg="cfail2")]
257 #[rustc_metadata_clean(cfg="cfail3")]
258 fn change_constructor_path_tuple_struct() {
259 let _ = TupleStruct2(0, 1, 2);
264 // Change constructor path indirectly (tuple struct) ---------------------------
265 mod change_constructor_path_indirectly_tuple_struct {
267 use super::TupleStruct as Struct;
269 use super::TupleStruct2 as Struct;
271 #[rustc_dirty(label="Hir", cfg="cfail2")]
272 #[rustc_clean(label="Hir", cfg="cfail3")]
273 #[rustc_dirty(label="HirBody", cfg="cfail2")]
274 #[rustc_clean(label="HirBody", cfg="cfail3")]
275 #[rustc_metadata_dirty(cfg="cfail2")]
276 #[rustc_metadata_clean(cfg="cfail3")]
277 fn function() -> Struct {