- // MIR for `main` before CopyProp + // MIR for `main` after CopyProp fn main() -> () { let mut _0: (); let mut _1: i32; let mut _3: std::ops::Range; let mut _4: std::ops::Range; let mut _5: usize; let mut _6: &[i32]; let mut _7: &[i32; 4]; let mut _9: (); let _10: (); let mut _11: std::option::Option; let mut _12: &mut std::ops::Range; let mut _13: &mut std::ops::Range; let mut _14: isize; let mut _15: !; let mut _17: i32; let _18: usize; let mut _19: usize; let mut _20: bool; scope 1 { debug sum => _1; let _2: [i32; 4]; scope 2 { debug a => _2; let mut _8: std::ops::Range; scope 3 { debug iter => _8; let _16: usize; scope 4 { debug i => _16; } } } } bb0: { StorageLive(_1); _1 = const 0_i32; StorageLive(_2); _2 = [const 0_i32, const 10_i32, const 20_i32, const 30_i32]; StorageLive(_3); StorageLive(_4); StorageLive(_5); StorageLive(_6); StorageLive(_7); _7 = &_2; _6 = move _7 as &[i32] (PointerCoercion(Unsize)); StorageDead(_7); _5 = core::slice::::len(move _6) -> [return: bb1, unwind unreachable]; } bb1: { StorageDead(_6); _4 = std::ops::Range:: { start: const 0_usize, end: move _5 }; StorageDead(_5); _3 = as IntoIterator>::into_iter(move _4) -> [return: bb2, unwind unreachable]; } bb2: { StorageDead(_4); StorageLive(_8); _8 = move _3; goto -> bb3; } bb3: { - StorageLive(_10); StorageLive(_11); StorageLive(_12); StorageLive(_13); _13 = &mut _8; _12 = &mut (*_13); _11 = as Iterator>::next(move _12) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_12); _14 = discriminant(_11); switchInt(move _14) -> [0: bb7, 1: bb6, otherwise: bb5]; } bb5: { unreachable; } bb6: { - StorageLive(_16); _16 = ((_11 as Some).0: usize); StorageLive(_17); - StorageLive(_18); - _18 = _16; _19 = Len(_2); - _20 = Lt(_18, _19); - assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> [success: bb8, unwind unreachable]; + _20 = Lt(_16, _19); + assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind unreachable]; } bb7: { _0 = const (); StorageDead(_13); StorageDead(_11); - StorageDead(_10); StorageDead(_8); StorageDead(_3); StorageDead(_2); StorageDead(_1); return; } bb8: { - _17 = _2[_18]; + _17 = _2[_16]; _1 = Add(_1, move _17); StorageDead(_17); - StorageDead(_18); - _10 = const (); - StorageDead(_16); StorageDead(_13); StorageDead(_11); - StorageDead(_10); - _9 = const (); goto -> bb3; } }