From 2d897380a06598e95529be7722144dd530379c7d Mon Sep 17 00:00:00 2001 From: eugineerd <70062110+eugineerd@users.noreply.github.com> Date: Sat, 21 Jun 2025 21:05:58 +0300 Subject: [PATCH] add missing `#[track_caller]` (#19769) # Objective I've noticed that some methods with `MaybeLocation::caller` don't have `#[track_caller]` which resulted in wrong locations reported when `track_location` is enabled. ## Solution add `#[track_caller]` to them. --- crates/bevy_ecs/src/system/commands/command.rs | 1 + crates/bevy_ecs/src/world/deferred_world.rs | 2 ++ crates/bevy_ecs/src/world/mod.rs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/crates/bevy_ecs/src/system/commands/command.rs b/crates/bevy_ecs/src/system/commands/command.rs index f3fc677e47..5f1f611856 100644 --- a/crates/bevy_ecs/src/system/commands/command.rs +++ b/crates/bevy_ecs/src/system/commands/command.rs @@ -223,6 +223,7 @@ pub fn trigger(event: impl Event) -> impl Command { } /// A [`Command`] that sends an [`EntityEvent`] for the given targets. +#[track_caller] pub fn trigger_targets( event: impl EntityEvent, targets: impl TriggerTargets + Send + Sync + 'static, diff --git a/crates/bevy_ecs/src/world/deferred_world.rs b/crates/bevy_ecs/src/world/deferred_world.rs index edf4b186a3..f59f9e88dc 100644 --- a/crates/bevy_ecs/src/world/deferred_world.rs +++ b/crates/bevy_ecs/src/world/deferred_world.rs @@ -96,6 +96,7 @@ impl<'w> DeferredWorld<'w> { /// If you do not need to ensure the above hooks are triggered, and your component /// is mutable, prefer using [`get_mut`](DeferredWorld::get_mut). #[inline] + #[track_caller] pub(crate) fn modify_component( &mut self, entity: Entity, @@ -129,6 +130,7 @@ impl<'w> DeferredWorld<'w> { /// You should prefer the typed [`modify_component`](DeferredWorld::modify_component) /// whenever possible. #[inline] + #[track_caller] pub(crate) fn modify_component_by_id( &mut self, entity: Entity, diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index fca9091dd5..798fd8ef60 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -1311,6 +1311,7 @@ impl World { /// # assert_eq!(world.get::(entity), Some(&Foo(true))); /// ``` #[inline] + #[track_caller] pub fn modify_component( &mut self, entity: Entity, @@ -1339,6 +1340,7 @@ impl World { /// You should prefer the typed [`modify_component`](World::modify_component) /// whenever possible. #[inline] + #[track_caller] pub fn modify_component_by_id( &mut self, entity: Entity,