]> git.lizzy.rs Git - rust.git/blob - tests/codegen/enum-bounds-check-derived-idx.rs
Merge commit '1d8491b120223272b13451fc81265aa64f7f4d5b' into sync-from-rustfmt
[rust.git] / tests / codegen / enum-bounds-check-derived-idx.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 pub enum Bar {
8     A = 1,
9     B = 3,
10 }
11
12 // CHECK-LABEL: @lookup_inc
13 #[no_mangle]
14 pub fn lookup_inc(buf: &[u8; 5], f: Bar) -> u8 {
15     // CHECK-NOT: panic_bounds_check
16     buf[f as usize + 1]
17 }
18
19 // CHECK-LABEL: @lookup_dec
20 #[no_mangle]
21 pub fn lookup_dec(buf: &[u8; 5], f: Bar) -> u8 {
22     // CHECK-NOT: panic_bounds_check
23     buf[f as usize - 1]
24 }