10
10
11
11
12
12
// This test case tests the incremental compilation hash (ICH) implementation
13
- // for struct definitions .
13
+ // for unary and binary expressions .
14
14
15
15
// The general pattern followed here is: Change one thing between rev1 and rev2
16
16
// and make sure that the hash has changed, then change nothing between rev2 and
@@ -41,6 +41,7 @@ pub fn const_negation() -> i32 {
41
41
}
42
42
43
43
44
+
44
45
// Change constant operand of bitwise not --------------------------------------
45
46
#[ cfg( cfail1) ]
46
47
pub fn const_bitwise_not ( ) -> i32 {
@@ -57,9 +58,10 @@ pub fn const_bitwise_not() -> i32 {
57
58
}
58
59
59
60
61
+
60
62
// Change variable operand of negation -----------------------------------------
61
63
#[ cfg( cfail1) ]
62
- pub fn var_negation ( x : i32 ) -> i32 {
64
+ pub fn var_negation ( x : i32 , y : i32 ) -> i32 {
63
65
-x
64
66
}
65
67
@@ -68,14 +70,15 @@ pub fn var_negation(x: i32) -> i32 {
68
70
#[ rustc_clean( label="Hir" , cfg="cfails3" ) ]
69
71
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
70
72
#[ rustc_metadata_clean( cfg="cfail3" ) ]
71
- pub fn var_negation ( y : i32 ) -> i32 {
73
+ pub fn var_negation ( x : i32 , y : i32 ) -> i32 {
72
74
-y
73
75
}
74
76
75
77
78
+
76
79
// Change variable operand of bitwise not --------------------------------------
77
80
#[ cfg( cfail1) ]
78
- pub fn var_bitwise_not ( x : i32 ) -> i32 {
81
+ pub fn var_bitwise_not ( x : i32 , y : i32 ) -> i32 {
79
82
!x
80
83
}
81
84
@@ -84,14 +87,15 @@ pub fn var_bitwise_not(x: i32) -> i32 {
84
87
#[ rustc_clean( label="Hir" , cfg="cfails3" ) ]
85
88
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
86
89
#[ rustc_metadata_clean( cfg="cfail3" ) ]
87
- pub fn var_bitwise_not ( y : i32 ) -> i32 {
90
+ pub fn var_bitwise_not ( x : i32 , y : i32 ) -> i32 {
88
91
!y
89
92
}
90
93
91
94
95
+
92
96
// Change variable operand of deref --------------------------------------------
93
97
#[ cfg( cfail1) ]
94
- pub fn var_deref ( x : & i32 ) -> i32 {
98
+ pub fn var_deref ( x : & i32 , y : & i32 ) -> i32 {
95
99
* x
96
100
}
97
101
@@ -100,11 +104,12 @@ pub fn var_deref(x: &i32) -> i32 {
100
104
#[ rustc_clean( label="Hir" , cfg="cfails3" ) ]
101
105
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
102
106
#[ rustc_metadata_clean( cfg="cfail3" ) ]
103
- pub fn var_deref ( y : & i32 ) -> i32 {
107
+ pub fn var_deref ( x : & i32 , y : & i32 ) -> i32 {
104
108
* y
105
109
}
106
110
107
111
112
+
108
113
// Change first constant operand of addition -----------------------------------
109
114
#[ cfg( cfail1) ]
110
115
pub fn first_const_add ( ) -> i32 {
@@ -121,6 +126,7 @@ pub fn first_const_add() -> i32 {
121
126
}
122
127
123
128
129
+
124
130
// Change second constant operand of addition -----------------------------------
125
131
#[ cfg( cfail1) ]
126
132
pub fn second_const_add ( ) -> i32 {
@@ -137,9 +143,10 @@ pub fn second_const_add() -> i32 {
137
143
}
138
144
139
145
146
+
140
147
// Change first variable operand of addition -----------------------------------
141
148
#[ cfg( cfail1) ]
142
- pub fn first_var_add ( a : i32 ) -> i32 {
149
+ pub fn first_var_add ( a : i32 , b : i32 ) -> i32 {
143
150
a + 2
144
151
}
145
152
@@ -148,14 +155,15 @@ pub fn first_var_add(a: i32) -> i32 {
148
155
#[ rustc_clean( label="Hir" , cfg="cfails3" ) ]
149
156
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
150
157
#[ rustc_metadata_clean( cfg="cfail3" ) ]
151
- pub fn first_var_add ( b : i32 ) -> i32 {
158
+ pub fn first_var_add ( a : i32 , b : i32 ) -> i32 {
152
159
b + 3
153
160
}
154
161
155
162
163
+
156
164
// Change second variable operand of addition ----------------------------------
157
165
#[ cfg( cfail1) ]
158
- pub fn second_var_add ( a : i32 ) -> i32 {
166
+ pub fn second_var_add ( a : i32 , b : i32 ) -> i32 {
159
167
1 + a
160
168
}
161
169
@@ -164,11 +172,12 @@ pub fn second_var_add(a: i32) -> i32 {
164
172
#[ rustc_clean( label="Hir" , cfg="cfails3" ) ]
165
173
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
166
174
#[ rustc_metadata_clean( cfg="cfail3" ) ]
167
- pub fn second_var_add ( b : i32 ) -> i32 {
175
+ pub fn second_var_add ( a : i32 , b : i32 ) -> i32 {
168
176
1 + b
169
177
}
170
178
171
179
180
+
172
181
// Change operator from + to - -------------------------------------------------
173
182
#[ cfg( cfail1) ]
174
183
pub fn plus_to_minus ( a : i32 ) -> i32 {
@@ -185,6 +194,7 @@ pub fn plus_to_minus(a: i32) -> i32 {
185
194
}
186
195
187
196
197
+
188
198
// Change operator from + to * -------------------------------------------------
189
199
#[ cfg( cfail1) ]
190
200
pub fn plus_to_mult ( a : i32 ) -> i32 {
@@ -201,6 +211,7 @@ pub fn plus_to_mult(a: i32) -> i32 {
201
211
}
202
212
203
213
214
+
204
215
// Change operator from + to / -------------------------------------------------
205
216
#[ cfg( cfail1) ]
206
217
pub fn plus_to_div ( a : i32 ) -> i32 {
@@ -217,6 +228,7 @@ pub fn plus_to_div(a: i32) -> i32 {
217
228
}
218
229
219
230
231
+
220
232
// Change operator from + to % -------------------------------------------------
221
233
#[ cfg( cfail1) ]
222
234
pub fn plus_to_mod ( a : i32 ) -> i32 {
@@ -233,6 +245,7 @@ pub fn plus_to_mod(a: i32) -> i32 {
233
245
}
234
246
235
247
248
+
236
249
// Change operator from && to || -----------------------------------------------
237
250
#[ cfg( cfail1) ]
238
251
pub fn and_to_or ( a : bool , b : bool ) -> bool {
@@ -444,7 +457,9 @@ pub fn value_cast(a: u32) -> i32 {
444
457
// Change l-value in assignment ------------------------------------------------
445
458
#[ cfg( cfail1) ]
446
459
pub fn lvalue ( ) -> i32 {
447
- let x = 10 ;
460
+ let mut x = 10 ;
461
+ let mut y = 11 ;
462
+ x = 9 ;
448
463
x
449
464
}
450
465
@@ -454,7 +469,9 @@ pub fn lvalue() -> i32 {
454
469
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
455
470
#[ rustc_metadata_clean( cfg="cfail3" ) ]
456
471
pub fn lvalue ( ) -> i32 {
457
- let y = 10 ;
472
+ let mut x = 10 ;
473
+ let mut y = 11 ;
474
+ x = 9 ;
458
475
y
459
476
}
460
477
@@ -463,7 +480,9 @@ pub fn lvalue() -> i32 {
463
480
// Change r-value in assignment ------------------------------------------------
464
481
#[ cfg( cfail1) ]
465
482
pub fn rvalue ( ) -> i32 {
466
- let x = 10 ;
483
+ let mut x = 10 ;
484
+ let mut y = 11 ;
485
+ x = 9 ;
467
486
x
468
487
}
469
488
@@ -473,25 +492,25 @@ pub fn rvalue() -> i32 {
473
492
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
474
493
#[ rustc_metadata_clean( cfg="cfail3" ) ]
475
494
pub fn rvalue ( ) -> i32 {
476
- let x = 11 ;
495
+ let mut x = 10 ;
496
+ let mut y = 11 ;
497
+ x = 8 ;
477
498
x
478
499
}
479
500
480
501
481
502
482
503
// Change index into slice -----------------------------------------------------
483
504
#[ cfg( cfail1) ]
484
- pub fn index_to_slice ( ) -> i32 {
485
- let xs = [ 1 , 2 , 3 , 4 , 5 ] ;
486
- xs[ 1 ]
505
+ pub fn index_to_slice ( s : & [ u8 ] , i : usize , j : usize ) -> u8 {
506
+ s[ i]
487
507
}
488
508
489
509
#[ cfg( not( cfail1) ) ]
490
510
#[ rustc_dirty( label="Hir" , cfg="cfails2" ) ]
491
511
#[ rustc_clean( label="Hir" , cfg="cfails3" ) ]
492
512
#[ rustc_metadata_dirty( cfg="cfail2" ) ]
493
513
#[ rustc_metadata_clean( cfg="cfail3" ) ]
494
- pub fn index_to_slice ( ) -> i32 {
495
- let xs = & [ 1 , 2 , 3 , 4 , 5 ] ;
496
- xs[ 1 ]
514
+ pub fn index_to_slice ( s : & [ u8 ] , i : usize , j : usize ) -> u8 {
515
+ s[ j]
497
516
}
0 commit comments