summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/lower_slice_len.rs
blob: 9c39c29fc4e4d61ea164fac582c87e868981808d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 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]);
}