Using derive SystemParam with lifetimes <'w, 's> and not using 's is difficult #2711
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
S-Needs-Design
This issue requires design work to think about how it would best be accomplished
Bevy version
main Aug 21, 96e396fdd4e3d389c82680b5f8926ef8dbaabd76
What you did
I want to derive SystemParam for a struct which bundles resources but was not fully aware what the struct needs to adhere to.
What you expected to happen
It should compile.
What actually happened
Now it gets complicated. First of all I forget the second lifetime parameter in the struct, which is apparently needed.
Error message hints in the right direction but looks off in the placement hint:
Next try
pub struct EntityAssets<'w, 's> {
raised the error messagewhich is difficult to understand how to actually use PhantomData in this place.
This issue has the necessary hint how to use it in deriving SystemParam.
Next try:
But this will produce an absurde error message since the deriving macro is producing bad code:
The next try produced an actually compiling version:
Additional information
I would suggest to make the second lifetime parameter optional in the processing macro, if possible for the resulting type.
The absurde error message hints to an order dependent processing in the derive macro. The processing of struct fields should be order independent.
The text was updated successfully, but these errors were encountered: