Skip to content

Commit

Permalink
Rollup merge of rust-lang#128500 - clubby789:122600-test, r=Mark-Simu…
Browse files Browse the repository at this point in the history
…lacrum

Add test for updating enum discriminant through pointer

Closes rust-lang#122600
  • Loading branch information
matthiaskrgr authored Aug 4, 2024
2 parents 0e78361 + 8497800 commit 8453534
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 8453534

Please sign in to comment.