]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/enum-bounds-check-derived-idx.rs
Rollup merge of #102227 - devnexen:solarish_get_path, r=m-ou-se
[rust.git] / src / test / 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     // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332
16     // CHECK: panic_bounds_check
17     buf[f as usize + 1]
18 }
19
20 // CHECK-LABEL: @lookup_dec
21 #[no_mangle]
22 pub fn lookup_dec(buf: &[u8; 5], f: Bar) -> u8 {
23     // FIXME: panic check can be removed by adding the assumes back after https://github.com/rust-lang/rust/pull/98332
24     // CHECK: panic_bounds_check
25     buf[f as usize - 1]
26 }