Skip to content

Deprecate DeferredWorld::query by generalizing QueryState::query_mut - #25789

Merged
alice-i-cecile merged 2 commits into
bevyengine:mainfrom
chescock:deferredworld-query
Sep 15, 2026
Merged

alice-i-cecile merged 2 commits into
bevyengine:mainfrom
chescock:deferredworld-query

Conversation

@chescock

Copy link
Copy Markdown
Contributor

Objective

Make the API for querying using QueryState more consistent.

Currently, the way to get a Query from a QueryState and World is the QueryState::query and QueryState::query_mut methods, but the way to get a Query from QueryState and DeferredWorld is the DeferredWorld::query method.

This is also surprising because DeferredWorld derefs to World, and there is a World::query method that creates a QueryState instead of creating a Query.

Solution

Generalize QueryState::query_mut to take impl Into<DeferredWorld<'w'>>. Add a missing From impl so that this actually works with &mut DeferredWorld, and add DeferredWorld::to_unsafe_world_cell to recover the full 'w lifetime in the implementation.

Deprecate DeferredWorld::query in favor of QueryState::query_mut.

…tate::query_mut`.

Deprecate `DeferredWorld::query()`.
@chescock chescock added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 14, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in ECS Sep 14, 2026
Comment thread crates/bevy_ecs/src/world/deferred_world.rs Outdated
Comment thread crates/bevy_ecs/src/query/state.rs Outdated
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 15, 2026
@alice-i-cecile
alice-i-cecile added this pull request to the merge queue Sep 15, 2026
Merged via the queue into bevyengine:main with commit fb8e31d Sep 15, 2026
44 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in ECS Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants