rust/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.5 KiB
Diff
Raw Normal View History

2021-10-06 15:53:11 +00:00
- // MIR for `array_bound` before NormalizeArrayLen
+ // MIR for `array_bound` after NormalizeArrayLen
fn array_bound(_1: usize, _2: &[u8; N]) -> u8 {
2023-06-06 13:47:00 +00:00
debug index => _1;
debug slice => _2;
let mut _0: u8;
let mut _3: bool;
let mut _4: usize;
let mut _5: usize;
let mut _6: &[u8];
let mut _7: &[u8; N];
let _8: usize;
let mut _9: usize;
let mut _10: bool;
2021-10-06 15:53:11 +00:00
bb0: {
2023-06-06 13:47:00 +00:00
StorageLive(_3);
StorageLive(_4);
_4 = _1;
StorageLive(_5);
StorageLive(_6);
StorageLive(_7);
_7 = &(*_2);
_6 = move _7 as &[u8] (PointerCoercion(Unsize));
2023-06-06 13:47:00 +00:00
StorageDead(_7);
- _5 = Len((*_6));
+ _5 = const N;
goto -> bb1;
2021-10-06 15:53:11 +00:00
}
bb1: {
2023-06-06 13:47:00 +00:00
StorageDead(_6);
_3 = Lt(move _4, move _5);
StorageDead(_5);
StorageDead(_4);
switchInt(move _3) -> [0: bb4, otherwise: bb2];
2021-10-06 15:53:11 +00:00
}
bb2: {
2023-06-06 13:47:00 +00:00
StorageLive(_8);
_8 = _1;
_9 = Len((*_2));
_10 = Lt(_8, _9);
2023-06-23 16:53:09 +00:00
assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue];
2021-10-06 15:53:11 +00:00
}
bb3: {
2023-06-06 13:47:00 +00:00
_0 = (*_2)[_8];
StorageDead(_8);
goto -> bb5;
2021-10-06 15:53:11 +00:00
}
bb4: {
2023-06-06 13:47:00 +00:00
_0 = const 42_u8;
goto -> bb5;
2021-10-06 15:53:11 +00:00
}
bb5: {
2023-06-06 13:47:00 +00:00
StorageDead(_3);
return;
2021-10-06 15:53:11 +00:00
}
}