]>
Commit | Line | Data |
---|---|---|
476ff2be SL |
1 | // This test case tests the incremental compilation hash (ICH) implementation |
2 | // for struct constructor expressions. | |
3 | ||
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. | |
7 | ||
416331ca | 8 | // build-pass (FIXME(62277): could be check-pass?) |
476ff2be | 9 | // revisions: cfail1 cfail2 cfail3 |
ff7c6d11 | 10 | // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans |
476ff2be SL |
11 | |
12 | #![allow(warnings)] | |
13 | #![feature(rustc_attrs)] | |
14 | #![crate_type="rlib"] | |
15 | ||
16 | ||
abe05a73 | 17 | pub struct RegularStruct { |
476ff2be SL |
18 | x: i32, |
19 | y: i64, | |
20 | z: i16, | |
21 | } | |
22 | ||
e1599b0c | 23 | // Change field value (regular struct) |
476ff2be | 24 | #[cfg(cfail1)] |
abe05a73 | 25 | pub fn change_field_value_regular_struct() -> RegularStruct { |
476ff2be SL |
26 | RegularStruct { |
27 | x: 0, | |
28 | y: 1, | |
29 | z: 2, | |
30 | } | |
31 | } | |
32 | ||
33 | #[cfg(not(cfail1))] | |
ba9703b0 | 34 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built")] |
abe05a73 | 35 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 36 | pub fn change_field_value_regular_struct() -> RegularStruct { |
476ff2be SL |
37 | RegularStruct { |
38 | x: 0, | |
39 | y: 2, | |
40 | z: 2, | |
41 | } | |
42 | } | |
43 | ||
44 | ||
45 | ||
e1599b0c | 46 | // Change field order (regular struct) |
476ff2be | 47 | #[cfg(cfail1)] |
abe05a73 | 48 | pub fn change_field_order_regular_struct() -> RegularStruct { |
476ff2be SL |
49 | RegularStruct { |
50 | x: 3, | |
51 | y: 4, | |
52 | z: 5, | |
53 | } | |
54 | } | |
55 | ||
56 | #[cfg(not(cfail1))] | |
ba9703b0 | 57 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck_tables_of")] |
abe05a73 | 58 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 59 | pub fn change_field_order_regular_struct() -> RegularStruct { |
476ff2be SL |
60 | RegularStruct { |
61 | y: 4, | |
62 | x: 3, | |
63 | z: 5, | |
64 | } | |
65 | } | |
66 | ||
67 | ||
68 | ||
e1599b0c | 69 | // Add field (regular struct) |
476ff2be | 70 | #[cfg(cfail1)] |
abe05a73 | 71 | pub fn add_field_regular_struct() -> RegularStruct { |
476ff2be SL |
72 | let struct1 = RegularStruct { |
73 | x: 3, | |
74 | y: 4, | |
75 | z: 5, | |
76 | }; | |
77 | ||
78 | RegularStruct { | |
79 | x: 7, | |
80 | .. struct1 | |
81 | } | |
82 | } | |
83 | ||
84 | #[cfg(not(cfail1))] | |
ba9703b0 | 85 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built,typeck_tables_of")] |
abe05a73 | 86 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 87 | pub fn add_field_regular_struct() -> RegularStruct { |
476ff2be SL |
88 | let struct1 = RegularStruct { |
89 | x: 3, | |
90 | y: 4, | |
91 | z: 5, | |
92 | }; | |
93 | ||
94 | RegularStruct { | |
95 | x: 7, | |
96 | y: 8, | |
97 | .. struct1 | |
98 | } | |
99 | } | |
100 | ||
101 | ||
102 | ||
e1599b0c | 103 | // Change field label (regular struct) |
476ff2be | 104 | #[cfg(cfail1)] |
abe05a73 | 105 | pub fn change_field_label_regular_struct() -> RegularStruct { |
476ff2be SL |
106 | let struct1 = RegularStruct { |
107 | x: 3, | |
108 | y: 4, | |
109 | z: 5, | |
110 | }; | |
111 | ||
112 | RegularStruct { | |
113 | x: 7, | |
114 | y: 9, | |
115 | .. struct1 | |
116 | } | |
117 | } | |
118 | ||
119 | #[cfg(not(cfail1))] | |
ba9703b0 | 120 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built,typeck_tables_of")] |
abe05a73 | 121 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 122 | pub fn change_field_label_regular_struct() -> RegularStruct { |
476ff2be SL |
123 | let struct1 = RegularStruct { |
124 | x: 3, | |
125 | y: 4, | |
126 | z: 5, | |
127 | }; | |
128 | ||
129 | RegularStruct { | |
130 | x: 7, | |
131 | z: 9, | |
132 | .. struct1 | |
133 | } | |
134 | } | |
135 | ||
136 | ||
137 | ||
abe05a73 | 138 | pub struct RegularStruct2 { |
476ff2be SL |
139 | x: i8, |
140 | y: i8, | |
141 | z: i8, | |
142 | } | |
143 | ||
e1599b0c | 144 | // Change constructor path (regular struct) |
476ff2be | 145 | #[cfg(cfail1)] |
abe05a73 | 146 | pub fn change_constructor_path_regular_struct() { |
476ff2be SL |
147 | let _ = RegularStruct { |
148 | x: 0, | |
149 | y: 1, | |
150 | z: 2, | |
151 | }; | |
152 | } | |
153 | ||
154 | #[cfg(not(cfail1))] | |
ba9703b0 | 155 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,typeck_tables_of")] |
abe05a73 | 156 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 157 | pub fn change_constructor_path_regular_struct() { |
476ff2be SL |
158 | let _ = RegularStruct2 { |
159 | x: 0, | |
160 | y: 1, | |
161 | z: 2, | |
162 | }; | |
163 | } | |
164 | ||
165 | ||
166 | ||
e1599b0c | 167 | // Change constructor path indirectly (regular struct) |
abe05a73 | 168 | pub mod change_constructor_path_indirectly_regular_struct { |
476ff2be SL |
169 | #[cfg(cfail1)] |
170 | use super::RegularStruct as Struct; | |
171 | #[cfg(not(cfail1))] | |
172 | use super::RegularStruct2 as Struct; | |
173 | ||
abe05a73 XL |
174 | #[rustc_clean( |
175 | cfg="cfail2", | |
ba9703b0 | 176 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,mir_built,typeck_tables_of" |
abe05a73 XL |
177 | )] |
178 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 179 | pub fn function() -> Struct { |
476ff2be SL |
180 | Struct { |
181 | x: 0, | |
182 | y: 1, | |
183 | z: 2, | |
184 | } | |
185 | } | |
186 | } | |
187 | ||
188 | ||
189 | ||
abe05a73 | 190 | pub struct TupleStruct(i32, i64, i16); |
476ff2be | 191 | |
e1599b0c | 192 | // Change field value (tuple struct) |
476ff2be | 193 | #[cfg(cfail1)] |
abe05a73 | 194 | pub fn change_field_value_tuple_struct() -> TupleStruct { |
476ff2be SL |
195 | TupleStruct(0, 1, 2) |
196 | } | |
197 | ||
198 | #[cfg(not(cfail1))] | |
ba9703b0 | 199 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built")] |
abe05a73 | 200 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 201 | pub fn change_field_value_tuple_struct() -> TupleStruct { |
476ff2be SL |
202 | TupleStruct(0, 1, 3) |
203 | } | |
204 | ||
205 | ||
206 | ||
abe05a73 | 207 | pub struct TupleStruct2(u16, u16, u16); |
476ff2be | 208 | |
e1599b0c | 209 | // Change constructor path (tuple struct) |
476ff2be | 210 | #[cfg(cfail1)] |
abe05a73 | 211 | pub fn change_constructor_path_tuple_struct() { |
476ff2be SL |
212 | let _ = TupleStruct(0, 1, 2); |
213 | } | |
214 | ||
215 | #[cfg(not(cfail1))] | |
ba9703b0 | 216 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,mir_built,typeck_tables_of")] |
abe05a73 | 217 | #[rustc_clean(cfg="cfail3")] |
abe05a73 | 218 | pub fn change_constructor_path_tuple_struct() { |
476ff2be SL |
219 | let _ = TupleStruct2(0, 1, 2); |
220 | } | |
221 | ||
222 | ||
223 | ||
e1599b0c | 224 | // Change constructor path indirectly (tuple struct) |
abe05a73 | 225 | pub mod change_constructor_path_indirectly_tuple_struct { |
476ff2be SL |
226 | #[cfg(cfail1)] |
227 | use super::TupleStruct as Struct; | |
228 | #[cfg(not(cfail1))] | |
229 | use super::TupleStruct2 as Struct; | |
230 | ||
abe05a73 XL |
231 | #[rustc_clean( |
232 | cfg="cfail2", | |
ba9703b0 | 233 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,mir_built,typeck_tables_of" |
abe05a73 XL |
234 | )] |
235 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 236 | pub fn function() -> Struct { |
476ff2be SL |
237 | Struct(0, 1, 2) |
238 | } | |
239 | } |