Skip to content

Commit

Permalink
Fix a miscompilation with #[derive(SystemParam)] (#7105)
Browse files Browse the repository at this point in the history
# Objective

- Fix #7103.
- The issue is caused because I forgot to add a where clause to a generated struct in #7056.

## Solution

- Add the where clause.
  • Loading branch information
JoJoJet committed Jan 10, 2023
1 parent a207178 commit fa40e2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
// <EventReader<'static, 'static, T> as SystemParam>::State
const _: () = {
#[doc(hidden)]
#state_struct_visibility struct FetchState <'w, 's, #(#lifetimeless_generics,)*> {
#state_struct_visibility struct FetchState <'w, 's, #(#lifetimeless_generics,)*>
#where_clause {
state: (#(<#tuple_types as #path::system::SystemParam>::State,)*),
marker: std::marker::PhantomData<(
<#path::prelude::Query<'w, 's, ()> as #path::system::SystemParam>::State,
Expand Down
9 changes: 9 additions & 0 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1639,4 +1639,13 @@ mod tests {

#[derive(SystemParam)]
pub struct EncapsulatedParam<'w>(Res<'w, PrivateResource>);

// regression test for https://github.com/bevyengine/bevy/issues/7103.
#[derive(SystemParam)]
pub struct WhereParam<'w, 's, Q>
where
Q: 'static + WorldQuery,
{
_q: Query<'w, 's, Q, ()>,
}
}

0 comments on commit fa40e2b

Please sign in to comment.