about summary refs log tree commit diff
path: root/tests/ui/codegen/nested-enum-match-optimization-15793.rs
blob: 420e3ad82b265386bcf415ab6b525fb8d0475637 (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
27
28
29
//! Regression test for https://github.com/rust-lang/rust/issues/15793

//@ run-pass
#![allow(dead_code)]

enum NestedEnum {
    First,
    Second,
    Third
}
enum Enum {
    Variant1(bool),
    Variant2(NestedEnum)
}

#[inline(never)]
fn foo(x: Enum) -> isize {
    match x {
        Enum::Variant1(true) => 1,
        Enum::Variant1(false) => 2,
        Enum::Variant2(NestedEnum::Second) => 3,
        Enum::Variant2(NestedEnum::Third) => 4,
        Enum::Variant2(NestedEnum::First) => 5
    }
}

fn main() {
    assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4);
}