bevy/crates/bevy_ecs/macros/src
James Liu 54456b7ea6
Make SystemParam::new_archetype and QueryState::new_archetype unsafe functions (#13044)
# Objective
Fix #2128. Both `Query::new_archetype` and `SystemParam::new_archetype`
do not check if the `Archetype` comes from the same World the state is
initialized from. This could result in unsoundness via invalid accesses
if called incorrectly.

## Solution
Make them `unsafe` functions and lift the invariant to the caller. This
also caught one instance of us not validating the World in
`SystemState::update_archetypes_unsafe_world_cell`'s implementation.

---

## Changelog
Changed: `QueryState::new_archetype` is now an unsafe function.
Changed: `SystemParam::new_archetype` is now an unsafe function.

## Migration Guide
`QueryState::new_archetype` and `SystemParam::new_archetype` are now an
unsafe functions that must be sure that the provided `Archetype` is from
the same `World` that the state was initialized from. Callers may need
to add additional assertions or propagate the safety invariant upwards
through the callstack to ensure safety.
2024-04-21 02:49:42 +00:00
..
component.rs Remove ComponentStorage and associated types (#12311) 2024-03-05 15:54:52 +00:00
lib.rs Make SystemParam::new_archetype and QueryState::new_archetype unsafe functions (#13044) 2024-04-21 02:49:42 +00:00
query_data.rs Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
query_filter.rs Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
states.rs Remove States::variants and remove enum-only restriction its derive (#9945) 2023-09-30 22:32:39 +00:00
world_query.rs Remove duplicate #[automatically_derived] in ECS macro (#11388) 2024-01-17 16:52:45 +00:00