]> git.proxmox.com Git - rustc.git/blob - tests/incremental/hashes/enum_constructors.rs
d839dabf293af971e877c1713457e1f52785851f
[rustc.git] / tests / incremental / hashes / enum_constructors.rs
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
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
15 #![allow(warnings)]
16 #![feature(rustc_attrs)]
17 #![crate_type="rlib"]
18
19
20 pub enum Enum {
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) -----------------------------------------
30 #[cfg(any(cfail1,cfail4))]
31 pub fn change_field_value_struct_like() -> Enum {
32 Enum::Struct {
33 x: 0,
34 y: 1,
35 z: 2,
36 }
37 }
38
39 #[cfg(not(any(cfail1,cfail4)))]
40 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")]
41 #[rustc_clean(cfg="cfail3")]
42 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")]
43 #[rustc_clean(cfg="cfail6")]
44 pub fn change_field_value_struct_like() -> Enum {
45 Enum::Struct {
46 x: 0,
47 y: 2,
48 z: 2,
49 }
50 }
51
52
53
54 // Change field order (struct-like) -----------------------------------------
55 #[cfg(any(cfail1,cfail4))]
56 pub fn change_field_order_struct_like() -> Enum {
57 Enum::Struct {
58 x: 3,
59 y: 4,
60 z: 5,
61 }
62 }
63
64 #[cfg(not(any(cfail1,cfail4)))]
65 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")]
66 #[rustc_clean(cfg="cfail3")]
67 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")]
68 #[rustc_clean(cfg="cfail6")]
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 {
72 Enum::Struct {
73 y: 4,
74 x: 3,
75 z: 5,
76 }
77 }
78
79
80 pub enum Enum2 {
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) ------------------------------------
96 #[cfg(any(cfail1,cfail4))]
97 pub fn change_constructor_path_struct_like() {
98 let _ = Enum ::Struct {
99 x: 0,
100 y: 1,
101 z: 2,
102 };
103 }
104
105 #[cfg(not(any(cfail1,cfail4)))]
106 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")]
107 #[rustc_clean(cfg="cfail3")]
108 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")]
109 #[rustc_clean(cfg="cfail6")]
110 pub fn change_constructor_path_struct_like() {
111 let _ = Enum2::Struct {
112 x: 0,
113 y: 1,
114 z: 2,
115 };
116 }
117
118
119
120 // Change variant (regular struct) ------------------------------------
121 #[cfg(any(cfail1,cfail4))]
122 pub fn change_constructor_variant_struct_like() {
123 let _ = Enum2::Struct {
124 x: 0,
125 y: 1,
126 z: 2,
127 };
128 }
129
130 #[cfg(not(any(cfail1,cfail4)))]
131 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")]
132 #[rustc_clean(cfg="cfail3")]
133 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")]
134 #[rustc_clean(cfg="cfail6")]
135 pub fn change_constructor_variant_struct_like() {
136 let _ = Enum2::Struct2 {
137 x: 0,
138 y: 1,
139 z: 2,
140 };
141 }
142
143
144 // Change constructor path indirectly (struct-like) -------------------------
145 pub mod change_constructor_path_indirectly_struct_like {
146 #[cfg(any(cfail1,cfail4))]
147 use super::Enum as TheEnum;
148 #[cfg(not(any(cfail1,cfail4)))]
149 use super::Enum2 as TheEnum;
150
151 #[rustc_clean(cfg="cfail2", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")]
152 #[rustc_clean(cfg="cfail3")]
153 #[rustc_clean(cfg="cfail5", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")]
154 #[rustc_clean(cfg="cfail6")]
155 pub fn function() -> TheEnum {
156 TheEnum::Struct {
157 x: 0,
158 y: 1,
159 z: 2,
160 }
161 }
162 }
163
164
165 // Change constructor variant indirectly (struct-like) ---------------------------
166 pub mod change_constructor_variant_indirectly_struct_like {
167 use super::Enum2;
168 #[cfg(any(cfail1,cfail4))]
169 use super::Enum2::Struct as Variant;
170 #[cfg(not(any(cfail1,cfail4)))]
171 use super::Enum2::Struct2 as Variant;
172
173 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")]
174 #[rustc_clean(cfg="cfail3")]
175 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")]
176 #[rustc_clean(cfg="cfail6")]
177 pub fn function() -> Enum2 {
178 Variant {
179 x: 0,
180 y: 1,
181 z: 2,
182 }
183 }
184 }
185
186
187 // Change field value (tuple-like) -------------------------------------------
188 #[cfg(any(cfail1,cfail4))]
189 pub fn change_field_value_tuple_like() -> Enum {
190 Enum::Tuple(0, 1, 2)
191 }
192
193 #[cfg(not(any(cfail1,cfail4)))]
194 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")]
195 #[rustc_clean(cfg="cfail3")]
196 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")]
197 #[rustc_clean(cfg="cfail6")]
198 pub fn change_field_value_tuple_like() -> Enum {
199 Enum::Tuple(0, 1, 3)
200 }
201
202
203
204 // Change constructor path (tuple-like) --------------------------------------
205 #[cfg(any(cfail1,cfail4))]
206 pub fn change_constructor_path_tuple_like() {
207 let _ = Enum ::Tuple(0, 1, 2);
208 }
209
210 #[cfg(not(any(cfail1,cfail4)))]
211 #[rustc_clean(
212 cfg="cfail2",
213 except="opt_hir_owner_nodes,typeck"
214 )]
215 #[rustc_clean(cfg="cfail3")]
216 #[rustc_clean(
217 cfg="cfail5",
218 except="opt_hir_owner_nodes,typeck"
219 )]
220 #[rustc_clean(cfg="cfail6")]
221 pub fn change_constructor_path_tuple_like() {
222 let _ = Enum2::Tuple(0, 1, 2);
223 }
224
225
226
227 // Change constructor variant (tuple-like) --------------------------------------
228 #[cfg(any(cfail1,cfail4))]
229 pub fn change_constructor_variant_tuple_like() {
230 let _ = Enum2::Tuple (0, 1, 2);
231 }
232
233 #[cfg(not(any(cfail1,cfail4)))]
234 #[rustc_clean(
235 cfg="cfail2",
236 except="opt_hir_owner_nodes,typeck"
237 )]
238 #[rustc_clean(cfg="cfail3")]
239 #[rustc_clean(
240 cfg="cfail5",
241 except="opt_hir_owner_nodes,typeck"
242 )]
243 #[rustc_clean(cfg="cfail6")]
244 pub fn change_constructor_variant_tuple_like() {
245 let _ = Enum2::Tuple2(0, 1, 2);
246 }
247
248
249 // Change constructor path indirectly (tuple-like) ---------------------------
250 pub mod change_constructor_path_indirectly_tuple_like {
251 #[cfg(any(cfail1,cfail4))]
252 use super::Enum as TheEnum;
253 #[cfg(not(any(cfail1,cfail4)))]
254 use super::Enum2 as TheEnum;
255
256 #[rustc_clean(cfg="cfail2", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")]
257 #[rustc_clean(cfg="cfail3")]
258 #[rustc_clean(cfg="cfail5", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")]
259 #[rustc_clean(cfg="cfail6")]
260 pub fn function() -> TheEnum {
261 TheEnum::Tuple(0, 1, 2)
262 }
263 }
264
265
266
267 // Change constructor variant indirectly (tuple-like) ---------------------------
268 pub mod change_constructor_variant_indirectly_tuple_like {
269 use super::Enum2;
270 #[cfg(any(cfail1,cfail4))]
271 use super::Enum2::Tuple as Variant;
272 #[cfg(not(any(cfail1,cfail4)))]
273 use super::Enum2::Tuple2 as Variant;
274
275 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")]
276 #[rustc_clean(cfg="cfail3")]
277 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")]
278 #[rustc_clean(cfg="cfail6")]
279 pub fn function() -> Enum2 {
280 Variant(0, 1, 2)
281 }
282 }
283
284
285 pub enum Clike {
286 A,
287 B,
288 C
289 }
290
291 pub enum Clike2 {
292 B,
293 C,
294 D
295 }
296
297 // Change constructor path (C-like) --------------------------------------
298 #[cfg(any(cfail1,cfail4))]
299 pub fn change_constructor_path_c_like() {
300 let _x = Clike ::B;
301 }
302
303 #[cfg(not(any(cfail1,cfail4)))]
304 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")]
305 #[rustc_clean(cfg="cfail3")]
306 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")]
307 #[rustc_clean(cfg="cfail6")]
308 pub fn change_constructor_path_c_like() {
309 let _x = Clike2::B;
310 }
311
312
313
314 // Change constructor variant (C-like) --------------------------------------
315 #[cfg(any(cfail1,cfail4))]
316 pub fn change_constructor_variant_c_like() {
317 let _x = Clike::A;
318 }
319
320 #[cfg(not(any(cfail1,cfail4)))]
321 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")]
322 #[rustc_clean(cfg="cfail3")]
323 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")]
324 #[rustc_clean(cfg="cfail6")]
325 pub fn change_constructor_variant_c_like() {
326 let _x = Clike::C;
327 }
328
329
330 // Change constructor path indirectly (C-like) ---------------------------
331 pub mod change_constructor_path_indirectly_c_like {
332 #[cfg(any(cfail1,cfail4))]
333 use super::Clike as TheEnum;
334 #[cfg(not(any(cfail1,cfail4)))]
335 use super::Clike2 as TheEnum;
336
337 #[rustc_clean(cfg="cfail2", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")]
338 #[rustc_clean(cfg="cfail3")]
339 #[rustc_clean(cfg="cfail5", except="fn_sig,opt_hir_owner_nodes,optimized_mir,typeck")]
340 #[rustc_clean(cfg="cfail6")]
341 pub fn function() -> TheEnum {
342 TheEnum::B
343 }
344 }
345
346
347
348 // Change constructor variant indirectly (C-like) ---------------------------
349 pub mod change_constructor_variant_indirectly_c_like {
350 use super::Clike;
351 #[cfg(any(cfail1,cfail4))]
352 use super::Clike::A as Variant;
353 #[cfg(not(any(cfail1,cfail4)))]
354 use super::Clike::B as Variant;
355
356 #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")]
357 #[rustc_clean(cfg="cfail3")]
358 #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")]
359 #[rustc_clean(cfg="cfail6")]
360 pub fn function() -> Clike {
361 Variant
362 }
363 }