-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for updating enum discriminant through pointer
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//@ compile-flags: -O | ||
//@ min-llvm-version: 19 | ||
|
||
// 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)); | ||
} |