]> git.proxmox.com Git - rustc.git/blame - src/test/ui/mir/issue-76740-copy-propagation.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / mir / issue-76740-copy-propagation.rs
CommitLineData
1b1a35ee
XL
1// Regression test for issue #76740.
2// run-pass
6a06907d 3// compile-flags: -Zmir-opt-level=4
1b1a35ee
XL
4
5#[derive(Copy, Clone)]
6pub struct V([usize; 4]);
7
8impl V {
9 fn new() -> Self {
10 V([0; 4])
11 }
12
13 #[inline(never)]
14 fn check(mut self) {
15 assert_eq!(self.0[0], 0);
16 self.0[0] = 1;
17 }
18}
19
20fn main() {
21 let v = V::new();
22 let mut i = 0;
23 while i != 10 {
24 // Copy propagation incorrectly assumed that Operand::Move does not
25 // mutate the local, and used the same v for each V::check call,
26 // rather than a copy.
27 v.check();
28 i += 1;
29 }
30}