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
14 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
19 #![feature(rustc_attrs)]
23 // Change constant operand of negation -----------------------------------------
24 #[cfg(any(cfail1,cfail4))]
25 pub fn const_negation() -> i32 {
29 #[cfg(not(any(cfail1,cfail4)))]
30 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
31 #[rustc_clean(cfg="cfail3")]
32 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
33 #[rustc_clean(cfg="cfail6")]
34 pub fn const_negation() -> i32 {
40 // Change constant operand of bitwise not --------------------------------------
41 #[cfg(any(cfail1,cfail4))]
42 pub fn const_bitwise_not() -> i32 {
46 #[cfg(not(any(cfail1,cfail4)))]
47 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
48 #[rustc_clean(cfg="cfail3")]
49 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
50 #[rustc_clean(cfg="cfail6")]
51 pub fn const_bitwise_not() -> i32 {
57 // Change variable operand of negation -----------------------------------------
58 #[cfg(any(cfail1,cfail4))]
59 pub fn var_negation(x: i32, y: i32) -> i32 {
63 #[cfg(not(any(cfail1,cfail4)))]
64 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
65 #[rustc_clean(cfg="cfail3")]
66 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
67 #[rustc_clean(cfg="cfail6")]
68 pub fn var_negation(x: i32, y: i32) -> i32 {
74 // Change variable operand of bitwise not --------------------------------------
75 #[cfg(any(cfail1,cfail4))]
76 pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
80 #[cfg(not(any(cfail1,cfail4)))]
81 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
82 #[rustc_clean(cfg="cfail3")]
83 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
84 #[rustc_clean(cfg="cfail6")]
85 pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
91 // Change variable operand of deref --------------------------------------------
92 #[cfg(any(cfail1,cfail4))]
93 pub fn var_deref(x: &i32, y: &i32) -> i32 {
97 #[cfg(not(any(cfail1,cfail4)))]
98 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
99 #[rustc_clean(cfg="cfail3")]
100 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
101 #[rustc_clean(cfg="cfail6")]
102 pub fn var_deref(x: &i32, y: &i32) -> i32 {
108 // Change first constant operand of addition -----------------------------------
109 #[cfg(any(cfail1,cfail4))]
110 pub fn first_const_add() -> i32 {
114 #[cfg(not(any(cfail1,cfail4)))]
115 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
116 #[rustc_clean(cfg="cfail3")]
117 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
118 #[rustc_clean(cfg="cfail6")]
119 pub fn first_const_add() -> i32 {
125 // Change second constant operand of addition -----------------------------------
126 #[cfg(any(cfail1,cfail4))]
127 pub fn second_const_add() -> i32 {
131 #[cfg(not(any(cfail1,cfail4)))]
132 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
133 #[rustc_clean(cfg="cfail3")]
134 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
135 #[rustc_clean(cfg="cfail6")]
136 pub fn second_const_add() -> i32 {
142 // Change first variable operand of addition -----------------------------------
143 #[cfg(any(cfail1,cfail4))]
144 pub fn first_var_add(a: i32, b: i32) -> i32 {
148 #[cfg(not(any(cfail1,cfail4)))]
149 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
150 #[rustc_clean(cfg="cfail3")]
151 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
152 #[rustc_clean(cfg="cfail6")]
153 pub fn first_var_add(a: i32, b: i32) -> i32 {
159 // Change second variable operand of addition ----------------------------------
160 #[cfg(any(cfail1,cfail4))]
161 pub fn second_var_add(a: i32, b: i32) -> i32 {
165 #[cfg(not(any(cfail1,cfail4)))]
166 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
167 #[rustc_clean(cfg="cfail3")]
168 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
169 #[rustc_clean(cfg="cfail6")]
170 pub fn second_var_add(a: i32, b: i32) -> i32 {
176 // Change operator from + to - -------------------------------------------------
177 #[cfg(any(cfail1,cfail4))]
178 pub fn plus_to_minus(a: i32) -> i32 {
182 #[cfg(not(any(cfail1,cfail4)))]
183 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
184 #[rustc_clean(cfg="cfail3")]
185 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
186 #[rustc_clean(cfg="cfail6")]
187 pub fn plus_to_minus(a: i32) -> i32 {
193 // Change operator from + to * -------------------------------------------------
194 #[cfg(any(cfail1,cfail4))]
195 pub fn plus_to_mult(a: i32) -> i32 {
199 #[cfg(not(any(cfail1,cfail4)))]
200 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
201 #[rustc_clean(cfg="cfail3")]
202 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
203 #[rustc_clean(cfg="cfail6")]
204 pub fn plus_to_mult(a: i32) -> i32 {
210 // Change operator from + to / -------------------------------------------------
211 #[cfg(any(cfail1,cfail4))]
212 pub fn plus_to_div(a: i32) -> i32 {
216 #[cfg(not(any(cfail1,cfail4)))]
217 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
218 #[rustc_clean(cfg="cfail3")]
219 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
220 #[rustc_clean(cfg="cfail6")]
221 pub fn plus_to_div(a: i32) -> i32 {
227 // Change operator from + to % -------------------------------------------------
228 #[cfg(any(cfail1,cfail4))]
229 pub fn plus_to_mod(a: i32) -> i32 {
233 #[cfg(not(any(cfail1,cfail4)))]
234 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
235 #[rustc_clean(cfg="cfail3")]
236 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
237 #[rustc_clean(cfg="cfail6")]
238 pub fn plus_to_mod(a: i32) -> i32 {
244 // Change operator from && to || -----------------------------------------------
245 #[cfg(any(cfail1,cfail4))]
246 pub fn and_to_or(a: bool, b: bool) -> bool {
250 #[cfg(not(any(cfail1,cfail4)))]
251 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
252 #[rustc_clean(cfg="cfail3")]
253 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
254 #[rustc_clean(cfg="cfail6")]
255 pub fn and_to_or(a: bool, b: bool) -> bool {
261 // Change operator from & to | -------------------------------------------------
262 #[cfg(any(cfail1,cfail4))]
263 pub fn bitwise_and_to_bitwise_or(a: i32) -> i32 {
267 #[cfg(not(any(cfail1,cfail4)))]
268 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
269 #[rustc_clean(cfg="cfail3")]
270 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
271 #[rustc_clean(cfg="cfail6")]
272 pub fn bitwise_and_to_bitwise_or(a: i32) -> i32 {
278 // Change operator from & to ^ -------------------------------------------------
279 #[cfg(any(cfail1,cfail4))]
280 pub fn bitwise_and_to_bitwise_xor(a: i32) -> i32 {
284 #[cfg(not(any(cfail1,cfail4)))]
285 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
286 #[rustc_clean(cfg="cfail3")]
287 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
288 #[rustc_clean(cfg="cfail6")]
289 pub fn bitwise_and_to_bitwise_xor(a: i32) -> i32 {
295 // Change operator from & to << ------------------------------------------------
296 #[cfg(any(cfail1,cfail4))]
297 pub fn bitwise_and_to_lshift(a: i32) -> i32 {
301 #[cfg(not(any(cfail1,cfail4)))]
302 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
303 #[rustc_clean(cfg="cfail3")]
304 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
305 #[rustc_clean(cfg="cfail6")]
306 pub fn bitwise_and_to_lshift(a: i32) -> i32 {
312 // Change operator from & to >> ------------------------------------------------
313 #[cfg(any(cfail1,cfail4))]
314 pub fn bitwise_and_to_rshift(a: i32) -> i32 {
318 #[cfg(not(any(cfail1,cfail4)))]
319 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
320 #[rustc_clean(cfg="cfail3")]
321 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
322 #[rustc_clean(cfg="cfail6")]
323 pub fn bitwise_and_to_rshift(a: i32) -> i32 {
329 // Change operator from == to != -----------------------------------------------
330 #[cfg(any(cfail1,cfail4))]
331 pub fn eq_to_uneq(a: i32) -> bool {
335 #[cfg(not(any(cfail1,cfail4)))]
336 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
337 #[rustc_clean(cfg="cfail3")]
338 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
339 #[rustc_clean(cfg="cfail6")]
340 pub fn eq_to_uneq(a: i32) -> bool {
346 // Change operator from == to < ------------------------------------------------
347 #[cfg(any(cfail1,cfail4))]
348 pub fn eq_to_lt(a: i32) -> bool {
352 #[cfg(not(any(cfail1,cfail4)))]
353 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
354 #[rustc_clean(cfg="cfail3")]
355 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
356 #[rustc_clean(cfg="cfail6")]
357 pub fn eq_to_lt(a: i32) -> bool {
363 // Change operator from == to > ------------------------------------------------
364 #[cfg(any(cfail1,cfail4))]
365 pub fn eq_to_gt(a: i32) -> bool {
369 #[cfg(not(any(cfail1,cfail4)))]
370 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
371 #[rustc_clean(cfg="cfail3")]
372 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
373 #[rustc_clean(cfg="cfail6")]
374 pub fn eq_to_gt(a: i32) -> bool {
380 // Change operator from == to <= -----------------------------------------------
381 #[cfg(any(cfail1,cfail4))]
382 pub fn eq_to_le(a: i32) -> bool {
386 #[cfg(not(any(cfail1,cfail4)))]
387 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
388 #[rustc_clean(cfg="cfail3")]
389 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
390 #[rustc_clean(cfg="cfail6")]
391 pub fn eq_to_le(a: i32) -> bool {
397 // Change operator from == to >= -----------------------------------------------
398 #[cfg(any(cfail1,cfail4))]
399 pub fn eq_to_ge(a: i32) -> bool {
403 #[cfg(not(any(cfail1,cfail4)))]
404 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
405 #[rustc_clean(cfg="cfail3")]
406 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
407 #[rustc_clean(cfg="cfail6")]
408 pub fn eq_to_ge(a: i32) -> bool {
414 // Change type in cast expression ----------------------------------------------
415 #[cfg(any(cfail1,cfail4))]
416 pub fn type_cast(a: u8) -> u64 {
422 #[cfg(not(any(cfail1,cfail4)))]
423 #[rustc_clean(except="hir_owner_nodes,optimized_mir,typeck", cfg="cfail2")]
424 #[rustc_clean(cfg="cfail3")]
425 #[rustc_clean(except="hir_owner_nodes,optimized_mir,typeck", cfg="cfail5")]
426 #[rustc_clean(cfg="cfail6")]
427 pub fn type_cast(a: u8) -> u64 {
435 // Change value in cast expression ---------------------------------------------
436 #[cfg(any(cfail1,cfail4))]
437 pub fn value_cast(a: u32) -> i32 {
441 #[cfg(not(any(cfail1,cfail4)))]
442 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
443 #[rustc_clean(cfg="cfail3")]
444 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
445 #[rustc_clean(cfg="cfail6")]
446 pub fn value_cast(a: u32) -> i32 {
452 // Change place in assignment --------------------------------------------------
453 #[cfg(any(cfail1,cfail4))]
454 pub fn place() -> i32 {
461 #[cfg(not(any(cfail1,cfail4)))]
462 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
463 #[rustc_clean(cfg="cfail3")]
464 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
465 #[rustc_clean(cfg="cfail6")]
466 pub fn place() -> i32 {
475 // Change r-value in assignment ------------------------------------------------
476 #[cfg(any(cfail1,cfail4))]
477 pub fn rvalue() -> i32 {
483 #[cfg(not(any(cfail1,cfail4)))]
484 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
485 #[rustc_clean(cfg="cfail3")]
486 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
487 #[rustc_clean(cfg="cfail6")]
488 pub fn rvalue() -> i32 {
496 // Change index into slice -----------------------------------------------------
497 #[cfg(any(cfail1,cfail4))]
498 pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 {
502 #[cfg(not(any(cfail1,cfail4)))]
503 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
504 #[rustc_clean(cfg="cfail3")]
505 #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail5")]
506 #[rustc_clean(cfg="cfail6")]
507 pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 {