From fb2067104564f60ace22b144b3c5ef359f297cdb Mon Sep 17 00:00:00 2001 From: JoJoJet Date: Mon, 3 Oct 2022 16:57:31 +0000 Subject: [PATCH] Deduplicate ambiguity reporting code (#6149) # Objective Now that #6083 has been merged, we can clean up some ugly ambiguity detection code. # Solution Deduplicate code. --- .../src/schedule/ambiguity_detection.rs | 44 ++++--------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/ambiguity_detection.rs b/crates/bevy_ecs/src/schedule/ambiguity_detection.rs index 5cd97f8aeb5215..ce4a3360dec067 100644 --- a/crates/bevy_ecs/src/schedule/ambiguity_detection.rs +++ b/crates/bevy_ecs/src/schedule/ambiguity_detection.rs @@ -47,42 +47,16 @@ impl SystemOrderAmbiguity { ) -> Self { use SystemStageSegment::*; - // TODO: blocked on https://github.com/bevyengine/bevy/pull/4166 - // We can't grab the system container generically, because .parallel_systems() - // and the exclusive equivalent return a different type, - // and SystemContainer is not object-safe - let (system_a_name, system_b_name) = match segment { - Parallel => { - let system_container = stage.parallel_systems(); - ( - system_container[system_a_index].name(), - system_container[system_b_index].name(), - ) - } - ExclusiveAtStart => { - let system_container = stage.exclusive_at_start_systems(); - ( - system_container[system_a_index].name(), - system_container[system_b_index].name(), - ) - } - ExclusiveBeforeCommands => { - let system_container = stage.exclusive_before_commands_systems(); - ( - system_container[system_a_index].name(), - system_container[system_b_index].name(), - ) - } - ExclusiveAtEnd => { - let system_container = stage.exclusive_at_end_systems(); - ( - system_container[system_a_index].name(), - system_container[system_b_index].name(), - ) - } + let systems = match segment { + Parallel => stage.parallel_systems(), + ExclusiveAtStart => stage.exclusive_at_start_systems(), + ExclusiveBeforeCommands => stage.exclusive_before_commands_systems(), + ExclusiveAtEnd => stage.exclusive_at_end_systems(), }; - - let mut system_names = [system_a_name.to_string(), system_b_name.to_string()]; + let mut system_names = [ + systems[system_a_index].name().to_string(), + systems[system_b_index].name().to_string(), + ]; system_names.sort(); let mut conflicts: Vec<_> = component_ids