]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/issue-77812.rs
Ensure that --generate-link-to-definition is only used with HTML output and is unstable
[rust.git] / src / test / codegen / issue-77812.rs
1 // min-llvm-version: 12.0.0
2 // compile-flags: -O
3 #![crate_type = "lib"]
4
5 // Test that LLVM can eliminate the unreachable `Variant::Zero` branch.
6
7 #[derive(Copy, Clone, Eq, PartialEq)]
8 pub enum Variant {
9     Zero,
10     One,
11     Two,
12 }
13
14 extern {
15     fn exf1();
16     fn exf2();
17 }
18
19 pub static mut GLOBAL: Variant = Variant::Zero;
20
21 // CHECK-LABEL: @issue_77812
22 #[no_mangle]
23 pub unsafe fn issue_77812() {
24     let g = GLOBAL;
25     if g != Variant::Zero {
26         match g {
27             Variant::One => exf1(),
28             Variant::Two => exf2(),
29             // CHECK-NOT: panic
30             Variant::Zero => panic!(),
31         }
32     }
33 }