]> git.lizzy.rs Git - rust.git/blob - tests/codegen/issue-77812.rs
Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup
[rust.git] / tests / codegen / issue-77812.rs
1 // compile-flags: -O
2 #![crate_type = "lib"]
3
4 // Test that LLVM can eliminate the unreachable `Variant::Zero` branch.
5
6 #[derive(Copy, Clone, Eq, PartialEq)]
7 pub enum Variant {
8     Zero,
9     One,
10     Two,
11 }
12
13 extern {
14     fn exf1();
15     fn exf2();
16 }
17
18 pub static mut GLOBAL: Variant = Variant::Zero;
19
20 // CHECK-LABEL: @issue_77812
21 #[no_mangle]
22 pub unsafe fn issue_77812() {
23     let g = GLOBAL;
24     if g != Variant::Zero {
25         match g {
26             Variant::One => exf1(),
27             Variant::Two => exf2(),
28             // CHECK-NOT: panic
29             Variant::Zero => panic!(),
30         }
31     }
32 }