1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for struct constructor expressions.
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 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
11 // [cfail1]compile-flags: -Zincremental-ignore-spans
12 // [cfail2]compile-flags: -Zincremental-ignore-spans
13 // [cfail3]compile-flags: -Zincremental-ignore-spans
16 #![feature(rustc_attrs)]
20 pub struct RegularStruct {
26 // Change field value (regular struct)
27 #[cfg(any(cfail1,cfail4))]
28 pub fn change_field_value_regular_struct() -> RegularStruct {
36 #[cfg(not(any(cfail1,cfail4)))]
37 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
38 #[rustc_clean(cfg="cfail3")]
39 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
40 #[rustc_clean(cfg="cfail6")]
41 pub fn change_field_value_regular_struct() -> RegularStruct {
51 // Change field order (regular struct)
52 #[cfg(any(cfail1,cfail4))]
53 pub fn change_field_order_regular_struct() -> RegularStruct {
61 #[cfg(not(any(cfail1,cfail4)))]
62 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
63 #[rustc_clean(cfg="cfail3")]
64 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
65 #[rustc_clean(cfg="cfail6")]
66 pub fn change_field_order_regular_struct() -> RegularStruct {
76 // Add field (regular struct)
77 #[cfg(any(cfail1,cfail4))]
78 pub fn add_field_regular_struct() -> RegularStruct {
79 let struct1 = RegularStruct {
92 #[cfg(not(any(cfail1,cfail4)))]
93 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
94 #[rustc_clean(cfg="cfail3")]
95 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
96 #[rustc_clean(cfg="cfail6")]
97 pub fn add_field_regular_struct() -> RegularStruct {
98 let struct1 = RegularStruct {
113 // Change field label (regular struct)
114 #[cfg(any(cfail1,cfail4))]
115 pub fn change_field_label_regular_struct() -> RegularStruct {
116 let struct1 = RegularStruct {
129 #[cfg(not(any(cfail1,cfail4)))]
130 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
131 #[rustc_clean(cfg="cfail3")]
132 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
133 #[rustc_clean(cfg="cfail6")]
134 pub fn change_field_label_regular_struct() -> RegularStruct {
135 let struct1 = RegularStruct {
150 pub struct RegularStruct2 {
156 // Change constructor path (regular struct)
157 #[cfg(any(cfail1,cfail4))]
158 pub fn change_constructor_path_regular_struct() {
159 let _ = RegularStruct {
166 #[cfg(not(any(cfail1,cfail4)))]
167 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
168 #[rustc_clean(cfg="cfail3")]
169 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
170 #[rustc_clean(cfg="cfail6")]
171 pub fn change_constructor_path_regular_struct() {
172 let _ = RegularStruct2 {
181 // Change constructor path indirectly (regular struct)
182 pub mod change_constructor_path_indirectly_regular_struct {
183 #[cfg(any(cfail1,cfail4))]
184 use super::RegularStruct as Struct;
185 #[cfg(not(any(cfail1,cfail4)))]
186 use super::RegularStruct2 as Struct;
190 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
192 #[rustc_clean(cfg="cfail3")]
195 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
197 #[rustc_clean(cfg="cfail6")]
198 pub fn function() -> Struct {
209 pub struct TupleStruct(i32, i64, i16);
211 // Change field value (tuple struct)
212 #[cfg(any(cfail1,cfail4))]
213 pub fn change_field_value_tuple_struct() -> TupleStruct {
217 #[cfg(not(any(cfail1,cfail4)))]
218 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
219 #[rustc_clean(cfg="cfail3")]
220 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
221 #[rustc_clean(cfg="cfail6")]
222 pub fn change_field_value_tuple_struct() -> TupleStruct {
228 pub struct TupleStruct2(u16, u16, u16);
230 // Change constructor path (tuple struct)
231 #[cfg(any(cfail1,cfail4))]
232 pub fn change_constructor_path_tuple_struct() {
233 let _ = TupleStruct (0, 1, 2);
236 #[cfg(not(any(cfail1,cfail4)))]
237 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
238 #[rustc_clean(cfg="cfail3")]
239 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
240 #[rustc_clean(cfg="cfail6")]
241 pub fn change_constructor_path_tuple_struct() {
242 let _ = TupleStruct2(0, 1, 2);
247 // Change constructor path indirectly (tuple struct)
248 pub mod change_constructor_path_indirectly_tuple_struct {
249 #[cfg(any(cfail1,cfail4))]
250 use super::TupleStruct as Struct;
251 #[cfg(not(any(cfail1,cfail4)))]
252 use super::TupleStruct2 as Struct;
256 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
258 #[rustc_clean(cfg="cfail6")]
261 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
263 #[rustc_clean(cfg="cfail3")]
264 pub fn function() -> Struct {