| // MIR for `range_loop` after runtime-optimized | |
| fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { | |
| debug slice => _1; | |
| debug f => _2; | |
| let mut _0: (); | |
| let mut _3: usize; | |
| let mut _8: std::option::Option<usize>; | |
| let mut _10: bool; | |
| let mut _12: &impl Fn(usize, &T); | |
| let mut _13: (usize, &T); | |
| let _14: (); | |
| scope 1 { | |
| debug ((iter: std::ops::Range<usize>).0: usize) => _4; | |
| debug ((iter: std::ops::Range<usize>).1: usize) => _3; | |
| let _9: usize; | |
| scope 2 { | |
| debug i => _9; | |
| let _11: &T; | |
| scope 3 { | |
| debug x => _11; | |
| } | |
| } | |
| scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { | |
| scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { | |
| let mut _4: usize; | |
| let mut _6: bool; | |
| let _7: usize; | |
| scope 7 { | |
| scope 9 (inlined <usize as Step>::forward_unchecked) { | |
| scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) { | |
| scope 11 (inlined core::ub_checks::check_language_ub) { | |
| scope 12 (inlined core::ub_checks::check_language_ub::runtime) { | |
| } | |
| } | |
| } | |
| } | |
| } | |
| scope 8 (inlined std::cmp::impls::<impl PartialOrd for usize>::lt) { | |
| let mut _5: usize; | |
| } | |
| } | |
| } | |
| } | |
| scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { | |
| } | |
| bb0: { | |
| _3 = PtrMetadata(copy _1); | |
| _4 = const 0_usize; | |
| goto -> bb1; | |
| } | |
| bb1: { | |
| StorageLive(_8); | |
| StorageLive(_6); | |
| StorageLive(_5); | |
| _5 = copy _4; | |
| _6 = Lt(move _5, copy _3); | |
| StorageDead(_5); | |
| switchInt(move _6) -> [0: bb2, otherwise: bb4]; | |
| } | |
| bb2: { | |
| StorageDead(_6); | |
| StorageDead(_8); | |
| drop(_2) -> [return: bb3, unwind continue]; | |
| } | |
| bb3: { | |
| return; | |
| } | |
| bb4: { | |
| StorageLive(_7); | |
| _7 = copy _4; | |
| _4 = AddUnchecked(copy _7, const 1_usize); | |
| _8 = Option::<usize>::Some(copy _7); | |
| StorageDead(_7); | |
| StorageDead(_6); | |
| StorageLive(_9); | |
| _9 = copy ((_8 as Some).0: usize); | |
| StorageLive(_11); | |
| _10 = Lt(copy _9, copy _3); | |
| assert(move _10, "index out of bounds: the length is {} but the index is {}", copy _3, copy _9) -> [success: bb5, unwind: bb7]; | |
| } | |
| bb5: { | |
| _11 = &(*_1)[_9]; | |
| StorageLive(_12); | |
| _12 = &_2; | |
| StorageLive(_13); | |
| _13 = (copy _9, copy _11); | |
| _14 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _12, move _13) -> [return: bb6, unwind: bb7]; | |
| } | |
| bb6: { | |
| StorageDead(_13); | |
| StorageDead(_12); | |
| StorageDead(_11); | |
| StorageDead(_9); | |
| StorageDead(_8); | |
| goto -> bb1; | |
| } | |
| bb7 (cleanup): { | |
| drop(_2) -> [return: bb8, unwind terminate(cleanup)]; | |
| } | |
| bb8 (cleanup): { | |
| resume; | |
| } | |
| } |