Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
67d2a1b
Extra traits for IterableQueryData and SingleEntityQueryData.
chescock Oct 9, 2025
8083d79
Bound `get_components` with `SingleEntityQueryData`.
chescock Oct 10, 2025
4ab98f3
Add `IterQueryData` bounds where necessary.
chescock Oct 9, 2025
214a47f
Bound `transmute` and `join` with `SingleEntityQueryData`.
chescock Oct 12, 2025
3a16fca
`WorldQuery::update_archetypes` to update caches for nested queries.
chescock Oct 9, 2025
be4c890
`WorldQuery::update_external_component_access` to accumulate access f…
chescock Oct 9, 2025
a5cffe6
Migration guide.
chescock Oct 14, 2025
dcbe137
Update PR number in migration guide.
chescock Oct 15, 2025
19be88a
Lists should be surrounded by blank lines
chescock Oct 15, 2025
09d9a48
Rename `QueryState::update_external_component_access` to `init_access…
chescock Oct 18, 2025
457663a
Rename `WorldQuery::update_external_component_access` to `WorldQuery:…
chescock Oct 18, 2025
798c36c
Create a NestedQuery type to use the new features.
chescock Oct 20, 2025
4d4abca
Add unit tests to ensure conflict checking works with `NestedQuery`.
chescock Oct 20, 2025
35767cb
Rework `IterQueryData` docs.
chescock Oct 20, 2025
cf8908d
Add doc comment explaining `SingleEntityQueryData` restriction on sor…
chescock Oct 21, 2025
1f36d2a
Clarify that `SystemParam::init_access` and `WorldQuery::init_nested_…
chescock Oct 21, 2025
0660ceb
Resources are not entities yet :(
chescock Oct 21, 2025
d854f62
Clarify that it's acceptable to call `update_archetypes` or `into_rea…
chescock Oct 21, 2025
feb3cc4
Merge remote-tracking branch 'remotes/origin/main' into query-multipl…
chescock Oct 22, 2025
42bf0a6
Re-apply `SingleEntityQueryData` bounds from deleted `entity_ref.rs`.
chescock Oct 22, 2025
cacb14f
Fix "redundant explicit link target".
chescock Oct 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/bevy_ecs/macros/src/query_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,17 @@ pub fn derive_query_data_impl(input: TokenStream) -> TokenStream {
}
}

// SAFETY: Access is read-only
unsafe impl #user_impl_generics #path::query::IterQueryData
for #read_only_struct_name #user_ty_generics #user_where_clauses {}

// SAFETY: All fields only access the current entity
unsafe impl #user_impl_generics #path::query::SingleEntityQueryData
for #read_only_struct_name #user_ty_generics #user_where_clauses
// Make these HRTBs with an unused lifetime parameter to allow trivial constraints
// See https://github.com/rust-lang/rust/issues/48214
where #(for<'__a> #field_types: #path::query::QueryData<ReadOnly: #path::query::SingleEntityQueryData>,)* {}

impl #user_impl_generics #path::query::ReleaseStateQueryData
for #read_only_struct_name #user_ty_generics #user_where_clauses
// Make these HRTBs with an unused lifetime parameter to allow trivial constraints
Expand Down Expand Up @@ -359,6 +370,20 @@ pub fn derive_query_data_impl(input: TokenStream) -> TokenStream {
}
}

// SAFETY: All fields are iterable
unsafe impl #user_impl_generics #path::query::IterQueryData
for #struct_name #user_ty_generics #user_where_clauses
// Make these HRTBs with an unused lifetime parameter to allow trivial constraints
// See https://github.com/rust-lang/rust/issues/48214
where #(for<'__a> #field_types: #path::query::IterQueryData,)* {}

// SAFETY: All fields only access the current entity
unsafe impl #user_impl_generics #path::query::SingleEntityQueryData
for #struct_name #user_ty_generics #user_where_clauses
// Make these HRTBs with an unused lifetime parameter to allow trivial constraints
// See https://github.com/rust-lang/rust/issues/48214
where #(for<'__a> #field_types: #path::query::SingleEntityQueryData,)* {}

impl #user_impl_generics #path::query::ReleaseStateQueryData
for #struct_name #user_ty_generics #user_where_clauses
// Make these HRTBs with an unused lifetime parameter to allow trivial constraints
Expand Down
13 changes: 13 additions & 0 deletions crates/bevy_ecs/macros/src/world_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ pub(crate) fn world_query_impl(
#( <#field_types>::update_component_access(&state.#named_field_idents, _access); )*
}

fn init_nested_access(
state: &Self::State,
_system_name: Option<&str>,
_component_access_set: &mut #path::query::FilteredAccessSet,
_world: #path::world::unsafe_world_cell::UnsafeWorldCell,
) {
#( <#field_types>::init_nested_access(&state.#named_field_idents, _system_name, _component_access_set, _world); )*
}

fn init_state(world: &mut #path::world::World) -> #state_struct_name #user_ty_generics {
#state_struct_name {
#(#named_field_idents: <#field_types>::init_state(world),)*
Expand All @@ -171,6 +180,10 @@ pub(crate) fn world_query_impl(
fn matches_component_set(state: &Self::State, _set_contains_id: &impl Fn(#path::component::ComponentId) -> bool) -> bool {
true #(&& <#field_types>::matches_component_set(&state.#named_field_idents, _set_contains_id))*
}

fn update_archetypes(_state: &mut Self::State, _world: #path::world::unsafe_world_cell::UnsafeWorldCell) {
#(<#field_types>::update_archetypes(&mut _state.#named_field_idents, _world);)*
}
}
}
}
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/query/access.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::component::ComponentId;
use crate::world::World;
use crate::world::unsafe_world_cell::UnsafeWorldCell;
use alloc::{format, string::String, vec, vec::Vec};
use core::{fmt, fmt::Debug};
use derive_more::From;
Expand Down Expand Up @@ -991,7 +991,7 @@ impl AccessConflicts {
}
}

pub(crate) fn format_conflict_list(&self, world: &World) -> String {
pub(crate) fn format_conflict_list(&self, world: UnsafeWorldCell) -> String {
match self {
AccessConflicts::All => String::new(),
AccessConflicts::Individual(indices) => indices
Expand All @@ -1000,7 +1000,7 @@ impl AccessConflicts {
format!(
"{}",
world
.components
.components()
.get_name(ComponentId::new(index))
.unwrap()
.shortname()
Expand Down
Loading