diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index a8194ca6fe565..7c894ad07c172 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -329,6 +329,19 @@ pub unsafe trait WorldQuery { type State: Send + Sync + Sized; /// Runtime config value passed to [`WorldQuery::init_state`] + /// + /// This is used to pass runtime information that is necessary to construct + /// [`WorldQuery`]. + /// + /// Statically defined queries for types such as `&T` may obtain a + /// [`ComponentId`] statically, however, a dynamic query would require that + /// [`ComponentId`] is passed at runtime, such that + /// `Self::Config = ComponentId`. + /// + /// [`QueryState::new`](crate::query::state::QueryState::new) can be used when + /// `Self::Config: Default` otherwise + /// [`QueryState::new_with_config`](crate::query::state::QueryState::new_with_config) + /// is used to construct [`QueryState`](crate::query::state::QueryState). type Config; /// This function manually implements subtyping for the query items. diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 8beef70ceee44..d20abc50a061a 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -104,7 +104,9 @@ impl QueryState { ::Config: Default, ::Config: Default, { - QueryState::new_with_config(world, Default::default(), Default::default()) + let fetch_config = Default::default(); + let filter_config = Default::default(); + QueryState::new_with_config(world, fetch_config, filter_config) } /// Creates a new [`QueryState`] from a given [`World`], config, and inherits the result of `world.id()`.