Skip to content

Commit

Permalink
Add regression test for matching on u8
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKnodt committed Aug 13, 2020
1 parent 5e3f1b1 commit c0a811a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/mir-opt/matches_u8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR matches_u8.exhaustive_match.MatchBranchSimplification.diff

pub enum E {
A,
B,
}

// This only breaks on u8's, but probably still have to test i8.
#[no_mangle]
pub fn exhaustive_match(e: E) -> u8 {
match e {
E::A => 0,
E::B => 1,
}
}

fn main() {
assert_eq!(exhaustive_match(E::A), 0);
assert_eq!(exhaustive_match(E::B), 1);
}

0 comments on commit c0a811a

Please sign in to comment.