about summary refs log tree commit diff
path: root/tests/codegen/issues/issue-110797-enum-jump-same.rs
blob: d52faef23ad8d33ad85e71b83332f2bd9630736b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//@ compile-flags: -O
//@ min-llvm-version: 18

#![crate_type = "lib"]

pub enum K {
    A(Box<[i32]>),
    B(Box<[u8]>),
    C(Box<[String]>),
    D(Box<[u16]>),
}

// CHECK-LABEL: @get_len
// CHECK-NEXT: {{.*}}:
// CHECK-NEXT: getelementptr inbounds
// CHECK-NEXT: load
// CHECK-NEXT: ret i64
#[no_mangle]
pub fn get_len(arg: &K) -> usize {
    match arg {
        K::A(ref lst) => lst.len(),
        K::B(ref lst) => lst.len(),
        K::C(ref lst) => lst.len(),
        K::D(ref lst) => lst.len(),
    }
}