1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for unary and binary 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
16 #![feature(rustc_attrs)]
20 // Change constant operand of negation -----------------------------------------
21 #[cfg(any(cfail1,cfail4))]
22 pub fn const_negation() -> i32 {
26 #[cfg(not(any(cfail1,cfail4)))]
27 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
28 #[rustc_clean(cfg="cfail3")]
29 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
30 #[rustc_clean(cfg="cfail6")]
31 pub fn const_negation() -> i32 {
37 // Change constant operand of bitwise not --------------------------------------
38 #[cfg(any(cfail1,cfail4))]
39 pub fn const_bitwise_not() -> i32 {
43 #[cfg(not(any(cfail1,cfail4)))]
44 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
45 #[rustc_clean(cfg="cfail3")]
46 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
47 #[rustc_clean(cfg="cfail6")]
48 pub fn const_bitwise_not() -> i32 {
54 // Change variable operand of negation -----------------------------------------
55 #[cfg(any(cfail1,cfail4))]
56 pub fn var_negation(x: i32, y: i32) -> i32 {
60 #[cfg(not(any(cfail1,cfail4)))]
61 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
62 #[rustc_clean(cfg="cfail3")]
63 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
64 #[rustc_clean(cfg="cfail6")]
65 pub fn var_negation(x: i32, y: i32) -> i32 {
71 // Change variable operand of bitwise not --------------------------------------
72 #[cfg(any(cfail1,cfail4))]
73 pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
77 #[cfg(not(any(cfail1,cfail4)))]
78 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
79 #[rustc_clean(cfg="cfail3")]
80 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
81 #[rustc_clean(cfg="cfail6")]
82 pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
88 // Change variable operand of deref --------------------------------------------
89 #[cfg(any(cfail1,cfail4))]
90 pub fn var_deref(x: &i32, y: &i32) -> i32 {
94 #[cfg(not(any(cfail1,cfail4)))]
95 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
96 #[rustc_clean(cfg="cfail3")]
97 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
98 #[rustc_clean(cfg="cfail6")]
99 pub fn var_deref(x: &i32, y: &i32) -> i32 {
105 // Change first constant operand of addition -----------------------------------
106 #[cfg(any(cfail1,cfail4))]
107 pub fn first_const_add() -> i32 {
111 #[cfg(not(any(cfail1,cfail4)))]
112 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
113 #[rustc_clean(cfg="cfail3")]
114 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
115 #[rustc_clean(cfg="cfail6")]
116 pub fn first_const_add() -> i32 {
122 // Change second constant operand of addition -----------------------------------
123 #[cfg(any(cfail1,cfail4))]
124 pub fn second_const_add() -> i32 {
128 #[cfg(not(any(cfail1,cfail4)))]
129 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
130 #[rustc_clean(cfg="cfail3")]
131 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
132 #[rustc_clean(cfg="cfail6")]
133 pub fn second_const_add() -> i32 {
139 // Change first variable operand of addition -----------------------------------
140 #[cfg(any(cfail1,cfail4))]
141 pub fn first_var_add(a: i32, b: i32) -> i32 {
145 #[cfg(not(any(cfail1,cfail4)))]
146 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
147 #[rustc_clean(cfg="cfail3")]
148 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
149 #[rustc_clean(cfg="cfail6")]
150 pub fn first_var_add(a: i32, b: i32) -> i32 {
156 // Change second variable operand of addition ----------------------------------
157 #[cfg(any(cfail1,cfail4))]
158 pub fn second_var_add(a: i32, b: i32) -> i32 {
162 #[cfg(not(any(cfail1,cfail4)))]
163 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
164 #[rustc_clean(cfg="cfail3")]
165 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
166 #[rustc_clean(cfg="cfail6")]
167 pub fn second_var_add(a: i32, b: i32) -> i32 {
173 // Change operator from + to - -------------------------------------------------
174 #[cfg(any(cfail1,cfail4))]
175 pub fn plus_to_minus(a: i32) -> i32 {
179 #[cfg(not(any(cfail1,cfail4)))]
180 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
181 #[rustc_clean(cfg="cfail3")]
182 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
183 #[rustc_clean(cfg="cfail6")]
184 pub fn plus_to_minus(a: i32) -> i32 {
190 // Change operator from + to * -------------------------------------------------
191 #[cfg(any(cfail1,cfail4))]
192 pub fn plus_to_mult(a: i32) -> i32 {
196 #[cfg(not(any(cfail1,cfail4)))]
197 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
198 #[rustc_clean(cfg="cfail3")]
199 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
200 #[rustc_clean(cfg="cfail6")]
201 pub fn plus_to_mult(a: i32) -> i32 {
207 // Change operator from + to / -------------------------------------------------
208 #[cfg(any(cfail1,cfail4))]
209 pub fn plus_to_div(a: i32) -> i32 {
213 #[cfg(not(any(cfail1,cfail4)))]
214 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
215 #[rustc_clean(cfg="cfail3")]
216 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
217 #[rustc_clean(cfg="cfail6")]
218 pub fn plus_to_div(a: i32) -> i32 {
224 // Change operator from + to % -------------------------------------------------
225 #[cfg(any(cfail1,cfail4))]
226 pub fn plus_to_mod(a: i32) -> i32 {
230 #[cfg(not(any(cfail1,cfail4)))]
231 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
232 #[rustc_clean(cfg="cfail3")]
233 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
234 #[rustc_clean(cfg="cfail6")]
235 pub fn plus_to_mod(a: i32) -> i32 {
241 // Change operator from && to || -----------------------------------------------
242 #[cfg(any(cfail1,cfail4))]
243 pub fn and_to_or(a: bool, b: bool) -> bool {
247 #[cfg(not(any(cfail1,cfail4)))]
248 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
249 #[rustc_clean(cfg="cfail3")]
250 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
251 #[rustc_clean(cfg="cfail6")]
252 pub fn and_to_or(a: bool, b: bool) -> bool {
258 // Change operator from & to | -------------------------------------------------
259 #[cfg(any(cfail1,cfail4))]
260 pub fn bitwise_and_to_bitwise_or(a: i32) -> i32 {
264 #[cfg(not(any(cfail1,cfail4)))]
265 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
266 #[rustc_clean(cfg="cfail3")]
267 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
268 #[rustc_clean(cfg="cfail6")]
269 pub fn bitwise_and_to_bitwise_or(a: i32) -> i32 {
275 // Change operator from & to ^ -------------------------------------------------
276 #[cfg(any(cfail1,cfail4))]
277 pub fn bitwise_and_to_bitwise_xor(a: i32) -> i32 {
281 #[cfg(not(any(cfail1,cfail4)))]
282 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
283 #[rustc_clean(cfg="cfail3")]
284 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
285 #[rustc_clean(cfg="cfail6")]
286 pub fn bitwise_and_to_bitwise_xor(a: i32) -> i32 {
292 // Change operator from & to << ------------------------------------------------
293 #[cfg(any(cfail1,cfail4))]
294 pub fn bitwise_and_to_lshift(a: i32) -> i32 {
298 #[cfg(not(any(cfail1,cfail4)))]
299 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
300 #[rustc_clean(cfg="cfail3")]
301 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
302 #[rustc_clean(cfg="cfail6")]
303 pub fn bitwise_and_to_lshift(a: i32) -> i32 {
309 // Change operator from & to >> ------------------------------------------------
310 #[cfg(any(cfail1,cfail4))]
311 pub fn bitwise_and_to_rshift(a: i32) -> i32 {
315 #[cfg(not(any(cfail1,cfail4)))]
316 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
317 #[rustc_clean(cfg="cfail3")]
318 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
319 #[rustc_clean(cfg="cfail6")]
320 pub fn bitwise_and_to_rshift(a: i32) -> i32 {
326 // Change operator from == to != -----------------------------------------------
327 #[cfg(any(cfail1,cfail4))]
328 pub fn eq_to_uneq(a: i32) -> bool {
332 #[cfg(not(any(cfail1,cfail4)))]
333 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
334 #[rustc_clean(cfg="cfail3")]
335 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
336 #[rustc_clean(cfg="cfail6")]
337 pub fn eq_to_uneq(a: i32) -> bool {
343 // Change operator from == to < ------------------------------------------------
344 #[cfg(any(cfail1,cfail4))]
345 pub fn eq_to_lt(a: i32) -> bool {
349 #[cfg(not(any(cfail1,cfail4)))]
350 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
351 #[rustc_clean(cfg="cfail3")]
352 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
353 #[rustc_clean(cfg="cfail6")]
354 pub fn eq_to_lt(a: i32) -> bool {
360 // Change operator from == to > ------------------------------------------------
361 #[cfg(any(cfail1,cfail4))]
362 pub fn eq_to_gt(a: i32) -> bool {
366 #[cfg(not(any(cfail1,cfail4)))]
367 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
368 #[rustc_clean(cfg="cfail3")]
369 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
370 #[rustc_clean(cfg="cfail6")]
371 pub fn eq_to_gt(a: i32) -> bool {
377 // Change operator from == to <= -----------------------------------------------
378 #[cfg(any(cfail1,cfail4))]
379 pub fn eq_to_le(a: i32) -> bool {
383 #[cfg(not(any(cfail1,cfail4)))]
384 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
385 #[rustc_clean(cfg="cfail3")]
386 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
387 #[rustc_clean(cfg="cfail6")]
388 pub fn eq_to_le(a: i32) -> bool {
394 // Change operator from == to >= -----------------------------------------------
395 #[cfg(any(cfail1,cfail4))]
396 pub fn eq_to_ge(a: i32) -> bool {
400 #[cfg(not(any(cfail1,cfail4)))]
401 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
402 #[rustc_clean(cfg="cfail3")]
403 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
404 #[rustc_clean(cfg="cfail6")]
405 pub fn eq_to_ge(a: i32) -> bool {
411 // Change type in cast expression ----------------------------------------------
412 #[cfg(any(cfail1,cfail4))]
413 pub fn type_cast(a: u8) -> u64 {
419 #[cfg(not(any(cfail1,cfail4)))]
420 #[rustc_clean(except="hir_owner_nodes,optimized_mir,typeck", cfg="cfail2")]
421 #[rustc_clean(cfg="cfail3")]
422 #[rustc_clean(except="hir_owner_nodes,optimized_mir,typeck", cfg="cfail5")]
423 #[rustc_clean(cfg="cfail6")]
424 pub fn type_cast(a: u8) -> u64 {
432 // Change value in cast expression ---------------------------------------------
433 #[cfg(any(cfail1,cfail4))]
434 pub fn value_cast(a: u32) -> i32 {
438 #[cfg(not(any(cfail1,cfail4)))]
439 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
440 #[rustc_clean(cfg="cfail3")]
441 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
442 #[rustc_clean(cfg="cfail6")]
443 pub fn value_cast(a: u32) -> i32 {
449 // Change place in assignment --------------------------------------------------
450 #[cfg(any(cfail1,cfail4))]
451 pub fn place() -> i32 {
458 #[cfg(not(any(cfail1,cfail4)))]
459 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
460 #[rustc_clean(cfg="cfail3")]
461 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
462 #[rustc_clean(cfg="cfail6")]
463 pub fn place() -> i32 {
472 // Change r-value in assignment ------------------------------------------------
473 #[cfg(any(cfail1,cfail4))]
474 pub fn rvalue() -> i32 {
480 #[cfg(not(any(cfail1,cfail4)))]
481 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
482 #[rustc_clean(cfg="cfail3")]
483 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
484 #[rustc_clean(cfg="cfail6")]
485 pub fn rvalue() -> i32 {
493 // Change index into slice -----------------------------------------------------
494 #[cfg(any(cfail1,cfail4))]
495 pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 {
499 #[cfg(not(any(cfail1,cfail4)))]
500 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
501 #[rustc_clean(cfg="cfail3")]
502 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
503 #[rustc_clean(cfg="cfail6")]
504 pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 {