]> git.lizzy.rs Git - rust.git/blob - tests/codegen/enum-bounds-check.rs
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24
[rust.git] / tests / codegen / enum-bounds-check.rs
1 // compile-flags: -O
2
3 #![crate_type = "lib"]
4
5 pub enum Foo {
6     A, B
7 }
8
9 // CHECK-LABEL: @lookup
10 #[no_mangle]
11 pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 {
12     // CHECK-NOT: panic_bounds_check
13     buf[f as usize]
14 }
15
16 pub enum Bar {
17     A = 2,
18     B = 3
19 }
20
21 // CHECK-LABEL: @lookup_unmodified
22 #[no_mangle]
23 pub fn lookup_unmodified(buf: &[u8; 5], f: Bar) -> u8 {
24     // CHECK-NOT: panic_bounds_check
25     buf[f as usize]
26 }