1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for unary and binary expressions.
15 // The general pattern followed here is: Change one thing between rev1 and rev2
16 // and make sure that the hash has changed, then change nothing between rev2 and
17 // rev3 and make sure that the hash has not changed.
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
24 #![feature(rustc_attrs)]
28 // Change constant operand of negation -----------------------------------------
30 pub fn const_negation() -> i32 {
35 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
36 #[rustc_clean(cfg="cfail3")]
37 pub fn const_negation() -> i32 {
43 // Change constant operand of bitwise not --------------------------------------
45 pub fn const_bitwise_not() -> i32 {
50 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
51 #[rustc_clean(cfg="cfail3")]
52 pub fn const_bitwise_not() -> i32 {
58 // Change variable operand of negation -----------------------------------------
60 pub fn var_negation(x: i32, y: i32) -> i32 {
65 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
66 #[rustc_clean(cfg="cfail3")]
67 pub fn var_negation(x: i32, y: i32) -> i32 {
73 // Change variable operand of bitwise not --------------------------------------
75 pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
80 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
81 #[rustc_clean(cfg="cfail3")]
82 pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
88 // Change variable operand of deref --------------------------------------------
90 pub fn var_deref(x: &i32, y: &i32) -> i32 {
95 #[rustc_clean(except="HirBody,MirOptimized,MirValidated,TypeckTables", cfg="cfail2")]
96 #[rustc_clean(cfg="cfail3")]
97 pub fn var_deref(x: &i32, y: &i32) -> i32 {
103 // Change first constant operand of addition -----------------------------------
105 pub fn first_const_add() -> i32 {
110 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
111 #[rustc_clean(cfg="cfail3")]
112 pub fn first_const_add() -> i32 {
118 // Change second constant operand of addition -----------------------------------
120 pub fn second_const_add() -> i32 {
125 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
126 #[rustc_clean(cfg="cfail3")]
127 pub fn second_const_add() -> i32 {
133 // Change first variable operand of addition -----------------------------------
135 pub fn first_var_add(a: i32, b: i32) -> i32 {
140 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
141 #[rustc_clean(cfg="cfail3")]
142 pub fn first_var_add(a: i32, b: i32) -> i32 {
148 // Change second variable operand of addition ----------------------------------
150 pub fn second_var_add(a: i32, b: i32) -> i32 {
155 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
156 #[rustc_clean(cfg="cfail3")]
157 pub fn second_var_add(a: i32, b: i32) -> i32 {
163 // Change operator from + to - -------------------------------------------------
165 pub fn plus_to_minus(a: i32) -> i32 {
170 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
171 #[rustc_clean(cfg="cfail3")]
172 pub fn plus_to_minus(a: i32) -> i32 {
178 // Change operator from + to * -------------------------------------------------
180 pub fn plus_to_mult(a: i32) -> i32 {
185 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
186 #[rustc_clean(cfg="cfail3")]
187 pub fn plus_to_mult(a: i32) -> i32 {
193 // Change operator from + to / -------------------------------------------------
195 pub fn plus_to_div(a: i32) -> i32 {
200 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
201 #[rustc_clean(cfg="cfail3")]
202 pub fn plus_to_div(a: i32) -> i32 {
208 // Change operator from + to % -------------------------------------------------
210 pub fn plus_to_mod(a: i32) -> i32 {
215 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
216 #[rustc_clean(cfg="cfail3")]
217 pub fn plus_to_mod(a: i32) -> i32 {
223 // Change operator from && to || -----------------------------------------------
225 pub fn and_to_or(a: bool, b: bool) -> bool {
230 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
231 #[rustc_clean(cfg="cfail3")]
232 pub fn and_to_or(a: bool, b: bool) -> bool {
238 // Change operator from & to | -------------------------------------------------
240 pub fn bitwise_and_to_bitwise_or(a: i32) -> i32 {
245 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
246 #[rustc_clean(cfg="cfail3")]
247 pub fn bitwise_and_to_bitwise_or(a: i32) -> i32 {
253 // Change operator from & to ^ -------------------------------------------------
255 pub fn bitwise_and_to_bitwise_xor(a: i32) -> i32 {
260 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
261 #[rustc_clean(cfg="cfail3")]
262 pub fn bitwise_and_to_bitwise_xor(a: i32) -> i32 {
268 // Change operator from & to << ------------------------------------------------
270 pub fn bitwise_and_to_lshift(a: i32) -> i32 {
275 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
276 #[rustc_clean(cfg="cfail3")]
277 pub fn bitwise_and_to_lshift(a: i32) -> i32 {
283 // Change operator from & to >> ------------------------------------------------
285 pub fn bitwise_and_to_rshift(a: i32) -> i32 {
290 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
291 #[rustc_clean(cfg="cfail3")]
292 pub fn bitwise_and_to_rshift(a: i32) -> i32 {
298 // Change operator from == to != -----------------------------------------------
300 pub fn eq_to_uneq(a: i32) -> bool {
305 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
306 #[rustc_clean(cfg="cfail3")]
307 pub fn eq_to_uneq(a: i32) -> bool {
313 // Change operator from == to < ------------------------------------------------
315 pub fn eq_to_lt(a: i32) -> bool {
320 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
321 #[rustc_clean(cfg="cfail3")]
322 pub fn eq_to_lt(a: i32) -> bool {
328 // Change operator from == to > ------------------------------------------------
330 pub fn eq_to_gt(a: i32) -> bool {
335 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
336 #[rustc_clean(cfg="cfail3")]
337 pub fn eq_to_gt(a: i32) -> bool {
343 // Change operator from == to <= -----------------------------------------------
345 pub fn eq_to_le(a: i32) -> bool {
350 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
351 #[rustc_clean(cfg="cfail3")]
352 pub fn eq_to_le(a: i32) -> bool {
358 // Change operator from == to >= -----------------------------------------------
360 pub fn eq_to_ge(a: i32) -> bool {
365 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
366 #[rustc_clean(cfg="cfail3")]
367 pub fn eq_to_ge(a: i32) -> bool {
373 // Change type in cast expression ----------------------------------------------
375 pub fn type_cast(a: u8) -> u64 {
382 #[rustc_clean(except="HirBody,MirOptimized,MirValidated,TypeckTables", cfg="cfail2")]
383 #[rustc_clean(cfg="cfail3")]
384 pub fn type_cast(a: u8) -> u64 {
392 // Change value in cast expression ---------------------------------------------
394 pub fn value_cast(a: u32) -> i32 {
399 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
400 #[rustc_clean(cfg="cfail3")]
401 pub fn value_cast(a: u32) -> i32 {
407 // Change place in assignment --------------------------------------------------
409 pub fn place() -> i32 {
417 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
418 #[rustc_clean(cfg="cfail3")]
419 pub fn place() -> i32 {
428 // Change r-value in assignment ------------------------------------------------
430 pub fn rvalue() -> i32 {
437 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
438 #[rustc_clean(cfg="cfail3")]
439 pub fn rvalue() -> i32 {
447 // Change index into slice -----------------------------------------------------
449 pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 {
454 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
455 #[rustc_clean(cfg="cfail3")]
456 pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 {