diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 952877b9f1..55729a507f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,16 +92,15 @@ jobs: components: miri - name: CI job # To run the tests one item at a time for troubleshooting, use - # cargo --quiet test --lib -- --list | sed 's/: test$//' | MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-permissive-provenance -Zmiri-disable-weak-memory-emulation" xargs -n1 cargo miri test -p bevy_ecs --lib -- --exact + # cargo --quiet test --lib -- --list | sed 's/: test$//' | MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation" xargs -n1 cargo miri test -p bevy_ecs --lib -- --exact run: cargo miri test -p bevy_ecs env: # -Zrandomize-layout makes sure we dont rely on the layout of anything that might change RUSTFLAGS: -Zrandomize-layout # https://github.com/rust-lang/miri#miri--z-flags-and-environment-variables # -Zmiri-disable-isolation is needed because our executor uses `fastrand` which accesses system time. - # -Zmiri-permissive-provenance disables warnings against int2ptr casts (since those are used by once_cell) # -Zmiri-ignore-leaks is necessary because a bunch of tests don't join all threads before finishing. - MIRIFLAGS: -Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-permissive-provenance + MIRIFLAGS: -Zmiri-ignore-leaks -Zmiri-disable-isolation check-compiles: runs-on: ubuntu-latest diff --git a/crates/bevy_ptr/src/lib.rs b/crates/bevy_ptr/src/lib.rs index c9511bae16..bcfd060f01 100644 --- a/crates/bevy_ptr/src/lib.rs +++ b/crates/bevy_ptr/src/lib.rs @@ -13,7 +13,7 @@ use core::{ marker::PhantomData, mem::ManuallyDrop, num::NonZeroUsize, - ptr::NonNull, + ptr::{self, NonNull}, }; /// Used as a type argument to [`Ptr`], [`PtrMut`] and [`OwningPtr`] to specify that the pointer is aligned. @@ -539,7 +539,8 @@ pub const fn dangling_with_align(align: NonZeroUsize) -> NonNull { debug_assert!(align.is_power_of_two(), "Alignment must be power of two."); // SAFETY: The pointer will not be null, since it was created // from the address of a `NonZero`. - unsafe { NonNull::new_unchecked(align.get() as *mut u8) } + // TODO: use https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.with_addr once stabilised + unsafe { NonNull::new_unchecked(ptr::null_mut::().wrapping_add(align.get())) } } mod private {