Skip to content

Commit b3c6583

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ compile-flags: -O
2+
// Test for #122600
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-NOT: alloca
16+
// CHECK-NOT: memcpy
17+
// CHECK-NEXT: store i8
18+
// CHECK-NEXT: ret
19+
let State::A(v) = s.read() else { std::hint::unreachable_unchecked() };
20+
s.write(State::B(v));
21+
}

0 commit comments

Comments
 (0)