]>
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?) |
c295e0f8 | 9 | // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6 |
923072b8 | 10 | // compile-flags: -Z query-dep-graph -O |
c295e0f8 XL |
11 | // [cfail1]compile-flags: -Zincremental-ignore-spans |
12 | // [cfail2]compile-flags: -Zincremental-ignore-spans | |
13 | // [cfail3]compile-flags: -Zincremental-ignore-spans | |
476ff2be SL |
14 | |
15 | #![allow(warnings)] | |
16 | #![feature(rustc_attrs)] | |
17 | #![crate_type="rlib"] | |
18 | ||
19 | ||
abe05a73 | 20 | pub enum Enum { |
476ff2be SL |
21 | Struct { |
22 | x: i32, | |
23 | y: i64, | |
24 | z: i16, | |
25 | }, | |
26 | Tuple(i32, i64, i16) | |
27 | } | |
28 | ||
29 | // Change field value (struct-like) ----------------------------------------- | |
c295e0f8 | 30 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 31 | pub fn change_field_value_struct_like() -> Enum { |
476ff2be SL |
32 | Enum::Struct { |
33 | x: 0, | |
34 | y: 1, | |
35 | z: 2, | |
36 | } | |
37 | } | |
38 | ||
c295e0f8 | 39 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 40 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 41 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
42 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
43 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 44 | pub fn change_field_value_struct_like() -> Enum { |
476ff2be SL |
45 | Enum::Struct { |
46 | x: 0, | |
47 | y: 2, | |
48 | z: 2, | |
49 | } | |
50 | } | |
51 | ||
52 | ||
53 | ||
54 | // Change field order (struct-like) ----------------------------------------- | |
c295e0f8 | 55 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 56 | pub fn change_field_order_struct_like() -> Enum { |
476ff2be SL |
57 | Enum::Struct { |
58 | x: 3, | |
59 | y: 4, | |
60 | z: 5, | |
61 | } | |
62 | } | |
63 | ||
c295e0f8 | 64 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 65 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] |
abe05a73 | 66 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
67 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")] |
68 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 XL |
69 | // FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it |
70 | // would if it were not all constants | |
71 | pub fn change_field_order_struct_like() -> Enum { | |
476ff2be SL |
72 | Enum::Struct { |
73 | y: 4, | |
74 | x: 3, | |
75 | z: 5, | |
76 | } | |
77 | } | |
78 | ||
79 | ||
abe05a73 | 80 | pub enum Enum2 { |
476ff2be SL |
81 | Struct { |
82 | x: i8, | |
83 | y: i8, | |
84 | z: i8, | |
85 | }, | |
86 | Struct2 { | |
87 | x: i8, | |
88 | y: i8, | |
89 | z: i8, | |
90 | }, | |
91 | Tuple(u16, u16, u16), | |
92 | Tuple2(u64, u64, u64), | |
93 | } | |
94 | ||
95 | // Change constructor path (struct-like) ------------------------------------ | |
c295e0f8 | 96 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 97 | pub fn change_constructor_path_struct_like() { |
c295e0f8 | 98 | let _ = Enum ::Struct { |
476ff2be SL |
99 | x: 0, |
100 | y: 1, | |
101 | z: 2, | |
102 | }; | |
103 | } | |
104 | ||
c295e0f8 | 105 | #[cfg(not(any(cfail1,cfail4)))] |
923072b8 | 106 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] |
abe05a73 | 107 | #[rustc_clean(cfg="cfail3")] |
923072b8 | 108 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")] |
c295e0f8 | 109 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 110 | pub fn change_constructor_path_struct_like() { |
476ff2be SL |
111 | let _ = Enum2::Struct { |
112 | x: 0, | |
113 | y: 1, | |
114 | z: 2, | |
115 | }; | |
116 | } | |
117 | ||
118 | ||
119 | ||
120 | // Change variant (regular struct) ------------------------------------ | |
c295e0f8 | 121 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 122 | pub fn change_constructor_variant_struct_like() { |
c295e0f8 | 123 | let _ = Enum2::Struct { |
476ff2be SL |
124 | x: 0, |
125 | y: 1, | |
126 | z: 2, | |
127 | }; | |
128 | } | |
129 | ||
c295e0f8 | 130 | #[cfg(not(any(cfail1,cfail4)))] |
923072b8 | 131 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] |
abe05a73 | 132 | #[rustc_clean(cfg="cfail3")] |
923072b8 | 133 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")] |
c295e0f8 | 134 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 135 | pub fn change_constructor_variant_struct_like() { |
476ff2be SL |
136 | let _ = Enum2::Struct2 { |
137 | x: 0, | |
138 | y: 1, | |
139 | z: 2, | |
140 | }; | |
141 | } | |
142 | ||
143 | ||
144 | // Change constructor path indirectly (struct-like) ------------------------- | |
abe05a73 | 145 | pub mod change_constructor_path_indirectly_struct_like { |
c295e0f8 | 146 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 147 | use super::Enum as TheEnum; |
c295e0f8 | 148 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
149 | use super::Enum2 as TheEnum; |
150 | ||
abe05a73 XL |
151 | #[rustc_clean( |
152 | cfg="cfail2", | |
3dfed10e XL |
153 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ |
154 | typeck" | |
abe05a73 XL |
155 | )] |
156 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
157 | #[rustc_clean( |
158 | cfg="cfail5", | |
159 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ | |
160 | typeck" | |
161 | )] | |
162 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 163 | pub fn function() -> TheEnum { |
476ff2be SL |
164 | TheEnum::Struct { |
165 | x: 0, | |
166 | y: 1, | |
167 | z: 2, | |
168 | } | |
169 | } | |
170 | } | |
171 | ||
172 | ||
173 | // Change constructor variant indirectly (struct-like) --------------------------- | |
abe05a73 | 174 | pub mod change_constructor_variant_indirectly_struct_like { |
476ff2be | 175 | use super::Enum2; |
c295e0f8 | 176 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 177 | use super::Enum2::Struct as Variant; |
c295e0f8 | 178 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
179 | use super::Enum2::Struct2 as Variant; |
180 | ||
3dfed10e | 181 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 182 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
183 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
184 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 185 | pub fn function() -> Enum2 { |
476ff2be SL |
186 | Variant { |
187 | x: 0, | |
188 | y: 1, | |
189 | z: 2, | |
190 | } | |
191 | } | |
192 | } | |
193 | ||
194 | ||
195 | // Change field value (tuple-like) ------------------------------------------- | |
c295e0f8 | 196 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 197 | pub fn change_field_value_tuple_like() -> Enum { |
476ff2be SL |
198 | Enum::Tuple(0, 1, 2) |
199 | } | |
200 | ||
c295e0f8 | 201 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 202 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 203 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
204 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
205 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 206 | pub fn change_field_value_tuple_like() -> Enum { |
476ff2be SL |
207 | Enum::Tuple(0, 1, 3) |
208 | } | |
209 | ||
210 | ||
211 | ||
212 | // Change constructor path (tuple-like) -------------------------------------- | |
c295e0f8 | 213 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 214 | pub fn change_constructor_path_tuple_like() { |
c295e0f8 | 215 | let _ = Enum ::Tuple(0, 1, 2); |
476ff2be SL |
216 | } |
217 | ||
c295e0f8 | 218 | #[cfg(not(any(cfail1,cfail4)))] |
abe05a73 XL |
219 | #[rustc_clean( |
220 | cfg="cfail2", | |
923072b8 | 221 | except="hir_owner_nodes,typeck" |
abe05a73 XL |
222 | )] |
223 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
224 | #[rustc_clean( |
225 | cfg="cfail5", | |
923072b8 | 226 | except="hir_owner_nodes,typeck" |
c295e0f8 XL |
227 | )] |
228 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 229 | pub fn change_constructor_path_tuple_like() { |
476ff2be SL |
230 | let _ = Enum2::Tuple(0, 1, 2); |
231 | } | |
232 | ||
233 | ||
234 | ||
235 | // Change constructor variant (tuple-like) -------------------------------------- | |
c295e0f8 | 236 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 237 | pub fn change_constructor_variant_tuple_like() { |
c295e0f8 | 238 | let _ = Enum2::Tuple (0, 1, 2); |
476ff2be SL |
239 | } |
240 | ||
c295e0f8 | 241 | #[cfg(not(any(cfail1,cfail4)))] |
abe05a73 XL |
242 | #[rustc_clean( |
243 | cfg="cfail2", | |
923072b8 | 244 | except="hir_owner_nodes,typeck" |
abe05a73 XL |
245 | )] |
246 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
247 | #[rustc_clean( |
248 | cfg="cfail5", | |
923072b8 | 249 | except="hir_owner_nodes,typeck" |
c295e0f8 XL |
250 | )] |
251 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 252 | pub fn change_constructor_variant_tuple_like() { |
476ff2be SL |
253 | let _ = Enum2::Tuple2(0, 1, 2); |
254 | } | |
255 | ||
256 | ||
257 | // Change constructor path indirectly (tuple-like) --------------------------- | |
abe05a73 | 258 | pub mod change_constructor_path_indirectly_tuple_like { |
c295e0f8 | 259 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 260 | use super::Enum as TheEnum; |
c295e0f8 | 261 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
262 | use super::Enum2 as TheEnum; |
263 | ||
abe05a73 XL |
264 | #[rustc_clean( |
265 | cfg="cfail2", | |
3dfed10e XL |
266 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ |
267 | typeck" | |
abe05a73 XL |
268 | )] |
269 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
270 | #[rustc_clean( |
271 | cfg="cfail5", | |
272 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ | |
273 | typeck" | |
274 | )] | |
275 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 276 | pub fn function() -> TheEnum { |
476ff2be SL |
277 | TheEnum::Tuple(0, 1, 2) |
278 | } | |
279 | } | |
280 | ||
281 | ||
282 | ||
283 | // Change constructor variant indirectly (tuple-like) --------------------------- | |
abe05a73 | 284 | pub mod change_constructor_variant_indirectly_tuple_like { |
476ff2be | 285 | use super::Enum2; |
c295e0f8 | 286 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 287 | use super::Enum2::Tuple as Variant; |
c295e0f8 | 288 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
289 | use super::Enum2::Tuple2 as Variant; |
290 | ||
3dfed10e | 291 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 292 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
293 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
294 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 295 | pub fn function() -> Enum2 { |
476ff2be SL |
296 | Variant(0, 1, 2) |
297 | } | |
298 | } | |
299 | ||
300 | ||
abe05a73 | 301 | pub enum Clike { |
476ff2be SL |
302 | A, |
303 | B, | |
304 | C | |
305 | } | |
306 | ||
abe05a73 | 307 | pub enum Clike2 { |
476ff2be SL |
308 | B, |
309 | C, | |
310 | D | |
311 | } | |
312 | ||
313 | // Change constructor path (C-like) -------------------------------------- | |
c295e0f8 | 314 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 315 | pub fn change_constructor_path_c_like() { |
c295e0f8 | 316 | let _x = Clike ::B; |
476ff2be SL |
317 | } |
318 | ||
c295e0f8 | 319 | #[cfg(not(any(cfail1,cfail4)))] |
3dfed10e | 320 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 321 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
322 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] |
323 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 324 | pub fn change_constructor_path_c_like() { |
f9f354fc | 325 | let _x = Clike2::B; |
476ff2be SL |
326 | } |
327 | ||
328 | ||
329 | ||
330 | // Change constructor variant (C-like) -------------------------------------- | |
c295e0f8 | 331 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 332 | pub fn change_constructor_variant_c_like() { |
f9f354fc | 333 | let _x = Clike::A; |
476ff2be SL |
334 | } |
335 | ||
c295e0f8 | 336 | #[cfg(not(any(cfail1,cfail4)))] |
49aad941 | 337 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 338 | #[rustc_clean(cfg="cfail3")] |
49aad941 | 339 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
c295e0f8 | 340 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 341 | pub fn change_constructor_variant_c_like() { |
f9f354fc | 342 | let _x = Clike::C; |
476ff2be SL |
343 | } |
344 | ||
345 | ||
346 | // Change constructor path indirectly (C-like) --------------------------- | |
abe05a73 | 347 | pub mod change_constructor_path_indirectly_c_like { |
c295e0f8 | 348 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 349 | use super::Clike as TheEnum; |
c295e0f8 | 350 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
351 | use super::Clike2 as TheEnum; |
352 | ||
abe05a73 XL |
353 | #[rustc_clean( |
354 | cfg="cfail2", | |
3dfed10e XL |
355 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ |
356 | typeck" | |
abe05a73 XL |
357 | )] |
358 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
359 | #[rustc_clean( |
360 | cfg="cfail5", | |
361 | except="fn_sig,hir_owner,hir_owner_nodes,optimized_mir,\ | |
362 | typeck" | |
363 | )] | |
364 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 365 | pub fn function() -> TheEnum { |
476ff2be SL |
366 | TheEnum::B |
367 | } | |
368 | } | |
369 | ||
370 | ||
371 | ||
372 | // Change constructor variant indirectly (C-like) --------------------------- | |
abe05a73 | 373 | pub mod change_constructor_variant_indirectly_c_like { |
476ff2be | 374 | use super::Clike; |
c295e0f8 | 375 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 376 | use super::Clike::A as Variant; |
c295e0f8 | 377 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
378 | use super::Clike::B as Variant; |
379 | ||
3dfed10e | 380 | #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] |
abe05a73 | 381 | #[rustc_clean(cfg="cfail3")] |
c295e0f8 XL |
382 | #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] |
383 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 384 | pub fn function() -> Clike { |
476ff2be SL |
385 | Variant |
386 | } | |
387 | } |