bevy/crates/bevy_ecs/macros/src
Chris Russell d0550f58ae
Remove 's lifetime from WorldQuery::Fetch (#19720)
# Objective

Unblock #18162.

#15396 added the `'s` lifetime to `QueryData::Item` to make it possible
for query items to borrow from the state. The state isn't passed
directly to `QueryData::fetch()`, so it also added the `'s` lifetime to
`WorldQuery::Fetch` so that we can pass the borrows through there.

Unfortunately, having `WorldQuery::Fetch` borrow from the state makes it
impossible to have owned state, because we store the state and the
`Fetch` in the same `struct` during iteration.

## Solution

Undo the change to add the `'s` lifetime to `WorldQuery::Fetch`.

Instead, add a `&'s Self::State` parameter to `QueryData::fetch()` and
`QueryFilter::filter_fetch()` so that borrows from the state can be
passed directly to query items.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Emerson Coskey <emerson@coskey.dev>
2025-06-19 00:58:21 +00:00
..
component.rs Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
lib.rs Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
query_data.rs Remove 's lifetime from WorldQuery::Fetch (#19720) 2025-06-19 00:58:21 +00:00
query_filter.rs Remove 's lifetime from WorldQuery::Fetch (#19720) 2025-06-19 00:58:21 +00:00
world_query.rs Remove 's lifetime from WorldQuery::Fetch (#19720) 2025-06-19 00:58:21 +00:00