blob: 5362598ca7c4350195bae9a7c8029df138b998b8 [file] [log] [blame]
Jubilee Young3c0c9b62025-02-08 19:45:40 -08001//@ compile-flags: -Copt-level=3
Ariel Ben-Yehuda45fe3a12016-10-04 19:24:49 +03002
3#![crate_type = "lib"]
4
5pub enum Foo {
Nicholas Nethercote72800d32024-05-29 14:11:20 +10006 A,
7 B,
Ariel Ben-Yehuda45fe3a12016-10-04 19:24:49 +03008}
9
10// CHECK-LABEL: @lookup
11#[no_mangle]
12pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 {
13 // CHECK-NOT: panic_bounds_check
14 buf[f as usize]
15}
Dániel Buga1d157ce2020-08-25 11:44:18 +020016
17pub enum Bar {
18 A = 2,
Nicholas Nethercote72800d32024-05-29 14:11:20 +100019 B = 3,
Dániel Buga1d157ce2020-08-25 11:44:18 +020020}
21
22// CHECK-LABEL: @lookup_unmodified
23#[no_mangle]
24pub fn lookup_unmodified(buf: &[u8; 5], f: Bar) -> u8 {
ouz-aa1672ad2022-10-26 17:50:11 +030025 // CHECK-NOT: panic_bounds_check
Dániel Buga1d157ce2020-08-25 11:44:18 +020026 buf[f as usize]
27}