Skip to content

Conversation

@joseph-gio
Copy link
Member

@joseph-gio joseph-gio commented Dec 6, 2022

Objective

Solution

If any tuples have more than 16 fields, they are folded into tuples of tuples until they are under the 16-field limit.

@james7132 james7132 added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Dec 7, 2022
pub struct UnitParam {}

#[derive(Resource)]
pub struct R<const I: usize>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you added this over re-using UnitParam?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want each field to be a distinct type, to make sure the derive macro doesn't mess up the order of the fields.

const LIMIT: usize = 16;
while tuple_types.len() > LIMIT {
let end = Vec::from_iter(tuple_types.drain(..LIMIT));
tuple_types.push(parse_quote!( (#(#end,)*) ));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit difficult to follow this but does this make a tuple of tuples? Wouldn't that just raise the limit to 256 instead of removing it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait I think I see what this is doing. My god this is going to have a lot of codgen for anything more than 32 entries, but you probably already should be expecting that with a ParamSet that big.

const LIMIT: usize = 16;
while tuple_types.len() > LIMIT {
let end = Vec::from_iter(tuple_types.drain(..LIMIT));
tuple_types.push(parse_quote!( (#(#end,)*) ));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait I think I see what this is doing. My god this is going to have a lot of codgen for anything more than 32 entries, but you probably already should be expecting that with a ParamSet that big.

@james7132 james7132 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 17, 2022
@james7132 james7132 added this to the 0.10 milestone Dec 19, 2022
@cart
Copy link
Member

cart commented Dec 21, 2022

Resolve conflicts and this is good to go!

@joseph-gio
Copy link
Member Author

They are resolved :)

@cart
Copy link
Member

cart commented Dec 21, 2022

bors r+

bors bot pushed a commit that referenced this pull request Dec 21, 2022
# Objective

* The `SystemParam` derive internally uses tuples, which means it is constrained by the 16-field limit on `all_tuples`.
    * The error message if you exceed this limit is abysmal.
* Supercedes #5965 -- this does the same thing, but is simpler.

## Solution

If any tuples have more than 16 fields, they are folded into tuples of tuples until they are under the 16-field limit.
@bors bors bot changed the title Lift the 16-field limit from the SystemParam derive [Merged by Bors] - Lift the 16-field limit from the SystemParam derive Dec 21, 2022
@bors bors bot closed this Dec 21, 2022
@joseph-gio joseph-gio deleted the system-param-limit branch December 21, 2022 02:09
joseph-gio added a commit to joseph-gio/bevy that referenced this pull request Dec 21, 2022
* The `SystemParam` derive internally uses tuples, which means it is constrained by the 16-field limit on `all_tuples`.
    * The error message if you exceed this limit is abysmal.
* Supercedes bevyengine#5965 -- this does the same thing, but is simpler.

If any tuples have more than 16 fields, they are folded into tuples of tuples until they are under the 16-field limit.
bors bot pushed a commit that referenced this pull request Dec 25, 2022
# Objective

* Currently, the `SystemParam` derive does not support types with const generic parameters.
  * If you try to use const generics, the error message is cryptic and unhelpful.
* Continuation of the work started in #6867 and #6957.

## Solution

Allow const generic parameters to be used with `#[derive(SystemParam)]`.
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
# Objective

* The `SystemParam` derive internally uses tuples, which means it is constrained by the 16-field limit on `all_tuples`.
    * The error message if you exceed this limit is abysmal.
* Supercedes bevyengine#5965 -- this does the same thing, but is simpler.

## Solution

If any tuples have more than 16 fields, they are folded into tuples of tuples until they are under the 16-field limit.
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
# Objective

* Currently, the `SystemParam` derive does not support types with const generic parameters.
  * If you try to use const generics, the error message is cryptic and unhelpful.
* Continuation of the work started in bevyengine#6867 and bevyengine#6957.

## Solution

Allow const generic parameters to be used with `#[derive(SystemParam)]`.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

* The `SystemParam` derive internally uses tuples, which means it is constrained by the 16-field limit on `all_tuples`.
    * The error message if you exceed this limit is abysmal.
* Supercedes bevyengine#5965 -- this does the same thing, but is simpler.

## Solution

If any tuples have more than 16 fields, they are folded into tuples of tuples until they are under the 16-field limit.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

* Currently, the `SystemParam` derive does not support types with const generic parameters.
  * If you try to use const generics, the error message is cryptic and unhelpful.
* Continuation of the work started in bevyengine#6867 and bevyengine#6957.

## Solution

Allow const generic parameters to be used with `#[derive(SystemParam)]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants