Skip to content

Commit 06e6f3b

Browse files
committed
explicit alignment assertion
1 parent 3ddaa2d commit 06e6f3b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

sdk/pinocchio/src/sysvars/slot_hashes/test_std.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//! Tests that rely on the `std` feature (host-only helpers, alloc, etc.).
22
33
use super::*;
4-
use crate::{
5-
account_info::{Account, AccountInfo},
6-
pubkey::Pubkey,
7-
};
4+
use crate::account_info::{Account, AccountInfo};
85
use core::ptr;
96
extern crate std;
107
use super::test_utils::*;

sdk/pinocchio/src/sysvars/slot_hashes/test_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ pub unsafe fn make_account_info(
124124
let total = hdr_size + data.len();
125125
let words = (total + 7) / 8;
126126
let mut backing: Vec<u64> = std::vec![0u64; words];
127+
assert!(
128+
mem::align_of::<u64>() >= mem::align_of::<AccountLayout>(),
129+
"`backing` should be properly aligned to store an `AccountLayout` instance"
130+
);
127131

128132
let hdr_ptr = backing.as_mut_ptr() as *mut AccountLayout;
129133
ptr::write(

0 commit comments

Comments
 (0)