Skip to content

Commit 468791f

Browse files
add comment & fix errors
1 parent e69d6a9 commit 468791f

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

crates/bevy_ecs/src/bundle.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,19 +1217,6 @@ impl<'w> BundleSpawner<'w> {
12171217
&mut self,
12181218
entity: Entity,
12191219
bundle: T,
1220-
) -> EntityLocation {
1221-
self.spawn_non_existent_with_caller(
1222-
entity,
1223-
bundle,
1224-
#[cfg(feature = "track_change_detection")]
1225-
Location::caller(),
1226-
)
1227-
}
1228-
1229-
pub(crate) unsafe fn spawn_non_existent_with_caller<T: DynamicBundle>(
1230-
&mut self,
1231-
entity: Entity,
1232-
bundle: T,
12331220
#[cfg(feature = "track_change_detection")] caller: &'static Location<'static>,
12341221
) -> EntityLocation {
12351222
// SAFETY: We do not make any structural changes to the archetype graph through self.world so these pointers always remain valid
@@ -1317,7 +1304,7 @@ impl<'w> BundleSpawner<'w> {
13171304
let entity = self.entities().alloc();
13181305
// SAFETY: entity is allocated (but non-existent), `T` matches this BundleInfo's type
13191306
unsafe {
1320-
self.spawn_non_existent_with_caller(
1307+
self.spawn_non_existent(
13211308
entity,
13221309
bundle,
13231310
#[cfg(feature = "track_change_detection")]

crates/bevy_ecs/src/component.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ pub enum StorageType {
493493
SparseSet,
494494
}
495495

496-
/// The type used for [`Component`] lifecycle hooks such as `on_add`, `on_insert` or `on_remove`
496+
/// The type used for [`Component`] lifecycle hooks such as `on_add`, `on_insert` or `on_remove`.
497+
/// The caller location is `Some` if the `track_change_detection` feature is enabled.
497498
pub type ComponentHook =
498499
for<'w> fn(DeferredWorld<'w>, Entity, ComponentId, Option<&'static Location<'static>>);
499500

crates/bevy_ecs/src/observer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ mod tests {
14081408
world.flush_commands();
14091409
}
14101410

1411+
#[test]
14111412
fn observer_triggered_components() {
14121413
#[derive(Resource, Default)]
14131414
struct Counter(HashMap<ComponentId, usize>);

crates/bevy_ecs/src/world/entity_ref.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ impl<'w> EntityWorldMut<'w> {
18131813
)
18141814
}
18151815

1816-
pub fn remove_with_requires_with_caller<T: Bundle>(
1816+
pub(crate) fn remove_with_requires_with_caller<T: Bundle>(
18171817
&mut self,
18181818
#[cfg(feature = "track_change_detection")] caller: &'static Location<'static>,
18191819
) -> &mut Self {
@@ -3864,8 +3864,7 @@ unsafe impl DynamicComponentFetch for &'_ HashSet<ComponentId> {
38643864
#[cfg(test)]
38653865
mod tests {
38663866
use bevy_ptr::{OwningPtr, Ptr};
3867-
use core::panic::AssertUnwindSafe;
3868-
use std::panic::Location;
3867+
use core::panic::{AssertUnwindSafe, Location};
38693868

38703869
use crate::{
38713870
self as bevy_ecs,

crates/bevy_ecs/src/world/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ impl World {
13671367
let mut bundle_spawner = BundleSpawner::new::<B>(self, change_tick);
13681368
// SAFETY: bundle's type matches `bundle_info`, entity is allocated but non-existent
13691369
unsafe {
1370-
bundle_spawner.spawn_non_existent_with_caller(
1370+
bundle_spawner.spawn_non_existent(
13711371
entity,
13721372
bundle,
13731373
#[cfg(feature = "track_change_detection")]
@@ -2511,7 +2511,7 @@ impl World {
25112511
if let SpawnOrInsert::Spawn(ref mut spawner) = spawn_or_insert {
25122512
// SAFETY: `entity` is allocated (but non existent), bundle matches inserter
25132513
unsafe {
2514-
spawner.spawn_non_existent_with_caller(
2514+
spawner.spawn_non_existent(
25152515
entity,
25162516
bundle,
25172517
#[cfg(feature = "track_change_detection")]
@@ -2524,7 +2524,7 @@ impl World {
25242524
unsafe { BundleSpawner::new_with_id(self, bundle_id, change_tick) };
25252525
// SAFETY: `entity` is valid, `location` matches entity, bundle matches inserter
25262526
unsafe {
2527-
spawner.spawn_non_existent_with_caller(
2527+
spawner.spawn_non_existent(
25282528
entity,
25292529
bundle,
25302530
#[cfg(feature = "track_change_detection")]

0 commit comments

Comments
 (0)