about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/issue-116878.rs
blob: daf46c8bb554a017fff34760af7f4cd13efe1580 (plain)
1
2
3
4
5
6
7
8
9
10
11
//@ compile-flags: -Copt-level=3
#![crate_type = "lib"]

/// Make sure no bounds checks are emitted after a `get_unchecked`.
// CHECK-LABEL: @unchecked_slice_no_bounds_check
#[no_mangle]
pub unsafe fn unchecked_slice_no_bounds_check(s: &[u8]) -> u8 {
    let a = *s.get_unchecked(1);
    // CHECK-NOT: panic_bounds_check
    a + s[0]
}