about summary refs log tree commit diff
path: root/tests/codegen/enum/enum-bounds-check.rs
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2023-07-29 17:07:57 -0700
committerJubilee Young <workingjubilee@gmail.com>2023-07-29 18:34:41 -0700
commit06711615aa5b3d45e77c1aa20df7de14ed16edf2 (patch)
tree4df501c658dc3b8e93cb434fdfc0f18514312907 /tests/codegen/enum/enum-bounds-check.rs
parent03a57254b56886c43464e23b74af484d11374623 (diff)
downloadrust-06711615aa5b3d45e77c1aa20df7de14ed16edf2.tar.gz
rust-06711615aa5b3d45e77c1aa20df7de14ed16edf2.zip
tests/codegen/enum-* -> enum/enum-*
Diffstat (limited to 'tests/codegen/enum/enum-bounds-check.rs')
-rw-r--r--tests/codegen/enum/enum-bounds-check.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/codegen/enum/enum-bounds-check.rs b/tests/codegen/enum/enum-bounds-check.rs
new file mode 100644
index 00000000000..17322d5911b
--- /dev/null
+++ b/tests/codegen/enum/enum-bounds-check.rs
@@ -0,0 +1,26 @@
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+pub enum Foo {
+    A, B
+}
+
+// CHECK-LABEL: @lookup
+#[no_mangle]
+pub fn lookup(buf: &[u8; 2], f: Foo) -> u8 {
+    // CHECK-NOT: panic_bounds_check
+    buf[f as usize]
+}
+
+pub enum Bar {
+    A = 2,
+    B = 3
+}
+
+// CHECK-LABEL: @lookup_unmodified
+#[no_mangle]
+pub fn lookup_unmodified(buf: &[u8; 5], f: Bar) -> u8 {
+    // CHECK-NOT: panic_bounds_check
+    buf[f as usize]
+}