]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/copy-prop/issue_107511.rs
Rollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwco
[rust.git] / tests / mir-opt / copy-prop / issue_107511.rs
1 // unit-test: CopyProp
2
3 // EMIT_MIR issue_107511.main.CopyProp.diff
4 fn main() {
5     let mut sum = 0;
6     let a = [0, 10, 20, 30];
7
8     // `i` is assigned in a loop. Only removing its `StorageDead` would mean that
9     // execution sees repeated `StorageLive`. This would be UB.
10     for i in 0..a.len() {
11         sum += a[i];
12     }
13 }