Actually check alignment in BlobVec test aligned_zst (#10885)

Do not rely on Miri.

---------

Co-authored-by: James Liu <contact@jamessliu.com>
This commit is contained in:
Stepan Koltsov 2023-12-13 02:36:49 +00:00 committed by GitHub
parent 41db723c5c
commit 12a11e2fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -472,7 +472,7 @@ mod tests {
use crate::{component::Component, ptr::OwningPtr, world::World};
use super::BlobVec;
use std::{alloc::Layout, cell::RefCell, rc::Rc};
use std::{alloc::Layout, cell::RefCell, mem, rc::Rc};
// SAFETY: The pointer points to a valid value of type `T` and it is safe to drop this value.
unsafe fn drop_ptr<T>(x: OwningPtr<'_>) {
@ -626,7 +626,9 @@ mod tests {
let mut count = 0;
let mut q = world.query::<&Zst>();
for &Zst in q.iter(&world) {
for zst in q.iter(&world) {
// Ensure that the references returned are properly aligned.
assert_eq!(zst as *const Zst as usize % mem::align_of::<Zst>(), 0);
count += 1;
}