about summary refs log tree commit diff
path: root/tests/ui/mir/enum/plain_no_data_break.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/mir/enum/plain_no_data_break.rs')
-rw-r--r--tests/ui/mir/enum/plain_no_data_break.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/mir/enum/plain_no_data_break.rs b/tests/ui/mir/enum/plain_no_data_break.rs
new file mode 100644
index 00000000000..db68e752479
--- /dev/null
+++ b/tests/ui/mir/enum/plain_no_data_break.rs
@@ -0,0 +1,14 @@
+//@ run-fail
+//@ compile-flags: -C debug-assertions
+//@ error-pattern: trying to construct an enum from an invalid value 0x1
+
+#[repr(u32)]
+#[allow(dead_code)]
+enum Foo {
+    A = 2,
+    B,
+}
+
+fn main() {
+    let _val: Foo = unsafe { std::mem::transmute::<u32, Foo>(1) };
+}