]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/issue-73031.rs
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
[rust.git] / src / test / codegen / issue-73031.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 `All::None` branch.
6
7 pub enum All {
8     None,
9     Foo,
10     Bar,
11 }
12
13 // CHECK-LABEL: @issue_73031
14 #[no_mangle]
15 pub fn issue_73031(a: &mut All, q: i32) -> i32 {
16     *a = if q == 5 {
17         All::Foo
18     } else {
19         All::Bar
20     };
21     match *a {
22         // CHECK-NOT: panic
23         All::None => panic!(),
24         All::Foo => 1,
25         All::Bar => 2,
26     }
27 }