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

114 lines
2.9 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 _9: std::option::Option<usize>;
let mut _11: usize;
let mut _12: bool;
let mut _14: &impl Fn(usize, &T);
let mut _15: (usize, &T);
let _16: ();
scope 1 {
debug ((iter: std::ops::Range<usize>).0: usize) => _4;
debug ((iter: std::ops::Range<usize>).1: usize) => _3;
let _10: usize;
scope 2 {
debug i => _10;
let _13: &T;
scope 3 {
debug x => _13;
}
}
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 _6: bool;
let _7: usize;
let mut _8: usize;
scope 7 {
}
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);
StorageLive(_4);
_4 = const 0_usize;
goto -> bb1;
}
bb1: {
StorageLive(_9);
StorageLive(_7);
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(_7);
StorageDead(_9);
StorageDead(_4);
drop(_2) -> [return: bb3, unwind continue];
}
bb3: {
return;
}
bb4: {
_7 = copy _4;
StorageLive(_8);
_8 = <usize as Step>::forward_unchecked(copy _7, const 1_usize) -> [return: bb5, unwind: bb8];
}
bb5: {
_4 = move _8;
StorageDead(_8);
_9 = Option::<usize>::Some(copy _7);
StorageDead(_6);
StorageDead(_7);
_10 = copy ((_9 as Some).0: usize);
_11 = Len((*_1));
_12 = Lt(copy _10, copy _11);
assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, copy _10) -> [success: bb6, unwind: bb8];
}
bb6: {
_13 = &(*_1)[_10];
StorageLive(_14);
_14 = &_2;
StorageLive(_15);
_15 = (copy _10, copy _13);
_16 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _14, move _15) -> [return: bb7, unwind: bb8];
}
bb7: {
StorageDead(_15);
StorageDead(_14);
StorageDead(_9);
goto -> bb1;
}
bb8 (cleanup): {
drop(_2) -> [return: bb9, unwind terminate(cleanup)];
}
bb9 (cleanup): {
resume;
}
}