Skip to content

Commit 6026c08

Browse files
authored
Update documentation for WorldQuery and filters (#11952)
# Objective `update_archetype_component_access` was removed from queries in #9774, but some documentation still refers to it. ## Solution Update the documentation. Since a bunch of these were in SAFETY comments it would be nice if someone who knows the details better could check that the rest of those comments are still valid.
1 parent cb5ff51 commit 6026c08

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

crates/bevy_ecs/src/query/filter.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ use std::{cell::UnsafeCell, marker::PhantomData};
7070
/// [`matches_component_set`]: Self::matches_component_set
7171
/// [`Query`]: crate::system::Query
7272
/// [`State`]: Self::State
73-
/// [`update_archetype_component_access`]: Self::update_archetype_component_access
74-
/// [`update_component_access`]: Self::update_component_access
7573
7674
pub trait QueryFilter: WorldQuery {
7775
/// Returns true if (and only if) this Filter relies strictly on archetypes to limit which
@@ -123,7 +121,7 @@ pub trait QueryFilter: WorldQuery {
123121
pub struct With<T>(PhantomData<T>);
124122

125123
/// SAFETY:
126-
/// `update_component_access` and `update_archetype_component_access` do not add any accesses.
124+
/// `update_component_access` does not add any accesses.
127125
/// This is sound because `fetch` does not access any components.
128126
/// `update_component_access` adds a `With` filter for `T`.
129127
/// This is sound because `matches_component_set` returns whether the set contains the component.
@@ -231,7 +229,7 @@ impl<T: Component> QueryFilter for With<T> {
231229
pub struct Without<T>(PhantomData<T>);
232230

233231
/// SAFETY:
234-
/// `update_component_access` and `update_archetype_component_access` do not add any accesses.
232+
/// `update_component_access` does not add any accesses.
235233
/// This is sound because `fetch` does not access any components.
236234
/// `update_component_access` adds a `Without` filter for `T`.
237235
/// This is sound because `matches_component_set` returns whether the set does not contain the component.
@@ -366,7 +364,7 @@ macro_rules! impl_query_filter_tuple {
366364
#[allow(clippy::unused_unit)]
367365
/// SAFETY:
368366
/// `fetch` accesses are a subset of the subqueries' accesses
369-
/// This is sound because `update_component_access` and `update_archetype_component_access` adds accesses according to the implementations of all the subqueries.
367+
/// This is sound because `update_component_access` adds accesses according to the implementations of all the subqueries.
370368
/// `update_component_access` replace the filters with a disjunction where every element is a conjunction of the previous filters and the filters of one of the subqueries.
371369
/// This is sound because `matches_component_set` returns a disjunction of the results of the subqueries' implementations.
372370
unsafe impl<$($filter: QueryFilter),*> WorldQuery for Or<($($filter,)*)> {
@@ -579,7 +577,7 @@ pub struct AddedFetch<'w> {
579577

580578
/// SAFETY:
581579
/// `fetch` accesses a single component in a readonly way.
582-
/// This is sound because `update_component_access` and `update_archetype_component_access` add read access for that component and panic when appropriate.
580+
/// This is sound because `update_component_access` adds read access for that component and panics when appropriate.
583581
/// `update_component_access` adds a `With` filter for a component.
584582
/// This is sound because `matches_component_set` returns whether the set contains that component.
585583
unsafe impl<T: Component> WorldQuery for Added<T> {
@@ -779,7 +777,7 @@ pub struct ChangedFetch<'w> {
779777

780778
/// SAFETY:
781779
/// `fetch` accesses a single component in a readonly way.
782-
/// This is sound because `update_component_access` and `update_archetype_component_access` add read access for that component and panic when appropriate.
780+
/// This is sound because `update_component_access` add read access for that component and panics when appropriate.
783781
/// `update_component_access` adds a `With` filter for a component.
784782
/// This is sound because `matches_component_set` returns whether the set contains that component.
785783
unsafe impl<T: Component> WorldQuery for Changed<T> {

crates/bevy_ecs/src/query/world_query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ pub unsafe trait WorldQuery {
5757
///
5858
/// # Safety
5959
///
60-
/// - `world` must have permission to access any of the components specified in `Self::update_archetype_component_access`.
6160
/// - `state` must have been initialized (via [`WorldQuery::init_state`]) using the same `world` passed
6261
/// in to this function.
6362
unsafe fn init_fetch<'w>(
@@ -128,7 +127,8 @@ pub unsafe trait WorldQuery {
128127
/// Creates and initializes a [`State`](WorldQuery::State) for this [`WorldQuery`] type.
129128
fn init_state(world: &mut World) -> Self::State;
130129

131-
/// Attempts to initializes a [`State`](WorldQuery::State) for this [`WorldQuery`] type.
130+
/// Attempts to initialize a [`State`](WorldQuery::State) for this [`WorldQuery`] type using read-only
131+
/// access to the [`World`].
132132
fn get_state(world: &World) -> Option<Self::State>;
133133

134134
/// Returns `true` if this query matches a set of components. Otherwise, returns `false`.
@@ -145,7 +145,7 @@ macro_rules! impl_tuple_world_query {
145145
#[allow(clippy::unused_unit)]
146146
/// SAFETY:
147147
/// `fetch` accesses are the conjunction of the subqueries' accesses
148-
/// This is sound because `update_component_access` and `update_archetype_component_access` adds accesses according to the implementations of all the subqueries.
148+
/// This is sound because `update_component_access` adds accesses according to the implementations of all the subqueries.
149149
/// `update_component_access` adds all `With` and `Without` filters from the subqueries.
150150
/// This is sound because `matches_component_set` always returns `false` if any the subqueries' implementations return `false`.
151151
unsafe impl<$($name: WorldQuery),*> WorldQuery for ($($name,)*) {

0 commit comments

Comments
 (0)