From 8e1d0051d2c97dd75c788c874a2b7e652767cc57 Mon Sep 17 00:00:00 2001 From: Emerson Coskey Date: Fri, 20 Jun 2025 08:48:16 -0700 Subject: [PATCH] Fix QueryData derive codegen (#19750) Custom derived `QueryData` impls currently generate `Item` structs with the lifetimes swapped, which blows up the borrow checker sometimes. See: https://discord.com/channels/691052431525675048/749335865876021248/1385509416086011914 could add a regression test, TBH I don't know the error well enough to do that minimally. Seems like it's that both lifetimes on `QueryData::Item` need to be covariant, but I'm not sure. --- crates/bevy_ecs/macros/src/query_data.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/macros/src/query_data.rs b/crates/bevy_ecs/macros/src/query_data.rs index 910d9ce3b6..12d9c2bf1c 100644 --- a/crates/bevy_ecs/macros/src/query_data.rs +++ b/crates/bevy_ecs/macros/src/query_data.rs @@ -83,7 +83,7 @@ pub fn derive_query_data_impl(input: TokenStream) -> TokenStream { let user_generics_with_world_and_state = { let mut generics = ast.generics; generics.params.insert(0, parse_quote!('__w)); - generics.params.insert(0, parse_quote!('__s)); + generics.params.insert(1, parse_quote!('__s)); generics }; let (