rust/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCo...

139 lines
3.4 KiB
Rust

// MIR for `range_loop` after PreCodegen
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 _4: usize;
let mut _7: std::option::Option<usize>;
let mut _10: isize;
let mut _12: usize;
let mut _13: bool;
let mut _15: &impl Fn(usize, &T);
let mut _16: (usize, &T);
let _17: ();
let mut _18: usize;
scope 1 {
debug iter => std::ops::Range<usize>{ .0 => _4, .1 => _3, };
let _11: usize;
scope 2 {
debug i => _11;
let _14: &T;
scope 3 {
debug x => _14;
}
}
scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) {
debug self => &std::ops::Range<usize>{ .0 => _4, .1 => _3, };
scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) {
debug self => &std::ops::Range<usize>{ .0 => _4, .1 => _3, };
let mut _6: bool;
let _8: usize;
let mut _9: usize;
scope 7 {
debug old => _8;
scope 8 {
}
}
scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::lt) {
debug self => &_4;
debug other => &_3;
let mut _5: usize;
}
}
}
}
scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) {
debug self => std::ops::Range<usize>{ .0 => _18, .1 => _3, };
}
bb0: {
_3 = Len((*_1));
StorageLive(_4);
_4 = const 0_usize;
goto -> bb1;
}
bb1: {
StorageLive(_7);
StorageLive(_8);
StorageLive(_6);
StorageLive(_5);
_5 = _4;
_6 = Lt(move _5, _3);
StorageDead(_5);
switchInt(move _6) -> [0: bb2, otherwise: bb3];
}
bb2: {
_7 = Option::<usize>::None;
goto -> bb5;
}
bb3: {
_8 = _4;
StorageLive(_9);
_9 = <usize as Step>::forward_unchecked(_8, const 1_usize) -> [return: bb4, unwind: bb12];
}
bb4: {
_4 = move _9;
StorageDead(_9);
_7 = Option::<usize>::Some(_8);
goto -> bb5;
}
bb5: {
StorageDead(_6);
StorageDead(_8);
_10 = discriminant(_7);
switchInt(move _10) -> [0: bb6, 1: bb8, otherwise: bb11];
}
bb6: {
StorageDead(_7);
StorageDead(_4);
drop(_2) -> [return: bb7, unwind continue];
}
bb7: {
return;
}
bb8: {
_11 = ((_7 as Some).0: usize);
_12 = Len((*_1));
_13 = Lt(_11, _12);
assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb9, unwind: bb12];
}
bb9: {
_14 = &(*_1)[_11];
StorageLive(_15);
_15 = &_2;
StorageLive(_16);
_16 = (_11, _14);
_17 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _15, move _16) -> [return: bb10, unwind: bb12];
}
bb10: {
StorageDead(_16);
StorageDead(_15);
StorageDead(_7);
goto -> bb1;
}
bb11: {
unreachable;
}
bb12 (cleanup): {
drop(_2) -> [return: bb13, unwind terminate];
}
bb13 (cleanup): {
resume;
}
}