diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2024-08-01 15:41:17 +0000 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2024-08-03 16:41:49 +0000 |
| commit | 8497800abde9214041e11f35efdbfa437f761001 (patch) | |
| tree | d042c1e8c07710af483c0ed3f1c477c79554f7f1 /tests/codegen | |
| parent | c0e32983f5b06a6f7d8cc776ccac71de6512ed6d (diff) | |
| download | rust-8497800abde9214041e11f35efdbfa437f761001.tar.gz rust-8497800abde9214041e11f35efdbfa437f761001.zip | |
Add test for updating enum discriminant through pointer
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/issues/issue-122600-ptr-discriminant-update.rs | 19 |
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)); +} |
