Skip to content

Commit 9df2ac0

Browse files
clean up safety comments
1 parent ef85d54 commit 9df2ac0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

crates/bevy_ecs/src/world/entity_ref.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'w> EntityRef<'w> {
201201
///
202202
/// # Safety
203203
///
204-
/// - The returned reference must never alias a mutable borrow of this component.
204+
/// - The returned reference must never alias another reference to this component
205205
/// - The returned reference must not be used after this component is moved which
206206
/// may happen from **any** `insert_component`, `remove_component` or `despawn`
207207
/// operation on this world (non-exhaustive list).
@@ -211,7 +211,8 @@ impl<'w> EntityRef<'w> {
211211
component_id: ComponentId,
212212
) -> Option<MutUntyped<'w>> {
213213
self.world.components().get_info(component_id)?;
214-
// SAFETY: entity_location is valid, component_id is valid as checked by the line above, world access is promised by the caller
214+
// SAFETY: entity_location is valid, component_id is valid as checked by the line above,
215+
// the caller promises that they can uniquely access this component
215216
get_mut_by_id(self.world, self.entity, self.location, component_id)
216217
}
217218
}

crates/bevy_ecs/src/world/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,8 @@ impl World {
15331533
};
15341534

15351535
Some(MutUntyped {
1536-
// SAFETY: This function has exclusive access to the world so nothing aliases `ptr`.
1536+
// SAFETY: the caller of this function has to ensure that they can mutably access this
1537+
// component for the duration of the `'_` lifetime
15371538
value: ptr.assert_unique(),
15381539
ticks,
15391540
})

0 commit comments

Comments
 (0)