]> git.lizzy.rs Git - rust.git/blob - tests/codegen/issue-73031.rs
Rollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum
[rust.git] / tests / codegen / issue-73031.rs
1 // compile-flags: -O
2 #![crate_type = "lib"]
3
4 // Test that LLVM can eliminate the unreachable `All::None` branch.
5
6 pub enum All {
7     None,
8     Foo,
9     Bar,
10 }
11
12 // CHECK-LABEL: @issue_73031
13 #[no_mangle]
14 pub fn issue_73031(a: &mut All, q: i32) -> i32 {
15     *a = if q == 5 {
16         All::Foo
17     } else {
18         All::Bar
19     };
20     match *a {
21         // CHECK-NOT: panic
22         All::None => panic!(),
23         All::Foo => 1,
24         All::Bar => 2,
25     }
26 }