Rollup merge of #128500 - clubby789:122600-test, r=Mark-Simulacrum

Add test for updating enum discriminant through pointer

Closes #122600
This commit is contained in:
Matthias Krüger 2024-08-05 05:40:21 +02:00 committed by GitHub
commit 3c8b25905c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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));
}