]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/enum-bounds-check-issue-13926.rs
Rollup merge of #100184 - Kixunil:stabilize_ptr_const_cast, r=m-ou-se
[rust.git] / src / test / codegen / enum-bounds-check-issue-13926.rs
1 // This test checks an optimization that is not guaranteed to work. This test case should not block
2 // a future LLVM update.
3 // compile-flags: -O
4
5 #![crate_type = "lib"]
6
7 #[repr(u8)]
8 pub enum Exception {
9     Low = 5,
10     High = 10,
11 }
12
13 // CHECK-LABEL: @access
14 #[no_mangle]
15 pub fn access(array: &[usize; 12], exc: Exception) -> usize {
16     // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332
17     // CHECK: panic_bounds_check
18     array[(exc as u8 - 4) as usize]
19 }