Skip to content

Commit a8405d3

Browse files
remove comments referring to type when untyped pointer is returned
1 parent 0b824b3 commit a8405d3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

crates/bevy_ecs/src/storage/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Storages {
7171
let (components, table_row) =
7272
fetch_table(archetypes, self, location, component_id)?;
7373

74-
// SAFETY: archetypes only store valid table_rows and the stored component type is T
74+
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
7575
Some((
7676
components.get_data_unchecked(table_row),
7777
TickCells {
@@ -130,7 +130,7 @@ impl Storages {
130130
StorageType::Table => {
131131
let (components, table_row) =
132132
fetch_table(archetypes, self, location, component_id)?;
133-
// SAFETY: archetypes only store valid table_rows and the stored component type is T
133+
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
134134
Some(components.get_data_unchecked(table_row))
135135
}
136136
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get(entity),
@@ -182,7 +182,7 @@ impl Storages {
182182
StorageType::Table => {
183183
let (components, table_row) =
184184
fetch_table(archetypes, self, location, component_id)?;
185-
// SAFETY: archetypes only store valid table_rows and the stored component type is T
185+
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
186186
Some(components.get_ticks_unchecked(table_row))
187187
}
188188
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get_ticks(entity),
@@ -201,7 +201,7 @@ impl Storages {
201201
/// - `location` must be within bounds of the given archetype and `entity` must exist inside the `archetype`
202202
/// - `component_id` must be valid
203203
/// - `components` must come from the same world as `self`
204-
/// - The relevant table row **must be removed** by the caller once all components are taken
204+
/// - The relevant table row **must be removed** by the caller once all components are taken, without dropping the value
205205
#[inline]
206206
pub(crate) unsafe fn take_component<'a>(
207207
&'a mut self,
@@ -219,7 +219,10 @@ impl Storages {
219219
let table = &mut self.tables[location.table_id];
220220
// SAFETY: archetypes will always point to valid columns
221221
let components = table.get_column_mut(component_id).unwrap();
222-
// SAFETY: archetypes only store valid table_rows and the stored component type is T
222+
// SAFETY:
223+
// - archetypes only store valid table_rows
224+
// - index is in bounds as promised by caller
225+
// - promote is safe because the caller promises to remove the table row without dropping it immediately afterwards
223226
components
224227
.get_data_unchecked_mut(location.table_row)
225228
.promote()

crates/bevy_ecs/src/world/entity_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<'w> EntityMut<'w> {
439439
let component_id = bundle_components.next().unwrap();
440440
// SAFETY:
441441
// - entity location is valid
442-
// - table row is removed below
442+
// - table row is removed below, without dropping the contents
443443
// - `components` comes from the same world as `storages`
444444
storages.take_component(
445445
components,

0 commit comments

Comments
 (0)