Skip to content

Commit

Permalink
Fix ignored lifetimes in #[derive(SystemParam)] (#7458)
Browse files Browse the repository at this point in the history
# Objective

Fix #7447.

The `SystemParam` derive uses the wrong lifetimes for ignored fields.

## Solution

Use type inference instead of explicitly naming the types of ignored fields. This allows the compiler to automatically use the correct lifetime.
  • Loading branch information
JoJoJet committed Feb 3, 2023
1 parent ff7d5ff commit 44a572e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
>::get_param(&mut state.state, system_meta, world, change_tick);
#struct_name {
#(#fields: #field_locals,)*
#(#ignored_fields: <#ignored_field_types>::default(),)*
#(#ignored_fields: std::default::Default::default(),)*
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,11 +1541,12 @@ mod tests {
}

// Compile test for https://github.com/bevyengine/bevy/pull/6919.
// Regression test for https://github.com/bevyengine/bevy/issues/7447.
#[derive(SystemParam)]
struct MyParam<'w, T: Resource, Marker: 'static> {
struct IgnoredParam<'w, T: Resource, Marker: 'static> {
_foo: Res<'w, T>,
#[system_param(ignore)]
marker: PhantomData<Marker>,
marker: PhantomData<&'w Marker>,
}

// Compile tests for https://github.com/bevyengine/bevy/pull/6957.
Expand Down

0 comments on commit 44a572e

Please sign in to comment.