Skip to content

Delete System::component_access(). #19496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 2 additions & 6 deletions crates/bevy_ecs/src/schedule/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
component::{ComponentId, Tick},
error::{BevyError, ErrorContext, Result},
prelude::{IntoSystemSet, SystemSet},
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
schedule::{BoxedCondition, InternedSystemSet, NodeId, SystemTypeSet},
system::{ScheduleSystem, System, SystemIn, SystemParamValidationError, SystemStateFlags},
world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World},
Expand Down Expand Up @@ -162,12 +162,8 @@ impl System for ApplyDeferred {
Cow::Borrowed("bevy_ecs::apply_deferred")
}

fn component_access(&self) -> &Access<ComponentId> {
// This system accesses no components.
const { &Access::new() }
}

fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
// This system accesses no components.
const { &FilteredAccessSet::new() }
}

Expand Down
4 changes: 0 additions & 4 deletions crates/bevy_ecs/src/system/adapter_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ where
self.name.clone()
}

fn component_access(&self) -> &crate::query::Access<crate::component::ComponentId> {
self.system.component_access()
}

fn component_access_set(
&self,
) -> &crate::query::FilteredAccessSet<crate::component::ComponentId> {
Expand Down
10 changes: 1 addition & 9 deletions crates/bevy_ecs/src/system/combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::marker::PhantomData;
use crate::{
component::{ComponentId, Tick},
prelude::World,
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
schedule::InternedSystemSet,
system::{input::SystemInput, SystemIn, SystemParamValidationError},
world::unsafe_world_cell::UnsafeWorldCell,
Expand Down Expand Up @@ -144,10 +144,6 @@ where
self.name.clone()
}

fn component_access(&self) -> &Access<ComponentId> {
self.component_access_set.combined_access()
}

fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
&self.component_access_set
}
Expand Down Expand Up @@ -363,10 +359,6 @@ where
self.name.clone()
}

fn component_access(&self) -> &Access<ComponentId> {
self.component_access_set.combined_access()
}

fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
&self.component_access_set
}
Expand Down
7 changes: 1 addition & 6 deletions crates/bevy_ecs/src/system/exclusive_function_system.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
component::{ComponentId, Tick},
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
schedule::{InternedSystemSet, SystemSet},
system::{
check_system_change_tick, ExclusiveSystemParam, ExclusiveSystemParamItem, IntoSystem,
Expand Down Expand Up @@ -87,11 +87,6 @@ where
self.system_meta.name.clone()
}

#[inline]
fn component_access(&self) -> &Access<ComponentId> {
self.system_meta.component_access_set.combined_access()
}

#[inline]
fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
&self.system_meta.component_access_set
Expand Down
7 changes: 1 addition & 6 deletions crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
component::{ComponentId, Tick},
prelude::FromWorld,
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
schedule::{InternedSystemSet, SystemSet},
system::{
check_system_change_tick, ReadOnlySystemParam, System, SystemIn, SystemInput, SystemParam,
Expand Down Expand Up @@ -620,11 +620,6 @@ where
self.system_meta.name.clone()
}

#[inline]
fn component_access(&self) -> &Access<ComponentId> {
self.system_meta.component_access_set.combined_access()
}

#[inline]
fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
&self.system_meta.component_access_set
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,9 @@ mod tests {
x.initialize(&mut world);
y.initialize(&mut world);

let conflicts = x.component_access().get_conflicts(y.component_access());
let conflicts = x
.component_access_set()
.get_conflicts(y.component_access_set());
let b_id = world
.components()
.get_resource_id(TypeId::of::<B>())
Expand Down
7 changes: 1 addition & 6 deletions crates/bevy_ecs/src/system/observer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
error::Result,
never::Never,
prelude::{Bundle, Trigger},
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
schedule::{Fallible, Infallible},
system::{input::SystemIn, System},
world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World},
Expand Down Expand Up @@ -116,11 +116,6 @@ where
self.observer.name()
}

#[inline]
fn component_access(&self) -> &Access<ComponentId> {
self.observer.component_access()
}

#[inline]
fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
self.observer.component_access_set()
Expand Down
15 changes: 1 addition & 14 deletions crates/bevy_ecs/src/system/schedule_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloc::{borrow::Cow, vec::Vec};
use crate::{
component::{ComponentId, Tick},
error::Result,
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
system::{input::SystemIn, BoxedSystem, System, SystemInput},
world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, FromWorld, World},
};
Expand Down Expand Up @@ -33,11 +33,6 @@ impl<S: System<In = ()>> System for InfallibleSystemWrapper<S> {
self.0.type_id()
}

#[inline]
fn component_access(&self) -> &Access<ComponentId> {
self.0.component_access()
}

#[inline]
fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
self.0.component_access_set()
Expand Down Expand Up @@ -154,10 +149,6 @@ where
self.system.name()
}

fn component_access(&self) -> &Access<ComponentId> {
self.system.component_access()
}

fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
self.system.component_access_set()
}
Expand Down Expand Up @@ -256,10 +247,6 @@ where
self.system.name()
}

fn component_access(&self) -> &Access<ComponentId> {
self.system.component_access()
}

fn component_access_set(&self) -> &FilteredAccessSet<ComponentId> {
self.system.component_access_set()
}
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_ecs/src/system/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use thiserror::Error;

use crate::{
component::{ComponentId, Tick},
query::{Access, FilteredAccessSet},
query::FilteredAccessSet,
schedule::InternedSystemSet,
system::{input::SystemInput, SystemIn},
world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World},
Expand Down Expand Up @@ -57,9 +57,6 @@ pub trait System: Send + Sync + 'static {
TypeId::of::<Self>()
}

/// Returns the system's component [`Access`].
fn component_access(&self) -> &Access<ComponentId>;

/// Returns the system's component [`FilteredAccessSet`].
fn component_access_set(&self) -> &FilteredAccessSet<ComponentId>;

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/world/unsafe_world_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use thiserror::Error;
///
/// This alone is not enough to implement bevy systems where multiple systems can access *disjoint* parts of the world concurrently. For this, bevy stores all values of
/// resources and components (and [`ComponentTicks`]) in [`UnsafeCell`]s, and carefully validates disjoint access patterns using
/// APIs like [`System::component_access`](crate::system::System::component_access).
/// APIs like [`System::component_access_set`](crate::system::System::component_access_set).
///
/// A system then can be executed using [`System::run_unsafe`](crate::system::System::run_unsafe) with a `&World` and use methods with interior mutability to access resource values.
///
Expand Down
10 changes: 10 additions & 0 deletions release-content/migration-guides/delete_component_access.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: `System::component_access` has been deleted.
pull_requests: [19496]
---

`System::component_access` has been deleted. If you were calling this method, you can simply use
`my_system.component_access_set().combined_access()` to get the same result.

If you were manually implementing this, it should be equivalent to `System::component_access_set`
anyway.