Skip to content

Commit 44a572e

Browse files
committed
Fix ignored lifetimes in #[derive(SystemParam)] (#7458)
# 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.
1 parent ff7d5ff commit 44a572e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

crates/bevy_ecs/macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
506506
>::get_param(&mut state.state, system_meta, world, change_tick);
507507
#struct_name {
508508
#(#fields: #field_locals,)*
509-
#(#ignored_fields: <#ignored_field_types>::default(),)*
509+
#(#ignored_fields: std::default::Default::default(),)*
510510
}
511511
}
512512
}

crates/bevy_ecs/src/system/system_param.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1541,11 +1541,12 @@ mod tests {
15411541
}
15421542

15431543
// Compile test for https://github.com/bevyengine/bevy/pull/6919.
1544+
// Regression test for https://github.com/bevyengine/bevy/issues/7447.
15441545
#[derive(SystemParam)]
1545-
struct MyParam<'w, T: Resource, Marker: 'static> {
1546+
struct IgnoredParam<'w, T: Resource, Marker: 'static> {
15461547
_foo: Res<'w, T>,
15471548
#[system_param(ignore)]
1548-
marker: PhantomData<Marker>,
1549+
marker: PhantomData<&'w Marker>,
15491550
}
15501551

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

0 commit comments

Comments
 (0)