Skip to content

Commit e2ca47a

Browse files
author
oldmanmike
committed
Apply changes recommended in code review
Said code review and recommendations can be found here: #37610
1 parent 21814a5 commit e2ca47a

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

src/test/incremental/hashes/unary_and_binary_exprs.rs

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
// This test case tests the incremental compilation hash (ICH) implementation
13-
// for struct definitions.
13+
// for unary and binary expressions.
1414

1515
// The general pattern followed here is: Change one thing between rev1 and rev2
1616
// and make sure that the hash has changed, then change nothing between rev2 and
@@ -41,6 +41,7 @@ pub fn const_negation() -> i32 {
4141
}
4242

4343

44+
4445
// Change constant operand of bitwise not --------------------------------------
4546
#[cfg(cfail1)]
4647
pub fn const_bitwise_not() -> i32 {
@@ -57,9 +58,10 @@ pub fn const_bitwise_not() -> i32 {
5758
}
5859

5960

61+
6062
// Change variable operand of negation -----------------------------------------
6163
#[cfg(cfail1)]
62-
pub fn var_negation(x: i32) -> i32 {
64+
pub fn var_negation(x: i32, y: i32) -> i32 {
6365
-x
6466
}
6567

@@ -68,14 +70,15 @@ pub fn var_negation(x: i32) -> i32 {
6870
#[rustc_clean(label="Hir", cfg="cfails3")]
6971
#[rustc_metadata_dirty(cfg="cfail2")]
7072
#[rustc_metadata_clean(cfg="cfail3")]
71-
pub fn var_negation(y: i32) -> i32 {
73+
pub fn var_negation(x: i32, y: i32) -> i32 {
7274
-y
7375
}
7476

7577

78+
7679
// Change variable operand of bitwise not --------------------------------------
7780
#[cfg(cfail1)]
78-
pub fn var_bitwise_not(x: i32) -> i32 {
81+
pub fn var_bitwise_not(x: i32, y: i32) -> i32 {
7982
!x
8083
}
8184

@@ -84,14 +87,15 @@ pub fn var_bitwise_not(x: i32) -> i32 {
8487
#[rustc_clean(label="Hir", cfg="cfails3")]
8588
#[rustc_metadata_dirty(cfg="cfail2")]
8689
#[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 {
8891
!y
8992
}
9093

9194

95+
9296
// Change variable operand of deref --------------------------------------------
9397
#[cfg(cfail1)]
94-
pub fn var_deref(x: &i32) -> i32 {
98+
pub fn var_deref(x: &i32, y: &i32) -> i32 {
9599
*x
96100
}
97101

@@ -100,11 +104,12 @@ pub fn var_deref(x: &i32) -> i32 {
100104
#[rustc_clean(label="Hir", cfg="cfails3")]
101105
#[rustc_metadata_dirty(cfg="cfail2")]
102106
#[rustc_metadata_clean(cfg="cfail3")]
103-
pub fn var_deref(y: &i32) -> i32 {
107+
pub fn var_deref(x: &i32, y: &i32) -> i32 {
104108
*y
105109
}
106110

107111

112+
108113
// Change first constant operand of addition -----------------------------------
109114
#[cfg(cfail1)]
110115
pub fn first_const_add() -> i32 {
@@ -121,6 +126,7 @@ pub fn first_const_add() -> i32 {
121126
}
122127

123128

129+
124130
// Change second constant operand of addition -----------------------------------
125131
#[cfg(cfail1)]
126132
pub fn second_const_add() -> i32 {
@@ -137,9 +143,10 @@ pub fn second_const_add() -> i32 {
137143
}
138144

139145

146+
140147
// Change first variable operand of addition -----------------------------------
141148
#[cfg(cfail1)]
142-
pub fn first_var_add(a: i32) -> i32 {
149+
pub fn first_var_add(a: i32, b: i32) -> i32 {
143150
a + 2
144151
}
145152

@@ -148,14 +155,15 @@ pub fn first_var_add(a: i32) -> i32 {
148155
#[rustc_clean(label="Hir", cfg="cfails3")]
149156
#[rustc_metadata_dirty(cfg="cfail2")]
150157
#[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 {
152159
b + 3
153160
}
154161

155162

163+
156164
// Change second variable operand of addition ----------------------------------
157165
#[cfg(cfail1)]
158-
pub fn second_var_add(a: i32) -> i32 {
166+
pub fn second_var_add(a: i32, b: i32) -> i32 {
159167
1 + a
160168
}
161169

@@ -164,11 +172,12 @@ pub fn second_var_add(a: i32) -> i32 {
164172
#[rustc_clean(label="Hir", cfg="cfails3")]
165173
#[rustc_metadata_dirty(cfg="cfail2")]
166174
#[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 {
168176
1 + b
169177
}
170178

171179

180+
172181
// Change operator from + to - -------------------------------------------------
173182
#[cfg(cfail1)]
174183
pub fn plus_to_minus(a: i32) -> i32 {
@@ -185,6 +194,7 @@ pub fn plus_to_minus(a: i32) -> i32 {
185194
}
186195

187196

197+
188198
// Change operator from + to * -------------------------------------------------
189199
#[cfg(cfail1)]
190200
pub fn plus_to_mult(a: i32) -> i32 {
@@ -201,6 +211,7 @@ pub fn plus_to_mult(a: i32) -> i32 {
201211
}
202212

203213

214+
204215
// Change operator from + to / -------------------------------------------------
205216
#[cfg(cfail1)]
206217
pub fn plus_to_div(a: i32) -> i32 {
@@ -217,6 +228,7 @@ pub fn plus_to_div(a: i32) -> i32 {
217228
}
218229

219230

231+
220232
// Change operator from + to % -------------------------------------------------
221233
#[cfg(cfail1)]
222234
pub fn plus_to_mod(a: i32) -> i32 {
@@ -233,6 +245,7 @@ pub fn plus_to_mod(a: i32) -> i32 {
233245
}
234246

235247

248+
236249
// Change operator from && to || -----------------------------------------------
237250
#[cfg(cfail1)]
238251
pub fn and_to_or(a: bool, b: bool) -> bool {
@@ -444,7 +457,9 @@ pub fn value_cast(a: u32) -> i32 {
444457
// Change l-value in assignment ------------------------------------------------
445458
#[cfg(cfail1)]
446459
pub fn lvalue() -> i32 {
447-
let x = 10;
460+
let mut x = 10;
461+
let mut y = 11;
462+
x = 9;
448463
x
449464
}
450465

@@ -454,7 +469,9 @@ pub fn lvalue() -> i32 {
454469
#[rustc_metadata_dirty(cfg="cfail2")]
455470
#[rustc_metadata_clean(cfg="cfail3")]
456471
pub fn lvalue() -> i32 {
457-
let y = 10;
472+
let mut x = 10;
473+
let mut y = 11;
474+
x = 9;
458475
y
459476
}
460477

@@ -463,7 +480,9 @@ pub fn lvalue() -> i32 {
463480
// Change r-value in assignment ------------------------------------------------
464481
#[cfg(cfail1)]
465482
pub fn rvalue() -> i32 {
466-
let x = 10;
483+
let mut x = 10;
484+
let mut y = 11;
485+
x = 9;
467486
x
468487
}
469488

@@ -473,25 +492,25 @@ pub fn rvalue() -> i32 {
473492
#[rustc_metadata_dirty(cfg="cfail2")]
474493
#[rustc_metadata_clean(cfg="cfail3")]
475494
pub fn rvalue() -> i32 {
476-
let x = 11;
495+
let mut x = 10;
496+
let mut y = 11;
497+
x = 8;
477498
x
478499
}
479500

480501

481502

482503
// Change index into slice -----------------------------------------------------
483504
#[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]
487507
}
488508

489509
#[cfg(not(cfail1))]
490510
#[rustc_dirty(label="Hir", cfg="cfails2")]
491511
#[rustc_clean(label="Hir", cfg="cfails3")]
492512
#[rustc_metadata_dirty(cfg="cfail2")]
493513
#[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]
497516
}

0 commit comments

Comments
 (0)