After updating to Bevy 0.10 several of my SystemParams broke, due to a lifetime issue. I traced it down and it seems like using ParamSet within a #[derive(SystemParam)] struct doesn't work like expected, and I'm kinda lost on how to approach this.
This is a rather contrived minimal reproduction, but in theory this should compile right? It did in 0.9.1 at least.
#[derive(SystemParam)]
struct DoesNotWork<'w, 's> {
pub nope: ParamSet<'w, 's, (Commands<'w, 's>,)>,
}
My attempts to gather what is going on:
The error message is rather cryptic - as expected when dealing with macros:
80 | #[derive(SystemParam)]
| ^^^^^^^^^^^
| |
| lifetime `'w` defined here
| lifetime `'w2` defined here
| associated function was supposed to return data with lifetime `'w2` but it is returning data with lifetime `'w`
SOLUTION
The solution seems to remove all references to the lifetimes from the generic type parameter of ParamSet:
#[derive(SystemParam)]
struct WorksNow<'w, 's> {
pub yess: ParamSet<'w, 's, (Commands<'static, 'static>,)>,
}
But I don't quite understand a few of the things that are going on, so if anyone knows that stuff better than me, i'd be verryy glad to get some answers 😛