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 fn function() -> Struct {
216 struct TupleStruct(i32, i64, i16);
218 // Change field value (tuple struct) -------------------------------------------
220 fn change_field_value_tuple_struct() -> TupleStruct {
225 #[rustc_clean(label="Hir", cfg="cfail2")]
226 #[rustc_clean(label="Hir", cfg="cfail3")]
227 #[rustc_dirty(label="HirBody", cfg="cfail2")]
228 #[rustc_clean(label="HirBody", cfg="cfail3")]
229 #[rustc_metadata_clean(cfg="cfail2")]
230 #[rustc_metadata_clean(cfg="cfail3")]
231 fn change_field_value_tuple_struct() -> TupleStruct {
237 struct TupleStruct2(u16, u16, u16);
239 // Change constructor path (tuple struct) --------------------------------------
241 fn change_constructor_path_tuple_struct() {
242 let _ = TupleStruct(0, 1, 2);
246 #[rustc_clean(label="Hir", cfg="cfail2")]
247 #[rustc_clean(label="Hir", cfg="cfail3")]
248 #[rustc_dirty(label="HirBody", cfg="cfail2")]
249 #[rustc_clean(label="HirBody", cfg="cfail3")]
250 #[rustc_metadata_clean(cfg="cfail2")]
251 #[rustc_metadata_clean(cfg="cfail3")]
252 fn change_constructor_path_tuple_struct() {
253 let _ = TupleStruct2(0, 1, 2);
258 // Change constructor path indirectly (tuple struct) ---------------------------
259 mod change_constructor_path_indirectly_tuple_struct {
261 use super::TupleStruct as Struct;
263 use super::TupleStruct2 as Struct;
265 fn function() -> Struct {