add support for non-'a lifetimes when deriving SystemParam#2633
add support for non-'a lifetimes when deriving SystemParam#2633ahouts wants to merge 5 commits intobevyengine:mainfrom ahouts:support-non-a-lifetimes-when-deriving-SystemParam
Conversation
…mes-when-deriving-SystemParam # Conflicts: # crates/bevy_ecs/macros/src/lib.rs
|
Hey, thanks for fixing this! It was a very silly little bug. |
Co-authored-by: Garett Cooper <22463490+GarettCooper@users.noreply.github.com>
|
Maybe not compatible with #2605 |
|
IMO we should merge this ASAP, then rebase #2605 onto it. This change is much simpler, and I tend to find that order is much easier to fix things in. |
|
I think first we should have a conversation about how deriving will work with the new lifetimes. I can think of a couple of paths forward:
I'm honestly more in favor of (2). It requires using specific lifetimes, but it doesn't have weird implicit ordering requirements and seems more flexible / compatible with other non-w/s lifetimes. No matter what, making this work nicely is going outside the bounds of normal expectations. We'll need to make compromises somewhere. |
|
I'm happy with 2 if the behavior is explicitly documented :) |
|
Another option is to require an annotation on each lifetime. It would be more verbose, but at least it doesn't depend on seemingly innocuous things like lifetime name or ordering. #[derive(SystemParam)]
struct MyParam<#[bevy_ecs(world)] 'w, #[bevy_ecs(state)] 's]> {
foo: Res<'w, usize>,
bar: Res<'s, usize>,
}Or if you don't mind adding annotations that might conflict with other macros: #[derive(SystemParam)]
struct MyParam<#[world] 'w, #[state] 's]> {
foo: Res<'w, usize>,
bar: Res<'s, usize>,
} |
|
Regardless of what is chosen, this PR as written is no longer applicable. |
Objective
Fixes #2587
Solution
Check if the struct definition contains a lifetime. If it does, use that instead of
'a.