bevyengine / bevyengine/bevy

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

Open
#19,470 1 comment 0 reactions 0 assignees View on GitHub
A-ECS C-Bug D-Complex I-Regression S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

Bevy 0.16

## What you did

This is a follow up to [this discussion](https://github.com/bevyengine/bevy/discussions/19460).

The following code no longer compiles as of Bevy 0.16:

```rust
use bevy::prelude::*;

#[derive(Bundle)]
struct Foo(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:
```rust
use bevy::prelude::*;
use bevy::ecs::bundle::BundleFromComponents;

#[derive(Bundle)]
struct Foo(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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the generic `#[derive(Bundle)]` example on Bevy 0.16 and read discussion #19460 for the context around `BundleFromComponents`. Investigate the `Bundle`, `BundleFromComponents`, and derive behavior described in the issue; done means the generic bundle API has an agreed resolution that no longer exposes an unintended implementation detail.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.