Skip to content

Mutable NestedQuery with wrapper that erases QueryData type - #25809

Open
chescock wants to merge 6 commits into
bevyengine:mainfrom
chescock:mutable-nested-query-erased-query-state
Open

chescock wants to merge 6 commits into
bevyengine:mainfrom
chescock:mutable-nested-query-erased-query-state

Conversation

@chescock

Copy link
Copy Markdown
Contributor

Objective

Support mutable queries using NestedQuery.

The reason this was not supported in the initial version is that we want NestedQuery<D, F>::ReadOnly == NestedQuery<D::ReadOnly, F>, but that doesn't satisfy the ReadOnly::State == State constraint since QueryState<D::ReadOnly, F> != QueryState<D, F>.

Solution

Store QueryState<D::ReadOnly, F> in the State. Since D::ReadOnly::ReadOnly == D::ReadOnly, that ensures the states match.

In order to simplify the safety proofs and ensure we always convert it back to the appropriate type, introduce an ErasedQueryState wrapper type that prevents accidental access to the inner QueryState<D::ReadOnly, F>.

Adopted and modified from #25642. See also #25652 for context.

@chescock chescock added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events D-Unsafe Touches with unsafe code in some way S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 16, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in ECS Sep 16, 2026
@Zeophlite Zeophlite added the S-Merge-Conflicts Merge conflicts :( Add this label on top of other S- labels. label Sep 19, 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-Feature A new feature, making something new possible D-Unsafe Touches with unsafe code in some way S-Merge-Conflicts Merge conflicts :( Add this label on top of other S- labels. S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

3 participants