You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disallow requesting write resource access in Queries (#17116)
Related to #16843
Since `WorldQuery::Fetch` is `Clone`, it can't store mutable references
to resources, so it doesn't make sense to mutably access resources. In
that sense, it is hard to find usecases of mutably accessing resources
and to clearly define, what mutably accessing resources would mean, so
it's been decided to disallow write resource access.
Also changed documentation of safety requirements of
`WorldQuery::init_fetch` and `WorldQuery::fetch` to clearly state to the
caller, what safety invariants they need to uphold.
Copy file name to clipboardExpand all lines: crates/bevy_ecs/src/query/world_query.rs
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ use variadics_please::all_tuples;
14
14
/// # Safety
15
15
///
16
16
/// Implementor must ensure that
17
-
/// [`update_component_access`], [`matches_component_set`], and [`fetch`]
17
+
/// [`update_component_access`], [`matches_component_set`], [`fetch`] and [`init_fetch`]
18
18
/// obey the following:
19
19
///
20
20
/// - For each component mutably accessed by [`fetch`], [`update_component_access`] should add write access unless read or write access has already been added, in which case it should panic.
@@ -26,8 +26,8 @@ use variadics_please::all_tuples;
26
26
/// - [`matches_component_set`] must be a disjunction of the element's implementations
27
27
/// - [`update_component_access`] must replace the filters with a disjunction of filters
28
28
/// - Each filter in that disjunction must be a conjunction of the corresponding element's filter with the previous `access`
29
-
/// - For each resource mutably accessed by [`init_fetch`], [`update_component_access`] should add write access unless read or write access has already been added, in which case it should panic.
30
-
/// - For each resource readonly accessed by [`init_fetch`], [`update_component_access`] should add read access unless write access has already been added, in which case it should panic.
29
+
/// - For each resource readonly accessed by [`init_fetch`], [`update_component_access`] should add read access.
30
+
/// - Mutable resource access is not allowed.
31
31
///
32
32
/// When implementing [`update_component_access`], note that `add_read` and `add_write` both also add a `With` filter, whereas `extend_access` does not change the filters.
0 commit comments