rust/tests/mir-opt/lower_slice_len.rs

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

18 lines
363 B
Rust
Raw Normal View History

// unit-test: LowerSliceLenCalls
2023-10-16 20:03:43 +00:00
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2021-06-20 14:09:42 +00:00
// EMIT_MIR lower_slice_len.bound.LowerSliceLenCalls.diff
pub fn bound(index: usize, slice: &[u8]) -> u8 {
2023-10-16 20:03:43 +00:00
// CHECK-LABEL: fn bound(
// CHECK-NOT: ::len(
2021-06-20 14:09:42 +00:00
if index < slice.len() {
slice[index]
} else {
42
}
}
fn main() {
let _ = bound(1, &[1, 2, 3]);
}