bevyengine / bevyengine/bevy

Error when having 16 components with the new tuple .spawn(())

Open
#7,329 10 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Bug S-Blocked
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version
bevy = {version = "0.9.1", features = ["dynamic", "wayland"]}

## \[Optional\] Relevant system information
OS: Manjaro Linux x86_64
Kernel: 5.15.85-1-MANJARO

## What you did

When creating 16 (different) components and using the new tuple way of spawning `.spawn(())`, building the project causes an error:

Components:
```
#[derive(Component)]
struct One;

#[derive(Component)]
struct Two;

#[derive(Component)]
struct Three;

#[derive(Component)]
struct Four;

#[derive(Component)]
struct Five;

#[derive(Component)]
struct Six;

#[derive(Component)]
struct Seven;

#[derive(Component)]
struct Eight;

#[derive(Component)]
struct Nine;

#[derive(Component)]
struct Ten;

#[derive(Component)]
struct Eleven;

#[derive(Component)]
struct Twelve;

#[derive(Component)]
struct Thirteen;

#[derive(Component)]
struct Fourteen;

#[derive(Component)]
struct Fifteen;
```

Spawning:
```
commands.spawn((
Name::new("Hi it's me"),
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
Twelve,
Thirteen,
Fourteen,
Fifteen
));
```
Error:

`error[E0277]: the trait bound `(bevy::prelude::Name, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen): bevy::prelude::Component` is not satisfied`

The components themselves do not matter, just that there are more than 15 of them:
```
commands.spawn((
Name::new("Hi it's me"),
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
Twelve,
// ...
Fifteen,
Sixteen,
Seventeen,
));
```

Results in the same error.

However, when using the old way of spawning, `.spawn().insert().insert()...`, it works fine and compiles.
It also compiles just fine when using one less component, i.e., just until `Fourteen`.

Old way:
```
commands
.spawn(Name::new("Hi it's me"))
.insert(One)
.insert(Two)
.insert(Three)
.insert(Four)
.insert(Five)
.insert(Six)
.insert(Seven)
.insert(Eight)
.insert(Nine)
.insert(Ten)
.insert(Eleven)
.insert(Twelve)
.insert(Thirteen)
.insert(Fourteen)
.insert(Fifteen)
.insert(Sixteen)
.insert(Seventeen);
```
Works fine:
![2023-01-22-125520_113x351_scrot](https://user-images.githubusercontent.com/26929955/213916969-e214d225-a907-4673-8d9b-4879ccd81c03.png)

## What went wrong

- what were you expecting?
All components to be inserted into the newly spawned object.

- what actually happened?
Only up to 16 components can be loaded using the new tuple way, after that it errors with:
```
error[E0277]: the trait bound `(bevy::prelude::Name, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen): bevy::prelude::Component` is not satisfied
--> src/main.rs:355:20
|
355 | commands.spawn((
| ______________-----_^
| | |
| | required by a bound introduced by this call
356 | | Name::new("Aye caramba"),
357 | | One,
358 | | Two,
... |
371 | | Fifteen
372 | | ));
| |_____^ the trait `bevy::prelude::Component` is not implemented for `(bevy::prelude::Name, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen)`
|
= help: the following other types implement trait `bevy::prelude::Component`:
AdditionalMassProperties
AlphaMode
Analyzer
AnimationPlayer
AsyncCollider
AsyncSceneCollider
BackgroundColor
Barracks
and 191 others
= note: required for `(bevy::prelude::Name, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen)` to implement `Bundle`
```

## Additional information

The note in the message suggests aligning them into a `Bundle`, but if it is indeed the solution, then the limit of 16 with the new spawn system should be documented somewhere. However, the fact that there are no errors with the old way of spawning is a bit suspicious.

Shall any more info be required, please let me know.

Thanks for your help!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.