2020-09-19 19:00:00 -05:00
|
|
|
// Regression test for issue #76740.
|
2020-09-18 19:14:27 -05:00
|
|
|
// run-pass
|
2021-03-04 07:21:13 -06:00
|
|
|
// compile-flags: -Zmir-opt-level=4
|
2020-09-19 19:00:00 -05:00
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct V([usize; 4]);
|
|
|
|
|
|
|
|
impl V {
|
|
|
|
fn new() -> Self {
|
|
|
|
V([0; 4])
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
fn check(mut self) {
|
|
|
|
assert_eq!(self.0[0], 0);
|
|
|
|
self.0[0] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let v = V::new();
|
|
|
|
let mut i = 0;
|
|
|
|
while i != 10 {
|
|
|
|
// Copy propagation incorrectly assumed that Operand::Move does not
|
|
|
|
// mutate the local, and used the same v for each V::check call,
|
|
|
|
// rather than a copy.
|
|
|
|
v.check();
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
}
|