Skip to content

Commit 8e89511

Browse files
authored
Remove Bundle::register_required_components (#19967)
# Objective - `Bundle::register_required_components` is not used anywhere, let's remove it
1 parent b5cefe2 commit 8e89511

File tree

4 files changed

+6
-54
lines changed

4 files changed

+6
-54
lines changed

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,6 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
159159
) {
160160
#(<#active_field_types as #ecs_path::bundle::Bundle>::get_component_ids(components, &mut *ids);)*
161161
}
162-
163-
fn register_required_components(
164-
components: &mut #ecs_path::component::ComponentsRegistrator,
165-
required_components: &mut #ecs_path::component::RequiredComponents
166-
) {
167-
#(<#active_field_types as #ecs_path::bundle::Bundle>::register_required_components(components, required_components);)*
168-
}
169162
}
170163
};
171164

crates/bevy_ecs/src/bundle.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,6 @@ pub unsafe trait Bundle: DynamicBundle + Send + Sync + 'static {
207207

208208
/// Gets this [`Bundle`]'s component ids. This will be [`None`] if the component has not been registered.
209209
fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option<ComponentId>));
210-
211-
/// Registers components that are required by the components in this [`Bundle`].
212-
fn register_required_components(
213-
_components: &mut ComponentsRegistrator,
214-
_required_components: &mut RequiredComponents,
215-
);
216210
}
217211

218212
/// Creates a [`Bundle`] by taking it from internal storage.
@@ -279,20 +273,6 @@ unsafe impl<C: Component> Bundle for C {
279273
ids(components.register_component::<C>());
280274
}
281275

282-
fn register_required_components(
283-
components: &mut ComponentsRegistrator,
284-
required_components: &mut RequiredComponents,
285-
) {
286-
let component_id = components.register_component::<C>();
287-
<C as Component>::register_required_components(
288-
component_id,
289-
components,
290-
required_components,
291-
0,
292-
&mut Vec::new(),
293-
);
294-
}
295-
296276
fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option<ComponentId>)) {
297277
ids(components.get_id(TypeId::of::<C>()));
298278
}
@@ -347,13 +327,6 @@ macro_rules! tuple_impl {
347327
fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option<ComponentId>)){
348328
$(<$name as Bundle>::get_component_ids(components, ids);)*
349329
}
350-
351-
fn register_required_components(
352-
components: &mut ComponentsRegistrator,
353-
required_components: &mut RequiredComponents,
354-
) {
355-
$(<$name as Bundle>::register_required_components(components, required_components);)*
356-
}
357330
}
358331

359332
#[expect(

crates/bevy_ecs/src/spawn.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,6 @@ unsafe impl<R: Relationship, L: SpawnableList<R> + Send + Sync + 'static> Bundle
199199
) {
200200
<R::RelationshipTarget as Bundle>::get_component_ids(components, ids);
201201
}
202-
203-
fn register_required_components(
204-
components: &mut crate::component::ComponentsRegistrator,
205-
required_components: &mut crate::component::RequiredComponents,
206-
) {
207-
<R::RelationshipTarget as Bundle>::register_required_components(
208-
components,
209-
required_components,
210-
);
211-
}
212202
}
213203

214204
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> {
267257
) {
268258
<R::RelationshipTarget as Bundle>::get_component_ids(components, ids);
269259
}
270-
271-
fn register_required_components(
272-
components: &mut crate::component::ComponentsRegistrator,
273-
required_components: &mut crate::component::RequiredComponents,
274-
) {
275-
<R::RelationshipTarget as Bundle>::register_required_components(
276-
components,
277-
required_components,
278-
);
279-
}
280260
}
281261

282262
/// [`RelationshipTarget`] methods that create a [`Bundle`] with a [`DynamicBundle::Effect`] that:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Remove Bundle::register_required_components
3+
pull_requests: [19967]
4+
---
5+
6+
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.

0 commit comments

Comments
 (0)