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
14 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
19 #![feature(rustc_attrs)]
23 pub struct RegularStruct {
29 // Change field value (regular struct)
30 #[cfg(any(cfail1,cfail4))]
31 pub fn change_field_value_regular_struct() -> RegularStruct {
39 #[cfg(not(any(cfail1,cfail4)))]
40 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
41 #[rustc_clean(cfg="cfail3")]
42 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
43 #[rustc_clean(cfg="cfail6")]
44 pub fn change_field_value_regular_struct() -> RegularStruct {
54 // Change field order (regular struct)
55 #[cfg(any(cfail1,cfail4))]
56 pub fn change_field_order_regular_struct() -> RegularStruct {
64 #[cfg(not(any(cfail1,cfail4)))]
65 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
66 #[rustc_clean(cfg="cfail3")]
67 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
68 #[rustc_clean(cfg="cfail6")]
69 pub fn change_field_order_regular_struct() -> RegularStruct {
79 // Add field (regular struct)
80 #[cfg(any(cfail1,cfail4))]
81 pub fn add_field_regular_struct() -> RegularStruct {
82 let struct1 = RegularStruct {
95 #[cfg(not(any(cfail1,cfail4)))]
96 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
97 #[rustc_clean(cfg="cfail3")]
98 #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
99 #[rustc_clean(cfg="cfail6")]
100 pub fn add_field_regular_struct() -> RegularStruct {
101 let struct1 = RegularStruct {
116 // Change field label (regular struct)
117 #[cfg(any(cfail1,cfail4))]
118 pub fn change_field_label_regular_struct() -> RegularStruct {
119 let struct1 = RegularStruct {
132 #[cfg(not(any(cfail1,cfail4)))]
133 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
134 #[rustc_clean(cfg="cfail3")]
135 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
136 #[rustc_clean(cfg="cfail6")]
137 pub fn change_field_label_regular_struct() -> RegularStruct {
138 let struct1 = RegularStruct {
153 pub struct RegularStruct2 {
159 // Change constructor path (regular struct)
160 #[cfg(any(cfail1,cfail4))]
161 pub fn change_constructor_path_regular_struct() {
162 let _ = RegularStruct {
169 #[cfg(not(any(cfail1,cfail4)))]
170 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
171 #[rustc_clean(cfg="cfail3")]
172 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
173 #[rustc_clean(cfg="cfail6")]
174 pub fn change_constructor_path_regular_struct() {
175 let _ = RegularStruct2 {
184 // Change constructor path indirectly (regular struct)
185 pub mod change_constructor_path_indirectly_regular_struct {
186 #[cfg(any(cfail1,cfail4))]
187 use super::RegularStruct as Struct;
188 #[cfg(not(any(cfail1,cfail4)))]
189 use super::RegularStruct2 as Struct;
193 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
195 #[rustc_clean(cfg="cfail3")]
198 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
200 #[rustc_clean(cfg="cfail6")]
201 pub fn function() -> Struct {
212 pub struct TupleStruct(i32, i64, i16);
214 // Change field value (tuple struct)
215 #[cfg(any(cfail1,cfail4))]
216 pub fn change_field_value_tuple_struct() -> TupleStruct {
220 #[cfg(not(any(cfail1,cfail4)))]
221 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
222 #[rustc_clean(cfg="cfail3")]
223 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
224 #[rustc_clean(cfg="cfail6")]
225 pub fn change_field_value_tuple_struct() -> TupleStruct {
231 pub struct TupleStruct2(u16, u16, u16);
233 // Change constructor path (tuple struct)
234 #[cfg(any(cfail1,cfail4))]
235 pub fn change_constructor_path_tuple_struct() {
236 let _ = TupleStruct (0, 1, 2);
239 #[cfg(not(any(cfail1,cfail4)))]
240 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
241 #[rustc_clean(cfg="cfail3")]
242 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
243 #[rustc_clean(cfg="cfail6")]
244 pub fn change_constructor_path_tuple_struct() {
245 let _ = TupleStruct2(0, 1, 2);
250 // Change constructor path indirectly (tuple struct)
251 pub mod change_constructor_path_indirectly_tuple_struct {
252 #[cfg(any(cfail1,cfail4))]
253 use super::TupleStruct as Struct;
254 #[cfg(not(any(cfail1,cfail4)))]
255 use super::TupleStruct2 as Struct;
259 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
261 #[rustc_clean(cfg="cfail6")]
264 except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,typeck"
266 #[rustc_clean(cfg="cfail3")]
267 pub fn function() -> Struct {