about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2020-08-13 23:46:27 +0000
committerkadmin <julianknodt@gmail.com>2020-08-13 23:51:16 +0000
commitc0a811a24ee926431f6e8fea6984430138a5fee0 (patch)
tree00d900673660f96d0882025a00d8e65d18cd4779
parent5e3f1b148db5bfa27fee52464ae1f5d34c49d77b (diff)
downloadrust-c0a811a24ee926431f6e8fea6984430138a5fee0.tar.gz
rust-c0a811a24ee926431f6e8fea6984430138a5fee0.zip
Add regression test for matching on u8
-rw-r--r--src/test/mir-opt/matches_u8.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/mir-opt/matches_u8.rs b/src/test/mir-opt/matches_u8.rs
new file mode 100644
index 00000000000..15de01fa963
--- /dev/null
+++ b/src/test/mir-opt/matches_u8.rs
@@ -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);
+}