-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemParam: lifetime may not live long enough #8192
Comments
What happens if you change those lifetimes to 'static? |
@alice-i-cecile Just to be clear, do you mean a 'static constraint on 'w and 's? Or do you mean dropping the 'w and 's in my type and replacing with 'static? (I'm assuming there could be a difference there do to the way the param parses the struct body) Will give this a shot ASAP! Thanks for the response |
Ah, seems like this issue pops up when a Here's a minimum reproducible example: #[derive(SystemParam)]
pub struct InvariantParam<'w, 's> {
set: ParamSet<'w, 's, (Query<'w, 's, ()>,)>,
} Seems like this will be fixed by #8030. |
@alice-i-cecile Adding the
and
@JoJoJet Thanks for chiming in here, do you have any insight on when we might expect #8030 ? Possible there will be a patch release, or are we talking 0.11? |
#8030 has a breaking change, so in order for the fix to land in a patch release I'd have to make a new PR with just that fix and nothing else. I can look into that later but I'm not sure how that would work out. As a temporary workaround, try changing just the lifetimes inside of the ParamSet to Meaning if you have a struct like this: Changing the lifetimes in this specific way seems to make it compile. |
@JoJoJet Thank you, that works. Appreciate the help 👍 |
Happy I could help :) |
…ry (bevyengine#8030) When using `PhantomData` fields with the `#[derive(SystemParam)]` or `#[derive(WorldQuery)]` macros, the user is required to add the `#[system_param(ignore)]` attribute so that the macro knows to treat that field specially. This is undesirable, since it makes the macro more fragile and less consistent. Implement `SystemParam` and `WorldQuery` for `PhantomData`. This makes the `ignore` attributes unnecessary. Some internal changes make the derive macro compatible with types that have invariant lifetimes, which fixes bevyengine#8192. From what I can tell, this fix requires `PhantomData` to implement `SystemParam` in order to ensure that all of a type's generic parameters are always constrained. --- + Implemented `SystemParam` and `WorldQuery` for `PhantomData<T>`. + Fixed a miscompilation caused when invariant lifetimes were used with the `SystemParam` macro.
…ry (#8030) When using `PhantomData` fields with the `#[derive(SystemParam)]` or `#[derive(WorldQuery)]` macros, the user is required to add the `#[system_param(ignore)]` attribute so that the macro knows to treat that field specially. This is undesirable, since it makes the macro more fragile and less consistent. Implement `SystemParam` and `WorldQuery` for `PhantomData`. This makes the `ignore` attributes unnecessary. Some internal changes make the derive macro compatible with types that have invariant lifetimes, which fixes #8192. From what I can tell, this fix requires `PhantomData` to implement `SystemParam` in order to ensure that all of a type's generic parameters are always constrained. --- + Implemented `SystemParam` and `WorldQuery` for `PhantomData<T>`. + Fixed a miscompilation caused when invariant lifetimes were used with the `SystemParam` macro.
…ry (bevyengine#8030) When using `PhantomData` fields with the `#[derive(SystemParam)]` or `#[derive(WorldQuery)]` macros, the user is required to add the `#[system_param(ignore)]` attribute so that the macro knows to treat that field specially. This is undesirable, since it makes the macro more fragile and less consistent. Implement `SystemParam` and `WorldQuery` for `PhantomData`. This makes the `ignore` attributes unnecessary. Some internal changes make the derive macro compatible with types that have invariant lifetimes, which fixes bevyengine#8192. From what I can tell, this fix requires `PhantomData` to implement `SystemParam` in order to ensure that all of a type's generic parameters are always constrained. --- + Implemented `SystemParam` and `WorldQuery` for `PhantomData<T>`. + Fixed a miscompilation caused when invariant lifetimes were used with the `SystemParam` macro.
Bevy version
v0.10.0
What you did
Upgrading a bevy 0.9 project to the latest and greatest. I have a few
#[derive(SystemParam)]
implementations that were working great with 0.9, but now give me anerror: lifetime may not live long enough
which appears to all occur within theSystemParam
attribute itself. Here's the struct definition in question:The
TileQuery
itself is also aSystemParam
:The
EntityRef
trait is defined as:What went wrong
I'm getting 4 nearly identical errors all pointing to the
#[derive(SystemParam)]
.Here's the first error, followed by the 3 differences
Second:
Third:
Fourth:
Additional information
I will work to see if I can get a reproducible case with less dependencies than the current project I am working in. Apologies if this is unclear in anyway. Will be happy to assist anyway possible!
Thanks for an incredible open source project
The text was updated successfully, but these errors were encountered: