Skip to content

Commit addcfeb

Browse files
committed
fix errors
1 parent fbfee24 commit addcfeb

File tree

8 files changed

+71
-124
lines changed

8 files changed

+71
-124
lines changed

crates/bevy_ecs/macros/src/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,11 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
229229
}
230230

231231
fn world_access_level() -> WorldAccessLevel {
232-
let mut exclusive = false;
233232
let mut shared = false;
234233
#(
235234
match #param_fetch::world_access_level() {
236235
WorldAccessLevel::Exclusive => {
237-
exclusive = true;
236+
return WorldAccessLevel::Exclusive;
238237
}
239238
WorldAccessLevel::Shared => {
240239
shared = true;
@@ -243,9 +242,7 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
243242
}
244243
)*
245244

246-
if exclusive {
247-
WorldAccessLevel::Exclusive
248-
} else if shared {
245+
if shared {
249246
WorldAccessLevel::Shared
250247
} else {
251248
WorldAccessLevel::None

crates/bevy_ecs/src/schedule/ambiguity_detection.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ impl SystemOrderAmbiguity {
4545
stage: &SystemStage,
4646
world: &World,
4747
) -> Self {
48-
use crate::schedule::graph_utils::GraphNode;
4948
use SystemStageSegment::*;
5049

5150
// TODO: blocked on https://github.com/bevyengine/bevy/pull/4166
@@ -220,7 +219,7 @@ impl SystemStage {
220219
/// Returns vector containing all pairs of indices of systems with ambiguous execution order,
221220
/// along with specific components that have triggered the warning.
222221
/// Systems must be topologically sorted beforehand.
223-
fn find_ambiguities(systems: &[impl SystemContainer]) -> Vec<(usize, usize, Vec<ComponentId>)> {
222+
fn find_ambiguities(systems: &[SystemContainer]) -> Vec<(usize, usize, Vec<ComponentId>)> {
224223
let mut all_dependencies = Vec::<FixedBitSet>::with_capacity(systems.len());
225224
let mut all_dependants = Vec::<FixedBitSet>::with_capacity(systems.len());
226225
for (index, container) in systems.iter().enumerate() {
@@ -266,9 +265,8 @@ fn find_ambiguities(systems: &[impl SystemContainer]) -> Vec<(usize, usize, Vec<
266265
let a_access = systems[index_a].component_access();
267266
let b_access = systems[index_b].component_access();
268267
if let (Some(a), Some(b)) = (a_access, b_access) {
269-
let conflicts = a.get_conflicts(b);
270-
if !conflicts.is_empty() {
271-
ambiguities.push((index_a, index_b, conflicts));
268+
if !a.is_compatible(b) {
269+
ambiguities.push((index_a, index_b, a.get_conflicts(b)));
272270
}
273271
} else {
274272
ambiguities.push((index_a, index_b, Vec::new()));

crates/bevy_ecs/src/schedule/executor.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::{schedule::FunctionSystemContainer, world::World};
1+
use crate::{schedule::SystemContainer, world::World};
22
use downcast_rs::{impl_downcast, Downcast};
33

44
pub trait ParallelSystemExecutor: Downcast + Send + Sync {
55
/// Called by `SystemStage` whenever `systems` have been changed.
6-
fn rebuild_cached_data(&mut self, systems: &[FunctionSystemContainer]);
6+
fn rebuild_cached_data(&mut self, systems: &[SystemContainer]);
77

8-
fn run_systems(&mut self, systems: &mut [FunctionSystemContainer], world: &mut World);
8+
fn run_systems(&mut self, systems: &mut [SystemContainer], world: &mut World);
99
}
1010

1111
impl_downcast!(ParallelSystemExecutor);
@@ -14,9 +14,9 @@ impl_downcast!(ParallelSystemExecutor);
1414
pub struct SingleThreadedExecutor;
1515

1616
impl ParallelSystemExecutor for SingleThreadedExecutor {
17-
fn rebuild_cached_data(&mut self, _: &[FunctionSystemContainer]) {}
17+
fn rebuild_cached_data(&mut self, _: &[SystemContainer]) {}
1818

19-
fn run_systems(&mut self, systems: &mut [FunctionSystemContainer], world: &mut World) {
19+
fn run_systems(&mut self, systems: &mut [SystemContainer], world: &mut World) {
2020
for system in systems {
2121
if system.should_run() {
2222
#[cfg(feature = "trace")]

crates/bevy_ecs/src/schedule/executor_parallel.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
archetype::ArchetypeComponentId,
33
query::Access,
4-
schedule::{FunctionSystemContainer, ParallelSystemExecutor},
4+
schedule::{ParallelSystemExecutor, SystemContainer},
55
system::MaybeUnsafeCell,
66
world::World,
77
};
@@ -78,7 +78,7 @@ impl Default for ParallelExecutor {
7878
}
7979

8080
impl ParallelSystemExecutor for ParallelExecutor {
81-
fn rebuild_cached_data(&mut self, systems: &[FunctionSystemContainer]) {
81+
fn rebuild_cached_data(&mut self, systems: &[SystemContainer]) {
8282
self.system_metadata.clear();
8383
self.queued.grow(systems.len());
8484
self.running.grow(systems.len());
@@ -109,7 +109,7 @@ impl ParallelSystemExecutor for ParallelExecutor {
109109
}
110110
}
111111

112-
fn run_systems(&mut self, systems: &mut [FunctionSystemContainer], world: &mut World) {
112+
fn run_systems(&mut self, systems: &mut [SystemContainer], world: &mut World) {
113113
#[cfg(test)]
114114
if self.events_sender.is_none() {
115115
let (sender, receiver) = async_channel::unbounded::<SchedulingEvent>();
@@ -172,7 +172,7 @@ impl ParallelExecutor {
172172
fn prepare_systems<'scope>(
173173
&mut self,
174174
scope: &mut Scope<'scope, ()>,
175-
systems: &'scope mut [FunctionSystemContainer],
175+
systems: &'scope mut [SystemContainer],
176176
world: &'scope World,
177177
) {
178178
// These are used as a part of a unit test.

crates/bevy_ecs/src/schedule/stage.rs

+25-52
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use crate::{
55
prelude::IntoSystem,
66
schedule::{
77
graph_utils::{self, DependencyGraphError},
8-
BoxedRunCriteria, DuplicateLabelStrategy, FunctionSystemContainer, GraphNode,
9-
InsertionPoint, ParallelExecutor, ParallelSystemExecutor, RunCriteriaContainer,
10-
RunCriteriaDescriptor, RunCriteriaDescriptorOrLabel, RunCriteriaInner, RunCriteriaLabelId,
11-
ShouldRun, SingleThreadedExecutor, SystemContainer, SystemDescriptor, SystemLabelId,
12-
SystemSet, SystemType,
8+
BoxedRunCriteria, DuplicateLabelStrategy, GraphNode, InsertionPoint, ParallelExecutor,
9+
ParallelSystemExecutor, RunCriteriaContainer, RunCriteriaDescriptor,
10+
RunCriteriaDescriptorOrLabel, RunCriteriaInner, RunCriteriaLabelId, ShouldRun,
11+
SingleThreadedExecutor, SystemContainer, SystemDescriptor, SystemLabelId, SystemSet,
12+
SystemType,
1313
},
1414
world::{World, WorldId},
1515
};
@@ -62,22 +62,22 @@ pub struct SystemStage {
6262
/// Topologically sorted run criteria of systems.
6363
run_criteria: Vec<RunCriteriaContainer>,
6464
/// Topologically sorted exclusive systems that want to be run at the start of the stage.
65-
pub(super) exclusive_at_start: Vec<FunctionSystemContainer>,
65+
pub(super) exclusive_at_start: Vec<SystemContainer>,
6666
/// Topologically sorted exclusive systems that want to be run after parallel systems but
6767
/// before the application of their command buffers.
68-
pub(super) exclusive_before_commands: Vec<FunctionSystemContainer>,
68+
pub(super) exclusive_before_commands: Vec<SystemContainer>,
6969
/// Topologically sorted exclusive systems that want to be run at the end of the stage.
70-
pub(super) exclusive_at_end: Vec<FunctionSystemContainer>,
70+
pub(super) exclusive_at_end: Vec<SystemContainer>,
7171
/// Topologically sorted parallel systems.
72-
pub(super) parallel: Vec<FunctionSystemContainer>,
72+
pub(super) parallel: Vec<SystemContainer>,
7373
/// Determines if the stage was modified and needs to rebuild its graphs and orders.
7474
pub(super) systems_modified: bool,
7575
/// Determines if the stage's executor was changed.
7676
executor_modified: bool,
7777
/// Newly inserted run criteria that will be initialized at the next opportunity.
7878
uninitialized_run_criteria: Vec<(usize, DuplicateLabelStrategy)>,
7979
/// Newly inserted systems that will be initialized at the next opportunity.
80-
uninitialized_systems: Vec<(FunctionSystemContainer, SystemType)>,
80+
uninitialized_systems: Vec<(SystemContainer, SystemType)>,
8181
/// Saves the value of the World change_tick during the last tick check
8282
last_tick_check: u32,
8383
/// If true, buffers will be automatically applied at the end of the stage. If false, buffers must be manually applied.
@@ -155,7 +155,7 @@ impl SystemStage {
155155
self.systems_modified = true;
156156
let system_type = descriptor.system_type;
157157
let criteria = descriptor.run_criteria.take();
158-
let mut container = FunctionSystemContainer::from_descriptor(descriptor);
158+
let mut container = SystemContainer::from_descriptor(descriptor);
159159
match criteria {
160160
Some(RunCriteriaDescriptorOrLabel::Label(label)) => {
161161
container.run_criteria_label = Some(label);
@@ -189,29 +189,29 @@ impl SystemStage {
189189
/// Topologically sorted parallel systems.
190190
///
191191
/// Note that systems won't be fully-formed until the stage has been run at least once.
192-
pub fn parallel_systems(&self) -> &[impl SystemContainer] {
192+
pub fn parallel_systems(&self) -> &[SystemContainer] {
193193
&self.parallel
194194
}
195195

196196
/// Topologically sorted exclusive systems that want to be run at the start of the stage.
197197
///
198198
/// Note that systems won't be fully-formed until the stage has been run at least once.
199-
pub fn exclusive_at_start_systems(&self) -> &[impl SystemContainer] {
199+
pub fn exclusive_at_start_systems(&self) -> &[SystemContainer] {
200200
&self.exclusive_at_start
201201
}
202202

203203
/// Topologically sorted exclusive systems that want to be run at the end of the stage.
204204
///
205205
/// Note that systems won't be fully-formed until the stage has been run at least once.
206-
pub fn exclusive_at_end_systems(&self) -> &[impl SystemContainer] {
206+
pub fn exclusive_at_end_systems(&self) -> &[SystemContainer] {
207207
&self.exclusive_at_end
208208
}
209209

210210
/// Topologically sorted exclusive systems that want to be run after parallel systems but
211211
/// before the application of their command buffers.
212212
///
213213
/// Note that systems won't be fully-formed until the stage has been run at least once.
214-
pub fn exclusive_before_commands_systems(&self) -> &[impl SystemContainer] {
214+
pub fn exclusive_before_commands_systems(&self) -> &[SystemContainer] {
215215
&self.exclusive_before_commands
216216
}
217217

@@ -515,8 +515,8 @@ impl SystemStage {
515515
}
516516
}
517517

518-
fn update_run_criteria_indices<T: SystemContainer>(
519-
systems: &mut [T],
518+
fn update_run_criteria_indices(
519+
systems: &mut [SystemContainer],
520520
order_inverted: &[(usize, &usize)],
521521
) {
522522
for system in systems {
@@ -542,7 +542,7 @@ impl SystemStage {
542542
/// Sorts given system containers topologically, populates their resolved dependencies
543543
/// and run criteria.
544544
fn process_systems(
545-
systems: &mut Vec<impl SystemContainer>,
545+
systems: &mut Vec<SystemContainer>,
546546
run_criteria_labels: &HashMap<RunCriteriaLabelId, usize>,
547547
) -> Result<(), DependencyGraphError<HashSet<SystemLabelId>>> {
548548
let mut graph = graph_utils::build_dependency_graph(systems);
@@ -638,7 +638,7 @@ impl Stage for SystemStage {
638638
run_system_loop = false;
639639

640640
fn should_run(
641-
container: &impl SystemContainer,
641+
container: &SystemContainer,
642642
run_criteria: &[RunCriteriaContainer],
643643
default: ShouldRun,
644644
) -> bool {
@@ -800,7 +800,7 @@ mod tests {
800800
use crate::{
801801
schedule::{
802802
IntoSystemDescriptor, RunCriteria, RunCriteriaDescriptorCoercion, ShouldRun,
803-
SingleThreadedExecutor, Stage, SystemLabel, SystemLabelId, SystemSet, SystemStage,
803+
SingleThreadedExecutor, Stage, SystemLabel, SystemSet, SystemStage,
804804
},
805805
system::{In, Local, Query, ResMut},
806806
world::World,
@@ -978,13 +978,7 @@ mod tests {
978978
.with_system(make_exclusive(1).before(L234).after(L0))
979979
.with_system(make_exclusive(0).label(L0))
980980
.with_system(make_exclusive(4).label(L234).label(L4))
981-
.with_system(
982-
make_exclusive(3)
983-
984-
.label(L234)
985-
.after(L2)
986-
.before(L4),
987-
);
981+
.with_system(make_exclusive(3).label(L234).after(L2).before(L4));
988982
stage.run(&mut world);
989983
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
990984
stage.run(&mut world);
@@ -999,31 +993,11 @@ mod tests {
999993
let mut world = World::new();
1000994
world.init_resource::<EntityCount>();
1001995
let mut stage = SystemStage::parallel()
1002-
.with_system(
1003-
make_exclusive(2)
1004-
1005-
.label(L2)
1006-
.after(L1)
1007-
.before(L3)
1008-
.before(L3),
1009-
)
1010-
.with_system(
1011-
make_exclusive(1)
1012-
1013-
.label(L1)
1014-
.after(L0)
1015-
.after(L0)
1016-
.before(L2),
1017-
)
996+
.with_system(make_exclusive(2).label(L2).after(L1).before(L3).before(L3))
997+
.with_system(make_exclusive(1).label(L1).after(L0).after(L0).before(L2))
1018998
.with_system(make_exclusive(0).label(L0).before(L1))
1019999
.with_system(make_exclusive(4).label(L4).after(L3))
1020-
.with_system(
1021-
make_exclusive(3)
1022-
1023-
.label(L3)
1024-
.after(L2)
1025-
.before(L4),
1026-
);
1000+
.with_system(make_exclusive(3).label(L3).after(L2).before(L4));
10271001
stage.run(&mut world);
10281002
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
10291003
stage.run(&mut world);
@@ -1083,8 +1057,7 @@ mod tests {
10831057
fn exclusive_cycle_1() {
10841058
let mut world = World::new();
10851059
world.init_resource::<EntityCount>();
1086-
let mut stage = SystemStage::parallel()
1087-
.with_system(make_exclusive(0).label(L0).after(L0));
1060+
let mut stage = SystemStage::parallel().with_system(make_exclusive(0).label(L0).after(L0));
10881061
stage.run(&mut world);
10891062
}
10901063

0 commit comments

Comments
 (0)