diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 6df15e84c7492..58859fd88eef7 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -130,6 +130,7 @@ const _: () = { type Item<'w, 's> = Commands<'w, 's>; + #[track_caller] fn init_state(world: &mut World) -> Self::State { FetchState { state: <__StructFieldsAlias<'_, '_> as bevy_ecs::system::SystemParam>::init_state( @@ -193,6 +194,7 @@ const _: () = { } #[inline] + #[track_caller] unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &bevy_ecs::system::SystemMeta, diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index cc7009c1759b8..ab753eb9a4d54 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -286,6 +286,7 @@ all_tuples!( impl SystemState { /// Creates a new [`SystemState`] with default state. + #[track_caller] pub fn new(world: &mut World) -> Self { let mut meta = SystemMeta::new::(); meta.last_run = world.change_tick().relative_to(Tick::MAX); @@ -362,6 +363,7 @@ impl SystemState { /// Retrieve the mutable [`SystemParam`] values. #[inline] + #[track_caller] pub fn get_mut<'w, 's>(&'s mut self, world: &'w mut World) -> SystemParamItem<'w, 's, Param> { self.validate_world(world.id()); // SAFETY: World is uniquely borrowed and matches the World this SystemState was created with. @@ -421,6 +423,7 @@ impl SystemState { /// access is safe in the context of global [`World`] access. The passed-in [`World`] _must_ be the [`World`] the [`SystemState`] was /// created with. #[inline] + #[track_caller] pub unsafe fn get_unchecked<'w, 's>( &'s mut self, world: UnsafeWorldCell<'w>, @@ -435,6 +438,7 @@ impl SystemState { /// access is safe in the context of global [`World`] access. The passed-in [`World`] _must_ be the [`World`] the [`SystemState`] was /// created with. #[inline] + #[track_caller] unsafe fn fetch<'w, 's>( &'s mut self, world: UnsafeWorldCell<'w>, diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 2a0498ffdcfdc..b59698651a9b7 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -1336,6 +1336,7 @@ unsafe impl SystemParam for Deferred<'_, T> { type State = SyncCell; type Item<'w, 's> = Deferred<'s, T>; + #[track_caller] fn init_state(world: &mut World) -> Self::State { SyncCell::new(T::from_world(world)) } @@ -2171,6 +2172,7 @@ macro_rules! impl_system_param_tuple { type Item<'w, 's> = ($($param::Item::<'w, 's>,)*); #[inline] + #[track_caller] fn init_state(world: &mut World) -> Self::State { ($($param::init_state(world),)*) } @@ -2216,6 +2218,7 @@ macro_rules! impl_system_param_tuple { } #[inline] + #[track_caller] unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &SystemMeta, diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index efd33e6de3e82..8157b03a61afc 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -3829,6 +3829,7 @@ pub trait FromWorld { impl FromWorld for T { /// Creates `Self` using [`default()`](`Default::default`). + #[track_caller] fn from_world(_world: &mut World) -> Self { T::default() }