-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add unary and binary tests for incr-comp #37610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
|
||
// This test case tests the incremental compilation hash (ICH) implementation | ||
// for struct definitions. | ||
// for unary and binary expressions. | ||
|
||
// The general pattern followed here is: Change one thing between rev1 and rev2 | ||
// and make sure that the hash has changed, then change nothing between rev2 and | ||
|
@@ -41,6 +41,7 @@ pub fn const_negation() -> i32 { | |
} | ||
|
||
|
||
|
||
// Change constant operand of bitwise not -------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn const_bitwise_not() -> i32 { | ||
|
@@ -57,9 +58,10 @@ pub fn const_bitwise_not() -> i32 { | |
} | ||
|
||
|
||
|
||
// Change variable operand of negation ----------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn var_negation(x: i32) -> i32 { | ||
pub fn var_negation(x: i32, y: i32) -> i32 { | ||
-x | ||
} | ||
|
||
|
@@ -68,14 +70,15 @@ pub fn var_negation(x: i32) -> i32 { | |
#[rustc_clean(label="Hir", cfg="cfails3")] | ||
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn var_negation(y: i32) -> i32 { | ||
pub fn var_negation(x: i32, y: i32) -> i32 { | ||
-y | ||
} | ||
|
||
|
||
|
||
// Change variable operand of bitwise not -------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn var_bitwise_not(x: i32) -> i32 { | ||
pub fn var_bitwise_not(x: i32, y: i32) -> i32 { | ||
!x | ||
} | ||
|
||
|
@@ -84,14 +87,15 @@ pub fn var_bitwise_not(x: i32) -> i32 { | |
#[rustc_clean(label="Hir", cfg="cfails3")] | ||
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn var_bitwise_not(y: i32) -> i32 { | ||
pub fn var_bitwise_not(x: i32, y: i32) -> i32 { | ||
!y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
} | ||
|
||
|
||
|
||
// Change variable operand of deref -------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn var_deref(x: &i32) -> i32 { | ||
pub fn var_deref(x: &i32, y: &i32) -> i32 { | ||
*x | ||
} | ||
|
||
|
@@ -100,11 +104,12 @@ pub fn var_deref(x: &i32) -> i32 { | |
#[rustc_clean(label="Hir", cfg="cfails3")] | ||
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn var_deref(y: &i32) -> i32 { | ||
pub fn var_deref(x: &i32, y: &i32) -> i32 { | ||
*y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
} | ||
|
||
|
||
|
||
// Change first constant operand of addition ----------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn first_const_add() -> i32 { | ||
|
@@ -121,6 +126,7 @@ pub fn first_const_add() -> i32 { | |
} | ||
|
||
|
||
|
||
// Change second constant operand of addition ----------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn second_const_add() -> i32 { | ||
|
@@ -137,9 +143,10 @@ pub fn second_const_add() -> i32 { | |
} | ||
|
||
|
||
|
||
// Change first variable operand of addition ----------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn first_var_add(a: i32) -> i32 { | ||
pub fn first_var_add(a: i32, b: i32) -> i32 { | ||
a + 2 | ||
} | ||
|
||
|
@@ -148,14 +155,15 @@ pub fn first_var_add(a: i32) -> i32 { | |
#[rustc_clean(label="Hir", cfg="cfails3")] | ||
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn first_var_add(b: i32) -> i32 { | ||
pub fn first_var_add(a: i32, b: i32) -> i32 { | ||
b + 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
} | ||
|
||
|
||
|
||
// Change second variable operand of addition ---------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn second_var_add(a: i32) -> i32 { | ||
pub fn second_var_add(a: i32, b: i32) -> i32 { | ||
1 + a | ||
} | ||
|
||
|
@@ -164,11 +172,12 @@ pub fn second_var_add(a: i32) -> i32 { | |
#[rustc_clean(label="Hir", cfg="cfails3")] | ||
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn second_var_add(b: i32) -> i32 { | ||
pub fn second_var_add(a: i32, b: i32) -> i32 { | ||
1 + b | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
} | ||
|
||
|
||
|
||
// Change operator from + to - ------------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn plus_to_minus(a: i32) -> i32 { | ||
|
@@ -185,6 +194,7 @@ pub fn plus_to_minus(a: i32) -> i32 { | |
} | ||
|
||
|
||
|
||
// Change operator from + to * ------------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn plus_to_mult(a: i32) -> i32 { | ||
|
@@ -201,6 +211,7 @@ pub fn plus_to_mult(a: i32) -> i32 { | |
} | ||
|
||
|
||
|
||
// Change operator from + to / ------------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn plus_to_div(a: i32) -> i32 { | ||
|
@@ -217,6 +228,7 @@ pub fn plus_to_div(a: i32) -> i32 { | |
} | ||
|
||
|
||
|
||
// Change operator from + to % ------------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn plus_to_mod(a: i32) -> i32 { | ||
|
@@ -233,6 +245,7 @@ pub fn plus_to_mod(a: i32) -> i32 { | |
} | ||
|
||
|
||
|
||
// Change operator from && to || ----------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn and_to_or(a: bool, b: bool) -> bool { | ||
|
@@ -444,7 +457,9 @@ pub fn value_cast(a: u32) -> i32 { | |
// Change l-value in assignment ------------------------------------------------ | ||
#[cfg(cfail1)] | ||
pub fn lvalue() -> i32 { | ||
let x = 10; | ||
let mut x = 10; | ||
let mut y = 11; | ||
x = 9; | ||
x | ||
} | ||
|
||
|
@@ -454,7 +469,9 @@ pub fn lvalue() -> i32 { | |
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn lvalue() -> i32 { | ||
let y = 10; | ||
let mut x = 10; | ||
let mut y = 11; | ||
x = 9; | ||
y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to change the left-hand side of the assignment here, not the return value of the function. |
||
} | ||
|
||
|
@@ -463,7 +480,9 @@ pub fn lvalue() -> i32 { | |
// Change r-value in assignment ------------------------------------------------ | ||
#[cfg(cfail1)] | ||
pub fn rvalue() -> i32 { | ||
let x = 10; | ||
let mut x = 10; | ||
let mut y = 11; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
x = 9; | ||
x | ||
} | ||
|
||
|
@@ -473,25 +492,25 @@ pub fn rvalue() -> i32 { | |
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn rvalue() -> i32 { | ||
let x = 11; | ||
let mut x = 10; | ||
let mut y = 11; | ||
x = 8; | ||
x | ||
} | ||
|
||
|
||
|
||
// Change index into slice ----------------------------------------------------- | ||
#[cfg(cfail1)] | ||
pub fn index_to_slice() -> i32 { | ||
let xs = [1,2,3,4,5]; | ||
xs[1] | ||
pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 { | ||
s[i] | ||
} | ||
|
||
#[cfg(not(cfail1))] | ||
#[rustc_dirty(label="Hir", cfg="cfails2")] | ||
#[rustc_clean(label="Hir", cfg="cfails3")] | ||
#[rustc_metadata_dirty(cfg="cfail2")] | ||
#[rustc_metadata_clean(cfg="cfail3")] | ||
pub fn index_to_slice() -> i32 { | ||
let xs = &[1,2,3,4,5]; | ||
xs[1] | ||
pub fn index_to_slice(s: &[u8], i: usize, j: usize) -> u8 { | ||
s[j] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we have to make sure that
y
already exists in thecfail1
version (andx
still in the later version). Otherwise the hashing algorithm might miss the operand but we wouldn't know because the hash was changed anyway by renaming the function argument. Changing the operand should really be the only change.