Skip to content

Commit

Permalink
fix some names
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBrienen committed Oct 31, 2024
1 parent 4ad9486 commit bfd64b5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/removal_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ fn map_id_events(

// For all practical purposes, the api surface of `RemovedComponents<T>`
// should be similar to `EventReader<T>` to reduce confusion.
impl<T: Component> RemovedComponents<'_, '_, T> {
#[expect(clippy::needless_lifetimes)]
impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> {
/// Fetch underlying [`EventCursor`].
pub fn reader(&self) -> &EventCursor<RemovedComponentEntity> {
&self.reader
Expand Down
15 changes: 11 additions & 4 deletions crates/bevy_ecs/src/system/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ impl ParamBuilder {
}

// SAFETY: Calls `init_query_param`, just like `Query::init_state`.
unsafe impl<D: QueryData + 'static, F: QueryFilter + 'static>
SystemParamBuilder<Query<'_, '_, D, F>> for QueryState<D, F>
#[expect(clippy::needless_lifetimes)]
unsafe impl<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>
SystemParamBuilder<Query<'w, 's, D, F>> for QueryState<D, F>
{
fn build(self, world: &mut World, system_meta: &mut SystemMeta) -> QueryState<D, F> {
self.validate_world(world.id());
Expand Down Expand Up @@ -278,8 +279,14 @@ impl<'a, D: QueryData, F: QueryFilter>
}

// SAFETY: Calls `init_query_param`, just like `Query::init_state`.
unsafe impl<D: QueryData + 'static, F: QueryFilter + 'static, T: FnOnce(&mut QueryBuilder<D, F>)>
SystemParamBuilder<Query<'_, '_, D, F>> for QueryParamBuilder<T>
#[expect(clippy::needless_lifetimes)]
unsafe impl<
'w,
's,
D: QueryData + 'static,
F: QueryFilter + 'static,
T: FnOnce(&mut QueryBuilder<D, F>),
> SystemParamBuilder<Query<'w, 's, D, F>> for QueryParamBuilder<T>
{
fn build(self, world: &mut World, system_meta: &mut SystemMeta) -> QueryState<D, F> {
let mut builder = QueryBuilder::new(world);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub struct Query<'world, 'state, D: QueryData, F: QueryFilter = ()> {
this_run: Tick,
}

impl<D: QueryData, F: QueryFilter> core::fmt::Debug for Query<'_, '_, D, F> {
impl<'w, 's, D: QueryData, F: QueryFilter> core::fmt::Debug for Query<'w, 's, D, F> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Query")
.field("matched_entities", &self.iter().count())
Expand Down
24 changes: 14 additions & 10 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,20 @@ pub unsafe trait ReadOnlySystemParam: SystemParam {}
pub type SystemParamItem<'w, 's, P> = <P as SystemParam>::Item<'w, 's>;

// SAFETY: QueryState is constrained to read-only fetches, so it only reads World.
unsafe impl<D: ReadOnlyQueryData + 'static, F: QueryFilter + 'static> ReadOnlySystemParam
for Query<'_, '_, D, F>
#[expect(clippy::needless_lifetimes)]
unsafe impl<'w, 's, D: ReadOnlyQueryData + 'static, F: QueryFilter + 'static> ReadOnlySystemParam
for Query<'w, 's, D, F>
{
}

// SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If
// this Query conflicts with any prior access, a panic will occur.
unsafe impl<D: QueryData + 'static, F: QueryFilter + 'static> SystemParam for Query<'_, '_, D, F> {
#[expect(clippy::needless_lifetimes)]
unsafe impl<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static> SystemParam
for Query<'w, 's, D, F>
{
type State = QueryState<D, F>;
type Item<'w, 's> = Query<'w, 's, D, F>;
type Item<'world, 'state> = Query<'world, 'state, D, F>;

fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State {
let state = QueryState::new_with_access(world, &mut system_meta.archetype_component_access);
Expand All @@ -309,12 +313,12 @@ unsafe impl<D: QueryData + 'static, F: QueryFilter + 'static> SystemParam for Qu
}

#[inline]
unsafe fn get_param<'w, 's>(
state: &'s mut Self::State,
unsafe fn get_param<'world, 'state>(
state: &'state mut Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
world: UnsafeWorldCell<'world>,
change_tick: Tick,
) -> Self::Item<'w, 's> {
) -> Self::Item<'world, 'state> {
// SAFETY: We have registered all of the query's world accesses,
// so the caller ensures that `world` has permission to access any
// world data that the query needs.
Expand Down Expand Up @@ -498,8 +502,8 @@ unsafe impl<D: ReadOnlyQueryData + 'static, F: QueryFilter + 'static> ReadOnlySy

// SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If
// this Query conflicts with any prior access, a panic will occur.
unsafe impl<D: QueryData + 'static, F: QueryFilter + 'static> SystemParam
for Populated<'_, '_, D, F>
unsafe impl<'world, 'state, D: QueryData + 'static, F: QueryFilter + 'static> SystemParam
for Populated<'world, 'state, D, F>
{
type State = QueryState<D, F>;
type Item<'w, 's> = Populated<'w, 's, D, F>;
Expand Down

0 comments on commit bfd64b5

Please sign in to comment.