]>
git.proxmox.com Git - rustc.git/blob - src/test/incremental/hashes/unary_and_binary_exprs.rs
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.
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Z force-overflow-checks=off
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 #[rustc_metadata_clean(cfg="cfail2")]
38 #[rustc_metadata_clean(cfg="cfail3")]
39 pub fn const_negation() -> i32 {
45 // Change constant operand of bitwise not --------------------------------------
47 pub fn const_bitwise_not() -> i32 {
52 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
53 #[rustc_clean(cfg="cfail3")]
54 #[rustc_metadata_clean(cfg="cfail2")]
55 #[rustc_metadata_clean(cfg="cfail3")]
56 pub fn const_bitwise_not() -> i32 {
62 // Change variable operand of negation -----------------------------------------
64 pub fn var_negation(x
: i32, y
: i32) -> i32 {
69 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
70 #[rustc_clean(cfg="cfail3")]
71 #[rustc_metadata_clean(cfg="cfail2")]
72 #[rustc_metadata_clean(cfg="cfail3")]
73 pub fn var_negation(x
: i32, y
: i32) -> i32 {
79 // Change variable operand of bitwise not --------------------------------------
81 pub fn var_bitwise_not(x
: i32, y
: i32) -> i32 {
86 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
87 #[rustc_clean(cfg="cfail3")]
88 #[rustc_metadata_clean(cfg="cfail2")]
89 #[rustc_metadata_clean(cfg="cfail3")]
90 pub fn var_bitwise_not(x
: i32, y
: i32) -> i32 {
96 // Change variable operand of deref --------------------------------------------
98 pub fn var_deref(x
: &i32, y
: &i32) -> i32 {
103 #[rustc_clean(except="HirBody,MirOptimized,MirValidated,TypeckTables", cfg="cfail2")]
104 #[rustc_clean(cfg="cfail3")]
105 #[rustc_metadata_clean(cfg="cfail2")]
106 #[rustc_metadata_clean(cfg="cfail3")]
107 pub fn var_deref(x
: &i32, y
: &i32) -> i32 {
113 // Change first constant operand of addition -----------------------------------
115 pub fn first_const_add() -> i32 {
120 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
121 #[rustc_clean(cfg="cfail3")]
122 #[rustc_metadata_clean(cfg="cfail2")]
123 #[rustc_metadata_clean(cfg="cfail3")]
124 pub fn first_const_add() -> i32 {
130 // Change second constant operand of addition -----------------------------------
132 pub fn second_const_add() -> i32 {
137 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
138 #[rustc_clean(cfg="cfail3")]
139 #[rustc_metadata_clean(cfg="cfail2")]
140 #[rustc_metadata_clean(cfg="cfail3")]
141 pub fn second_const_add() -> i32 {
147 // Change first variable operand of addition -----------------------------------
149 pub fn first_var_add(a
: i32, b
: i32) -> i32 {
154 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
155 #[rustc_clean(cfg="cfail3")]
156 #[rustc_metadata_clean(cfg="cfail2")]
157 #[rustc_metadata_clean(cfg="cfail3")]
158 pub fn first_var_add(a
: i32, b
: i32) -> i32 {
164 // Change second variable operand of addition ----------------------------------
166 pub fn second_var_add(a
: i32, b
: i32) -> i32 {
171 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
172 #[rustc_clean(cfg="cfail3")]
173 #[rustc_metadata_clean(cfg="cfail2")]
174 #[rustc_metadata_clean(cfg="cfail3")]
175 pub fn second_var_add(a
: i32, b
: i32) -> i32 {
181 // Change operator from + to - -------------------------------------------------
183 pub fn plus_to_minus(a
: i32) -> i32 {
188 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
189 #[rustc_clean(cfg="cfail3")]
190 #[rustc_metadata_clean(cfg="cfail2")]
191 #[rustc_metadata_clean(cfg="cfail3")]
192 pub fn plus_to_minus(a
: i32) -> i32 {
198 // Change operator from + to * -------------------------------------------------
200 pub fn plus_to_mult(a
: i32) -> i32 {
205 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
206 #[rustc_clean(cfg="cfail3")]
207 #[rustc_metadata_clean(cfg="cfail2")]
208 #[rustc_metadata_clean(cfg="cfail3")]
209 pub fn plus_to_mult(a
: i32) -> i32 {
215 // Change operator from + to / -------------------------------------------------
217 pub fn plus_to_div(a
: i32) -> i32 {
222 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
223 #[rustc_clean(cfg="cfail3")]
224 #[rustc_metadata_clean(cfg="cfail2")]
225 #[rustc_metadata_clean(cfg="cfail3")]
226 pub fn plus_to_div(a
: i32) -> i32 {
232 // Change operator from + to % -------------------------------------------------
234 pub fn plus_to_mod(a
: i32) -> i32 {
239 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
240 #[rustc_clean(cfg="cfail3")]
241 #[rustc_metadata_clean(cfg="cfail2")]
242 #[rustc_metadata_clean(cfg="cfail3")]
243 pub fn plus_to_mod(a
: i32) -> i32 {
249 // Change operator from && to || -----------------------------------------------
251 pub fn and_to_or(a
: bool
, b
: bool
) -> bool
{
256 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
257 #[rustc_clean(cfg="cfail3")]
258 #[rustc_metadata_clean(cfg="cfail2")]
259 #[rustc_metadata_clean(cfg="cfail3")]
260 pub fn and_to_or(a
: bool
, b
: bool
) -> bool
{
266 // Change operator from & to | -------------------------------------------------
268 pub fn bitwise_and_to_bitwise_or(a
: i32) -> i32 {
273 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
274 #[rustc_clean(cfg="cfail3")]
275 #[rustc_metadata_clean(cfg="cfail2")]
276 #[rustc_metadata_clean(cfg="cfail3")]
277 pub fn bitwise_and_to_bitwise_or(a
: i32) -> i32 {
283 // Change operator from & to ^ -------------------------------------------------
285 pub fn bitwise_and_to_bitwise_xor(a
: i32) -> i32 {
290 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
291 #[rustc_clean(cfg="cfail3")]
292 #[rustc_metadata_clean(cfg="cfail2")]
293 #[rustc_metadata_clean(cfg="cfail3")]
294 pub fn bitwise_and_to_bitwise_xor(a
: i32) -> i32 {
300 // Change operator from & to << ------------------------------------------------
302 pub fn bitwise_and_to_lshift(a
: i32) -> i32 {
307 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
308 #[rustc_clean(cfg="cfail3")]
309 #[rustc_metadata_clean(cfg="cfail2")]
310 #[rustc_metadata_clean(cfg="cfail3")]
311 pub fn bitwise_and_to_lshift(a
: i32) -> i32 {
317 // Change operator from & to >> ------------------------------------------------
319 pub fn bitwise_and_to_rshift(a
: i32) -> i32 {
324 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
325 #[rustc_clean(cfg="cfail3")]
326 #[rustc_metadata_clean(cfg="cfail2")]
327 #[rustc_metadata_clean(cfg="cfail3")]
328 pub fn bitwise_and_to_rshift(a
: i32) -> i32 {
334 // Change operator from == to != -----------------------------------------------
336 pub fn eq_to_uneq(a
: i32) -> bool
{
341 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
342 #[rustc_clean(cfg="cfail3")]
343 #[rustc_metadata_clean(cfg="cfail2")]
344 #[rustc_metadata_clean(cfg="cfail3")]
345 pub fn eq_to_uneq(a
: i32) -> bool
{
351 // Change operator from == to < ------------------------------------------------
353 pub fn eq_to_lt(a
: i32) -> bool
{
358 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
359 #[rustc_clean(cfg="cfail3")]
360 #[rustc_metadata_clean(cfg="cfail2")]
361 #[rustc_metadata_clean(cfg="cfail3")]
362 pub fn eq_to_lt(a
: i32) -> bool
{
368 // Change operator from == to > ------------------------------------------------
370 pub fn eq_to_gt(a
: i32) -> bool
{
375 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
376 #[rustc_clean(cfg="cfail3")]
377 #[rustc_metadata_clean(cfg="cfail2")]
378 #[rustc_metadata_clean(cfg="cfail3")]
379 pub fn eq_to_gt(a
: i32) -> bool
{
385 // Change operator from == to <= -----------------------------------------------
387 pub fn eq_to_le(a
: i32) -> bool
{
392 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
393 #[rustc_clean(cfg="cfail3")]
394 #[rustc_metadata_clean(cfg="cfail2")]
395 #[rustc_metadata_clean(cfg="cfail3")]
396 pub fn eq_to_le(a
: i32) -> bool
{
402 // Change operator from == to >= -----------------------------------------------
404 pub fn eq_to_ge(a
: i32) -> bool
{
409 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
410 #[rustc_clean(cfg="cfail3")]
411 #[rustc_metadata_clean(cfg="cfail2")]
412 #[rustc_metadata_clean(cfg="cfail3")]
413 pub fn eq_to_ge(a
: i32) -> bool
{
419 // Change type in cast expression ----------------------------------------------
421 pub fn type_cast(a
: u8) -> u64 {
428 #[rustc_clean(except="HirBody,MirOptimized,MirValidated,TypeckTables", cfg="cfail2")]
429 #[rustc_clean(cfg="cfail3")]
430 #[rustc_metadata_clean(cfg="cfail2")]
431 #[rustc_metadata_clean(cfg="cfail3")]
432 pub fn type_cast(a
: u8) -> u64 {
440 // Change value in cast expression ---------------------------------------------
442 pub fn value_cast(a
: u32) -> i32 {
447 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
448 #[rustc_clean(cfg="cfail3")]
449 #[rustc_metadata_clean(cfg="cfail2")]
450 #[rustc_metadata_clean(cfg="cfail3")]
451 pub fn value_cast(a
: u32) -> i32 {
457 // Change l-value in assignment ------------------------------------------------
459 pub fn lvalue() -> i32 {
467 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
468 #[rustc_clean(cfg="cfail3")]
469 #[rustc_metadata_clean(cfg="cfail2")]
470 #[rustc_metadata_clean(cfg="cfail3")]
471 pub fn lvalue() -> i32 {
480 // Change r-value in assignment ------------------------------------------------
482 pub fn rvalue() -> i32 {
489 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
490 #[rustc_clean(cfg="cfail3")]
491 #[rustc_metadata_clean(cfg="cfail2")]
492 #[rustc_metadata_clean(cfg="cfail3")]
493 pub fn rvalue() -> i32 {
501 // Change index into slice -----------------------------------------------------
503 pub fn index_to_slice(s
: &[u8], i
: usize, j
: usize) -> u8 {
508 #[rustc_clean(except="HirBody,MirOptimized,MirValidated", cfg="cfail2")]
509 #[rustc_clean(cfg="cfail3")]
510 #[rustc_metadata_clean(cfg="cfail2")]
511 #[rustc_metadata_clean(cfg="cfail3")]
512 pub fn index_to_slice(s
: &[u8], i
: usize, j
: usize) -> u8 {