about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/no-bounds-check-after-assert-110971.rs
blob: aa4002f176da5f6b86399b801dfc3c365d878890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Tests that the slice access for `j` doesn't have a bounds check panic after
// being asserted as less than half of the slice length.

//@ compile-flags: -Copt-level=3

#![crate_type = "lib"]

// CHECK-LABEL: @check_only_assert_panic
#[no_mangle]
pub fn check_only_assert_panic(arr: &[u32], j: usize) -> u32 {
    // CHECK-NOT: panic_bounds_check
    assert!(j < arr.len() / 2);
    arr[j]
}