From d92d5e794dfd2f66f4f49c9878c6739793545777 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Tue, 10 Jan 2023 18:31:15 +0000 Subject: [PATCH] Fix a miscompilation with `#[derive(SystemParam)]` (#7105) # 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. --- crates/bevy_ecs/macros/src/lib.rs | 3 ++- crates/bevy_ecs/src/system/system_param.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs index 1990f89107774f..3d8a10b3af68ec 100644 --- a/crates/bevy_ecs/macros/src/lib.rs +++ b/crates/bevy_ecs/macros/src/lib.rs @@ -465,7 +465,8 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream { // 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, diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 289d597335617b..b253f68e28aa93 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -1546,4 +1546,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, ()>, + } }