rust/tests/mir-opt/copy-prop/issue_107511.rs

15 lines
386 B
Rust
Raw Normal View History

2023-04-05 03:44:20 -05:00
// ignore-wasm32 compiled with panic=abort by default
2023-01-31 11:16:16 -06:00
// unit-test: CopyProp
// EMIT_MIR issue_107511.main.CopyProp.diff
fn main() {
let mut sum = 0;
let a = [0, 10, 20, 30];
// `i` is assigned in a loop. Only removing its `StorageDead` would mean that
// execution sees repeated `StorageLive`. This would be UB.
for i in 0..a.len() {
sum += a[i];
}
}