]>
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 | ||
c620b35d FG |
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 | |
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)))] |
c0240ec0 | 40 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")] |
abe05a73 | 41 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 42 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")] |
c295e0f8 | 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)))] |
c0240ec0 | 65 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] |
abe05a73 | 66 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 67 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] |
c295e0f8 | 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)))] |
c0240ec0 | 106 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] |
abe05a73 | 107 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 108 | #[rustc_clean(cfg="cfail5", except="opt_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)))] |
c0240ec0 | 131 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] |
abe05a73 | 132 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 133 | #[rustc_clean(cfg="cfail5", except="opt_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 | ||
c0240ec0 | 151 | #[rustc_clean(cfg="cfail2", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 152 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 153 | #[rustc_clean(cfg="cfail5", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")] |
c295e0f8 | 154 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 155 | pub fn function() -> TheEnum { |
476ff2be SL |
156 | TheEnum::Struct { |
157 | x: 0, | |
158 | y: 1, | |
159 | z: 2, | |
160 | } | |
161 | } | |
162 | } | |
163 | ||
164 | ||
165 | // Change constructor variant indirectly (struct-like) --------------------------- | |
abe05a73 | 166 | pub mod change_constructor_variant_indirectly_struct_like { |
476ff2be | 167 | use super::Enum2; |
c295e0f8 | 168 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 169 | use super::Enum2::Struct as Variant; |
c295e0f8 | 170 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
171 | use super::Enum2::Struct2 as Variant; |
172 | ||
c0240ec0 | 173 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")] |
abe05a73 | 174 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 175 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")] |
c295e0f8 | 176 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 177 | pub fn function() -> Enum2 { |
476ff2be SL |
178 | Variant { |
179 | x: 0, | |
180 | y: 1, | |
181 | z: 2, | |
182 | } | |
183 | } | |
184 | } | |
185 | ||
186 | ||
187 | // Change field value (tuple-like) ------------------------------------------- | |
c295e0f8 | 188 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 189 | pub fn change_field_value_tuple_like() -> Enum { |
476ff2be SL |
190 | Enum::Tuple(0, 1, 2) |
191 | } | |
192 | ||
c295e0f8 | 193 | #[cfg(not(any(cfail1,cfail4)))] |
c0240ec0 | 194 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")] |
abe05a73 | 195 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 196 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")] |
c295e0f8 | 197 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 198 | pub fn change_field_value_tuple_like() -> Enum { |
476ff2be SL |
199 | Enum::Tuple(0, 1, 3) |
200 | } | |
201 | ||
202 | ||
203 | ||
204 | // Change constructor path (tuple-like) -------------------------------------- | |
c295e0f8 | 205 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 206 | pub fn change_constructor_path_tuple_like() { |
c295e0f8 | 207 | let _ = Enum ::Tuple(0, 1, 2); |
476ff2be SL |
208 | } |
209 | ||
c295e0f8 | 210 | #[cfg(not(any(cfail1,cfail4)))] |
abe05a73 XL |
211 | #[rustc_clean( |
212 | cfg="cfail2", | |
c0240ec0 | 213 | except="opt_hir_owner_nodes,typeck" |
abe05a73 XL |
214 | )] |
215 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
216 | #[rustc_clean( |
217 | cfg="cfail5", | |
c0240ec0 | 218 | except="opt_hir_owner_nodes,typeck" |
c295e0f8 XL |
219 | )] |
220 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 221 | pub fn change_constructor_path_tuple_like() { |
476ff2be SL |
222 | let _ = Enum2::Tuple(0, 1, 2); |
223 | } | |
224 | ||
225 | ||
226 | ||
227 | // Change constructor variant (tuple-like) -------------------------------------- | |
c295e0f8 | 228 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 229 | pub fn change_constructor_variant_tuple_like() { |
c295e0f8 | 230 | let _ = Enum2::Tuple (0, 1, 2); |
476ff2be SL |
231 | } |
232 | ||
c295e0f8 | 233 | #[cfg(not(any(cfail1,cfail4)))] |
abe05a73 XL |
234 | #[rustc_clean( |
235 | cfg="cfail2", | |
c0240ec0 | 236 | except="opt_hir_owner_nodes,typeck" |
abe05a73 XL |
237 | )] |
238 | #[rustc_clean(cfg="cfail3")] | |
c295e0f8 XL |
239 | #[rustc_clean( |
240 | cfg="cfail5", | |
c0240ec0 | 241 | except="opt_hir_owner_nodes,typeck" |
c295e0f8 XL |
242 | )] |
243 | #[rustc_clean(cfg="cfail6")] | |
abe05a73 | 244 | pub fn change_constructor_variant_tuple_like() { |
476ff2be SL |
245 | let _ = Enum2::Tuple2(0, 1, 2); |
246 | } | |
247 | ||
248 | ||
249 | // Change constructor path indirectly (tuple-like) --------------------------- | |
abe05a73 | 250 | pub mod change_constructor_path_indirectly_tuple_like { |
c295e0f8 | 251 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 252 | use super::Enum as TheEnum; |
c295e0f8 | 253 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
254 | use super::Enum2 as TheEnum; |
255 | ||
c0240ec0 | 256 | #[rustc_clean(cfg="cfail2", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 257 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 258 | #[rustc_clean(cfg="cfail5", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")] |
c295e0f8 | 259 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 260 | pub fn function() -> TheEnum { |
476ff2be SL |
261 | TheEnum::Tuple(0, 1, 2) |
262 | } | |
263 | } | |
264 | ||
265 | ||
266 | ||
267 | // Change constructor variant indirectly (tuple-like) --------------------------- | |
abe05a73 | 268 | pub mod change_constructor_variant_indirectly_tuple_like { |
476ff2be | 269 | use super::Enum2; |
c295e0f8 | 270 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 271 | use super::Enum2::Tuple as Variant; |
c295e0f8 | 272 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
273 | use super::Enum2::Tuple2 as Variant; |
274 | ||
c0240ec0 | 275 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 276 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 277 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] |
c295e0f8 | 278 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 279 | pub fn function() -> Enum2 { |
476ff2be SL |
280 | Variant(0, 1, 2) |
281 | } | |
282 | } | |
283 | ||
284 | ||
abe05a73 | 285 | pub enum Clike { |
476ff2be SL |
286 | A, |
287 | B, | |
288 | C | |
289 | } | |
290 | ||
abe05a73 | 291 | pub enum Clike2 { |
476ff2be SL |
292 | B, |
293 | C, | |
294 | D | |
295 | } | |
296 | ||
297 | // Change constructor path (C-like) -------------------------------------- | |
c295e0f8 | 298 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 299 | pub fn change_constructor_path_c_like() { |
c295e0f8 | 300 | let _x = Clike ::B; |
476ff2be SL |
301 | } |
302 | ||
c295e0f8 | 303 | #[cfg(not(any(cfail1,cfail4)))] |
c0240ec0 | 304 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 305 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 306 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] |
c295e0f8 | 307 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 308 | pub fn change_constructor_path_c_like() { |
f9f354fc | 309 | let _x = Clike2::B; |
476ff2be SL |
310 | } |
311 | ||
312 | ||
313 | ||
314 | // Change constructor variant (C-like) -------------------------------------- | |
c295e0f8 | 315 | #[cfg(any(cfail1,cfail4))] |
abe05a73 | 316 | pub fn change_constructor_variant_c_like() { |
f9f354fc | 317 | let _x = Clike::A; |
476ff2be SL |
318 | } |
319 | ||
c295e0f8 | 320 | #[cfg(not(any(cfail1,cfail4)))] |
c0240ec0 | 321 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")] |
abe05a73 | 322 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 323 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")] |
c295e0f8 | 324 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 325 | pub fn change_constructor_variant_c_like() { |
f9f354fc | 326 | let _x = Clike::C; |
476ff2be SL |
327 | } |
328 | ||
329 | ||
330 | // Change constructor path indirectly (C-like) --------------------------- | |
abe05a73 | 331 | pub mod change_constructor_path_indirectly_c_like { |
c295e0f8 | 332 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 333 | use super::Clike as TheEnum; |
c295e0f8 | 334 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
335 | use super::Clike2 as TheEnum; |
336 | ||
c0240ec0 | 337 | #[rustc_clean(cfg="cfail2", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")] |
abe05a73 | 338 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 339 | #[rustc_clean(cfg="cfail5", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")] |
c295e0f8 | 340 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 341 | pub fn function() -> TheEnum { |
476ff2be SL |
342 | TheEnum::B |
343 | } | |
344 | } | |
345 | ||
346 | ||
347 | ||
348 | // Change constructor variant indirectly (C-like) --------------------------- | |
abe05a73 | 349 | pub mod change_constructor_variant_indirectly_c_like { |
476ff2be | 350 | use super::Clike; |
c295e0f8 | 351 | #[cfg(any(cfail1,cfail4))] |
476ff2be | 352 | use super::Clike::A as Variant; |
c295e0f8 | 353 | #[cfg(not(any(cfail1,cfail4)))] |
476ff2be SL |
354 | use super::Clike::B as Variant; |
355 | ||
c0240ec0 | 356 | #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")] |
abe05a73 | 357 | #[rustc_clean(cfg="cfail3")] |
c0240ec0 | 358 | #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")] |
c295e0f8 | 359 | #[rustc_clean(cfg="cfail6")] |
abe05a73 | 360 | pub fn function() -> Clike { |
476ff2be SL |
361 | Variant |
362 | } | |
363 | } |