Skip to content

Commit 12a11e2

Browse files
Actually check alignment in BlobVec test aligned_zst (#10885)
Do not rely on Miri. --------- Co-authored-by: James Liu <[email protected]>
1 parent 41db723 commit 12a11e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/bevy_ecs/src/storage/blob_vec.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ mod tests {
472472
use crate::{component::Component, ptr::OwningPtr, world::World};
473473

474474
use super::BlobVec;
475-
use std::{alloc::Layout, cell::RefCell, rc::Rc};
475+
use std::{alloc::Layout, cell::RefCell, mem, rc::Rc};
476476

477477
// SAFETY: The pointer points to a valid value of type `T` and it is safe to drop this value.
478478
unsafe fn drop_ptr<T>(x: OwningPtr<'_>) {
@@ -626,7 +626,9 @@ mod tests {
626626
let mut count = 0;
627627

628628
let mut q = world.query::<&Zst>();
629-
for &Zst in q.iter(&world) {
629+
for zst in q.iter(&world) {
630+
// Ensure that the references returned are properly aligned.
631+
assert_eq!(zst as *const Zst as usize % mem::align_of::<Zst>(), 0);
630632
count += 1;
631633
}
632634

0 commit comments

Comments
 (0)