Skip to content

Commit f8964a4

Browse files
authored
Improve Debug names for SystemTypeSet. (#22499)
# Objective - Debug names for `SystemTypeSet` are quite bad. For example, the system `fn a() {}` gets the `SystemTypeSet` `DebugName` of `SystemTypeSet(fn bevy_ecs::system::function_system::FunctionSystem<fn(), (), (), bevy_dev_tools::schedule_data::serde::tests::linear::a>())`. This includes an extraneous `FunctionSystem` which is only relevant for dealing with the lack of specialization in Rust, as well as extra In/Out args - even though the function dictates these. - This is a step towards #10981. ## Solution - Make `SystemTypeSet` store the function, not the wrapper (e.g., `FunctionSystem`). This should be safe since, a system can only ever have one of either `FunctionSystem` or `ExclusiveFunctionSystem` - either way, this implementation is unique so `SystemTypeSet<F>` will never overlap. - Change debug printing for `SystemTypeSet` to just debug print as `SystemTypeSet:system_name_goes_here`. ## Testing - Tests still pass.
1 parent 912214a commit f8964a4

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

crates/bevy_ecs/src/schedule/set.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::{
1414
define_label,
1515
intern::Interned,
1616
system::{
17-
ExclusiveFunctionSystem, ExclusiveSystemParamFunction, FromInput, FunctionSystem,
18-
IntoResult, IsExclusiveFunctionSystem, IsFunctionSystem, SystemParamFunction,
17+
ExclusiveSystemParamFunction, FromInput, IntoResult, IsExclusiveFunctionSystem,
18+
IsFunctionSystem, SystemParamFunction,
1919
},
2020
};
2121

@@ -196,9 +196,7 @@ impl<T: 'static> SystemTypeSet<T> {
196196

197197
impl<T> Debug for SystemTypeSet<T> {
198198
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
199-
f.debug_tuple("SystemTypeSet")
200-
.field(&format_args!("fn {}()", DebugName::type_name::<T>()))
201-
.finish()
199+
write!(f, "SystemTypeSet:{}", DebugName::type_name::<T>())
202200
}
203201
}
204202

@@ -293,11 +291,11 @@ where
293291
Marker: 'static,
294292
F: SystemParamFunction<Marker, In: FromInput<()>, Out: IntoResult<()>>,
295293
{
296-
type Set = SystemTypeSet<FunctionSystem<Marker, (), (), F>>;
294+
type Set = SystemTypeSet<F>;
297295

298296
#[inline]
299297
fn into_system_set(self) -> Self::Set {
300-
SystemTypeSet::<FunctionSystem<Marker, (), (), F>>::new()
298+
SystemTypeSet::<F>::new()
301299
}
302300
}
303301

@@ -308,11 +306,11 @@ where
308306
F::Out: IntoResult<()>,
309307
F: ExclusiveSystemParamFunction<Marker>,
310308
{
311-
type Set = SystemTypeSet<ExclusiveFunctionSystem<Marker, (), F>>;
309+
type Set = SystemTypeSet<F>;
312310

313311
#[inline]
314312
fn into_system_set(self) -> Self::Set {
315-
SystemTypeSet::<ExclusiveFunctionSystem<Marker, (), F>>::new()
313+
SystemTypeSet::<F>::new()
316314
}
317315
}
318316

crates/bevy_ecs/src/system/exclusive_function_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ where
192192
}
193193

194194
fn default_system_sets(&self) -> Vec<InternedSystemSet> {
195-
let set = crate::schedule::SystemTypeSet::<Self>::new();
195+
let set = crate::schedule::SystemTypeSet::<F>::new();
196196
vec![set.intern()]
197197
}
198198

crates/bevy_ecs/src/system/function_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ where
754754
}
755755

756756
fn default_system_sets(&self) -> Vec<InternedSystemSet> {
757-
let set = crate::schedule::SystemTypeSet::<Self>::new();
757+
let set = crate::schedule::SystemTypeSet::<F>::new();
758758
vec![set.intern()]
759759
}
760760

0 commit comments

Comments
 (0)