Skip to content

Commit 8497800

Browse files
committed
Add test for updating enum discriminant through pointer
1 parent c0e3298 commit 8497800

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: -O
2+
//@ min-llvm-version: 19
3+
4+
#![crate_type = "lib"]
5+
6+
pub enum State {
7+
A([u8; 753]),
8+
B([u8; 753]),
9+
}
10+
11+
// CHECK-LABEL: @update
12+
#[no_mangle]
13+
pub unsafe fn update(s: *mut State) {
14+
// CHECK-NEXT: start:
15+
// CHECK-NEXT: store i8
16+
// CHECK-NEXT: ret
17+
let State::A(v) = s.read() else { std::hint::unreachable_unchecked() };
18+
s.write(State::B(v));
19+
}

0 commit comments

Comments
 (0)