]> git.lizzy.rs Git - rust.git/blob - tests/ui/mir/issue-76740-copy-propagation.rs
Rollup merge of #103418 - Aaron1011:macro-semicolon-future-incompat, r=davidtwco
[rust.git] / tests / ui / mir / issue-76740-copy-propagation.rs
1 // Regression test for issue #76740.
2 // run-pass
3 // compile-flags: -Zmir-opt-level=4
4
5 #[derive(Copy, Clone)]
6 pub struct V([usize; 4]);
7
8 impl 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
20 fn 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 }