Skip to content

Commit

Permalink
Add test for updating enum discriminant through pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Aug 3, 2024
1 parent c0e3298 commit 8497800
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/codegen/issues/issue-122600-ptr-discriminant-update.rs
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit 8497800

Please sign in to comment.