about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-05 05:40:21 +0200
committerGitHub <noreply@github.com>2024-08-05 05:40:21 +0200
commit3c8b25905ce638ef8144a13ed30c6a6349bb5c06 (patch)
tree3d034e185f72e8dca28eab6fb1c8cc3ee326a115
parente4367cec5ec622f0d79304e3ddbdf8628fa6d10c (diff)
parent8497800abde9214041e11f35efdbfa437f761001 (diff)
downloadrust-3c8b25905ce638ef8144a13ed30c6a6349bb5c06.tar.gz
rust-3c8b25905ce638ef8144a13ed30c6a6349bb5c06.zip
Rollup merge of #128500 - clubby789:122600-test, r=Mark-Simulacrum
Add test for updating enum discriminant through pointer

Closes #122600
-rw-r--r--tests/codegen/issues/issue-122600-ptr-discriminant-update.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs
new file mode 100644
index 00000000000..4b520a62069
--- /dev/null
+++ b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs
@@ -0,0 +1,19 @@
+//@ compile-flags: -O
+//@ min-llvm-version: 19
+
+#![crate_type = "lib"]
+
+pub enum State {
+    A([u8; 753]),
+    B([u8; 753]),
+}
+
+// CHECK-LABEL: @update
+#[no_mangle]
+pub unsafe fn update(s: *mut State) {
+    // CHECK-NEXT: start:
+    // CHECK-NEXT: store i8
+    // CHECK-NEXT: ret
+    let State::A(v) = s.read() else { std::hint::unreachable_unchecked() };
+    s.write(State::B(v));
+}