Skip to content

Commit af40cf2

Browse files
committed
a
1 parent e2f5eb5 commit af40cf2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

crates/bevy_ecs/src/world/unsafe_world_cell.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,24 +818,35 @@ unsafe fn get_ticks(
818818
}
819819

820820
#[inline]
821-
#[allow(unsafe_op_in_unsafe_fn)]
821+
/// # Safety:
822+
/// - the returned `Column` is only used in ways that the `world` has permission for.
823+
/// - the returned `Column` is only used in ways that would not conflict with any existing
824+
/// borrows of world data.
822825
unsafe fn fetch_table(
823826
world: UnsafeWorldCell<'_>,
824827
location: EntityLocation,
825828
component_id: ComponentId,
826829
) -> Option<(&Column, TableRow)> {
827830
let archetype = &world.archetypes()[location.archetype_id];
828-
let table = &world.unsafe_world().storages.tables[archetype.table_id()];
831+
// SAFETY: caller ensures returned data is not misused
832+
let table = &unsafe { world.unsafe_world() }.storages.tables[archetype.table_id()];
829833
let components = table.get_column(component_id)?;
830834
let table_row = archetype.entity_table_row(location.archetype_row);
831835
Some((components, table_row))
832836
}
833837

834838
#[inline]
835-
#[allow(unsafe_op_in_unsafe_fn)]
839+
/// # Safety:
840+
/// - the returned `ComponentSparseSet` is only used in ways that the `world` has permission for.
841+
/// - the returned `ComponentSparseSet` is only used in ways that would not conflict with any existing
842+
/// borrows of world data.
836843
unsafe fn fetch_sparse_set(
837844
world: UnsafeWorldCell<'_>,
838845
component_id: ComponentId,
839846
) -> Option<&ComponentSparseSet> {
840-
world.unsafe_world().storages.sparse_sets.get(component_id)
847+
// SAFETY: caller ensures returned data is not misused
848+
unsafe { world.unsafe_world() }
849+
.storages
850+
.sparse_sets
851+
.get(component_id)
841852
}

0 commit comments

Comments
 (0)