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 1, 2024
1 parent c0e3298 commit b3c6583
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/codegen/ptr-discriminant-update.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ compile-flags: -O
// Test for #122600

#![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-NOT: alloca
// CHECK-NOT: memcpy
// 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 b3c6583

Please sign in to comment.