]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/matches_u8.rs
Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk
[rust.git] / tests / mir-opt / matches_u8.rs
1 // unit-test: MatchBranchSimplification
2
3
4 // EMIT_MIR matches_u8.exhaustive_match.MatchBranchSimplification.diff
5 // EMIT_MIR matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff
6
7 pub enum E {
8     A,
9     B,
10 }
11
12 #[no_mangle]
13 pub fn exhaustive_match(e: E) -> u8 {
14     match e {
15         E::A => 0,
16         E::B => 1,
17     }
18 }
19
20 #[no_mangle]
21 pub fn exhaustive_match_i8(e: E) -> i8 {
22     match e {
23         E::A => 0,
24         E::B => 1,
25     }
26 }
27
28 fn main() {
29   assert_eq!(exhaustive_match(E::A), 0);
30   assert_eq!(exhaustive_match(E::B), 1);
31
32   assert_eq!(exhaustive_match_i8(E::A), 0);
33   assert_eq!(exhaustive_match_i8(E::B), 1);
34 }