rust/tests/mir-opt/lower_slice_len.rs
2023-04-06 10:08:07 +01:00

16 lines
326 B
Rust

// ignore-wasm32 compiled with panic=abort by default
// unit-test: LowerSliceLenCalls
// EMIT_MIR lower_slice_len.bound.LowerSliceLenCalls.diff
pub fn bound(index: usize, slice: &[u8]) -> u8 {
if index < slice.len() {
slice[index]
} else {
42
}
}
fn main() {
let _ = bound(1, &[1, 2, 3]);
}