Skip to content

Compiler Error on #[derive(Bundle)] for Generic Bundles in 0.16 #19470

Open
@Zeenobit

Description

@Zeenobit

Bevy version

Bevy 0.16

What you did

This is a follow up to this discussion.

The following code no longer compiles as of Bevy 0.16:

use bevy::prelude::*;

#[derive(Bundle)]
struct Foo<T: Bundle>(T);
error[E0277]: the trait bound `T: BundleFromComponents` is not satisfied

I understand this requires BundleFromComponent trait bound to work because of the new changes to Bundles:

use bevy::prelude::*;
use bevy::ecs::bundle::BundleFromComponents;

#[derive(Bundle)]
struct Foo<T: Bundle + BundleFromComponents>(T);

However, as discussed, this feels like a regression since BundleFromComponents is mostly an implementation detail (to me, at least).

Additional information

Some solutions that come to my mind:

  • We could have Bundle require BundleFromComponents as a trait bound. But this makes me wonder why this trait was split out to begin with.
  • We could introduce a new CompleteBundle trait (naming is hard) which does require BundleFromComponent and change derive(Bundle) to derive(CompleteBundle) instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-ComplexQuite challenging from either a design or technical perspective. Ask for help!P-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions