diff --git a/crates/bevy_ecs/src/bundle/mod.rs b/crates/bevy_ecs/src/bundle/mod.rs index b6a81ebd27328..f7cd9996b2853 100644 --- a/crates/bevy_ecs/src/bundle/mod.rs +++ b/crates/bevy_ecs/src/bundle/mod.rs @@ -1,3 +1,8 @@ +#![expect( + unsafe_op_in_unsafe_fn, + reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." +)] + //! Types for handling [`Bundle`]s. //! //! This module contains the [`Bundle`] trait and some other helper types. diff --git a/crates/bevy_ecs/src/entity/clone_entities.rs b/crates/bevy_ecs/src/entity/clone_entities.rs index 0f7105e0eb0ce..824775fb7b4b0 100644 --- a/crates/bevy_ecs/src/entity/clone_entities.rs +++ b/crates/bevy_ecs/src/entity/clone_entities.rs @@ -1,3 +1,8 @@ +#![expect( + unsafe_op_in_unsafe_fn, + reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." +)] + use crate::{ archetype::Archetype, bundle::{Bundle, BundleRemover, InsertMode}, diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 4c8763ad66f64..4c336a562bb51 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -1,7 +1,3 @@ -#![expect( - unsafe_op_in_unsafe_fn, - reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." -)] #![doc = include_str!("../README.md")] #![cfg_attr( any(docsrs, docsrs_dep), diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index b5c1b3d7d18a5..065eadd24db88 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -1,3 +1,8 @@ +#![expect( + unsafe_op_in_unsafe_fn, + reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." +)] + //! Contains APIs for retrieving component data from the world. mod access; diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 497b937c31f51..33bc8d0b80079 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -448,12 +448,21 @@ impl ExecutorState { } #[cfg(feature = "hotpatching")] - let hotpatch_tick = context - .environment - .world_cell - .get_resource_ref::() - .map(|r| r.last_changed()) - .unwrap_or_default(); + #[expect( + clippy::undocumented_unsafe_blocks, + reason = "This actually could result in UB if a system tries to mutate + `HotPatchChanges`. We allow this as the resource only exists with the `hotpatching` feature. + and `hotpatching` should never be enabled in release." + )] + #[cfg(feature = "hotpatching")] + let hotpatch_tick = unsafe { + context + .environment + .world_cell + .get_resource_ref::() + } + .map(|r| r.last_changed()) + .unwrap_or_default(); // can't borrow since loop mutably borrows `self` let mut ready_systems = core::mem::take(&mut self.ready_systems_copy); diff --git a/crates/bevy_ecs/src/storage/mod.rs b/crates/bevy_ecs/src/storage/mod.rs index 0584ae15c6738..084cca6bc8396 100644 --- a/crates/bevy_ecs/src/storage/mod.rs +++ b/crates/bevy_ecs/src/storage/mod.rs @@ -1,3 +1,8 @@ +#![expect( + unsafe_op_in_unsafe_fn, + reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." +)] + //! Storage layouts for ECS data. //! //! This module implements the low-level collections that store data in a [`World`]. These all offer minimal and often diff --git a/crates/bevy_ecs/src/system/combinator.rs b/crates/bevy_ecs/src/system/combinator.rs index 0ef463fc45e0d..ad10d2ddd8cf6 100644 --- a/crates/bevy_ecs/src/system/combinator.rs +++ b/crates/bevy_ecs/src/system/combinator.rs @@ -167,8 +167,6 @@ where input: SystemIn, world: &mut PrivateUnsafeWorldCell, ) -> Result { - #![deny(unsafe_op_in_unsafe_fn)] - // SAFETY: see comment on `Func::combine` call match (|| unsafe { system.validate_param_unsafe(world.0)?; diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 16af1523376e4..2a0498ffdcfdc 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -1,3 +1,8 @@ +#![expect( + unsafe_op_in_unsafe_fn, + reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." +)] + pub use crate::change_detection::{NonSend, NonSendMut, Res, ResMut}; use crate::{ archetype::Archetypes, diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index a4f49c7460a35..3f39865f8f34d 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1,3 +1,8 @@ +#![expect( + unsafe_op_in_unsafe_fn, + reason = "See #11590. To be removed once all applicable unsafe code has an unsafe block with a safety comment." +)] + //! Defines the [`World`] and APIs for accessing it directly. pub(crate) mod command_queue;