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