From 4022385f51646471c0d7223b80d507cf4618df52 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Thu, 22 Feb 2024 00:40:45 +0100 Subject: [PATCH] Fix `SystemTypeSet::system_type` being out of sync with `System::type_id` (#12030) ## Objective Always have `some_system.into_system().type_id() == some_system.into_system_set().system_type().unwrap()`. System sets have a `fn system_type() -> Option` that is implemented by `SystemTypeSet` to returning the TypeId of the system's function type. This was implemented in https://github.com/bevyengine/bevy/pull/7715 and is used in `bevy_mod_debugdump` to handle `.after(function)` constraints. Back then, `System::type_id` always also returned the type id of the function item, not of `FunctionSystem`. https://github.com/bevyengine/bevy/pull/11728 changes the behaviour of `System::type_id` so that it returns the id of the `FunctionSystem`/`ExclusiveFunctionSystem` wrapper, but it did not change `SystemTypeSet::system_type`, so doing the lookup breaks in `bevy_mod_debugdump`. ## Solution Change `IntoSystemSet` for functions to return a `SystemTypeSet` / `SystemTypeSet` instead of `SystemTypeSet`. --- crates/bevy_ecs/src/schedule/set.rs | 13 ++++++++----- .../src/system/exclusive_function_system.rs | 2 +- crates/bevy_ecs/src/system/function_system.rs | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index 37e36ac11caac..d1ee7badfaa8e 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -9,7 +9,8 @@ use bevy_utils::intern::Interned; pub use bevy_utils::label::DynEq; use crate::system::{ - ExclusiveSystemParamFunction, IsExclusiveFunctionSystem, IsFunctionSystem, SystemParamFunction, + ExclusiveFunctionSystem, ExclusiveSystemParamFunction, FunctionSystem, + IsExclusiveFunctionSystem, IsFunctionSystem, SystemParamFunction, }; define_label!( @@ -167,26 +168,28 @@ impl IntoSystemSet<()> for S { // systems impl IntoSystemSet<(IsFunctionSystem, Marker)> for F where + Marker: 'static, F: SystemParamFunction, { - type Set = SystemTypeSet; + type Set = SystemTypeSet>; #[inline] fn into_system_set(self) -> Self::Set { - SystemTypeSet::new() + SystemTypeSet::>::new() } } // exclusive systems impl IntoSystemSet<(IsExclusiveFunctionSystem, Marker)> for F where + Marker: 'static, F: ExclusiveSystemParamFunction, { - type Set = SystemTypeSet; + type Set = SystemTypeSet>; #[inline] fn into_system_set(self) -> Self::Set { - SystemTypeSet::new() + SystemTypeSet::>::new() } } diff --git a/crates/bevy_ecs/src/system/exclusive_function_system.rs b/crates/bevy_ecs/src/system/exclusive_function_system.rs index b701f8098fcd7..a019330856aec 100644 --- a/crates/bevy_ecs/src/system/exclusive_function_system.rs +++ b/crates/bevy_ecs/src/system/exclusive_function_system.rs @@ -143,7 +143,7 @@ where } fn default_system_sets(&self) -> Vec { - let set = crate::schedule::SystemTypeSet::::new(); + let set = crate::schedule::SystemTypeSet::::new(); vec![set.intern()] } diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 3911ba83b57c0..903c512a4937b 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -536,7 +536,7 @@ where } fn default_system_sets(&self) -> Vec { - let set = crate::schedule::SystemTypeSet::::new(); + let set = crate::schedule::SystemTypeSet::::new(); vec![set.intern()] }