Remove Bundle::register_required_components (#19967)

# Objective

- `Bundle::register_required_components` is not used anywhere, let's
remove it
This commit is contained in:
Giacomo Stevanato 2025-07-06 20:15:28 +02:00 committed by GitHub
parent b5cefe2b5d
commit 8e89511e47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 54 deletions

View File

@ -159,13 +159,6 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
) {
#(<#active_field_types as #ecs_path::bundle::Bundle>::get_component_ids(components, &mut *ids);)*
}
fn register_required_components(
components: &mut #ecs_path::component::ComponentsRegistrator,
required_components: &mut #ecs_path::component::RequiredComponents
) {
#(<#active_field_types as #ecs_path::bundle::Bundle>::register_required_components(components, required_components);)*
}
}
};

View File

@ -207,12 +207,6 @@ pub unsafe trait Bundle: DynamicBundle + Send + Sync + 'static {
/// Gets this [`Bundle`]'s component ids. This will be [`None`] if the component has not been registered.
fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option<ComponentId>));
/// Registers components that are required by the components in this [`Bundle`].
fn register_required_components(
_components: &mut ComponentsRegistrator,
_required_components: &mut RequiredComponents,
);
}
/// Creates a [`Bundle`] by taking it from internal storage.
@ -279,20 +273,6 @@ unsafe impl<C: Component> Bundle for C {
ids(components.register_component::<C>());
}
fn register_required_components(
components: &mut ComponentsRegistrator,
required_components: &mut RequiredComponents,
) {
let component_id = components.register_component::<C>();
<C as Component>::register_required_components(
component_id,
components,
required_components,
0,
&mut Vec::new(),
);
}
fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option<ComponentId>)) {
ids(components.get_id(TypeId::of::<C>()));
}
@ -347,13 +327,6 @@ macro_rules! tuple_impl {
fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option<ComponentId>)){
$(<$name as Bundle>::get_component_ids(components, ids);)*
}
fn register_required_components(
components: &mut ComponentsRegistrator,
required_components: &mut RequiredComponents,
) {
$(<$name as Bundle>::register_required_components(components, required_components);)*
}
}
#[expect(

View File

@ -199,16 +199,6 @@ unsafe impl<R: Relationship, L: SpawnableList<R> + Send + Sync + 'static> Bundle
) {
<R::RelationshipTarget as Bundle>::get_component_ids(components, ids);
}
fn register_required_components(
components: &mut crate::component::ComponentsRegistrator,
required_components: &mut crate::component::RequiredComponents,
) {
<R::RelationshipTarget as Bundle>::register_required_components(
components,
required_components,
);
}
}
impl<R: Relationship, L: SpawnableList<R>> DynamicBundle for SpawnRelatedBundle<R, L> {
@ -267,16 +257,6 @@ unsafe impl<R: Relationship, B: Bundle> Bundle for SpawnOneRelated<R, B> {
) {
<R::RelationshipTarget as Bundle>::get_component_ids(components, ids);
}
fn register_required_components(
components: &mut crate::component::ComponentsRegistrator,
required_components: &mut crate::component::RequiredComponents,
) {
<R::RelationshipTarget as Bundle>::register_required_components(
components,
required_components,
);
}
}
/// [`RelationshipTarget`] methods that create a [`Bundle`] with a [`DynamicBundle::Effect`] that:

View File

@ -0,0 +1,6 @@
---
title: Remove Bundle::register_required_components
pull_requests: [19967]
---
This method was effectively dead-code as it was never used by the ECS to compute required components, hence it was removed. if you were overriding its implementation you can just remove it, as it never did anything. If you were using it in any other way, please open an issue.