Skip to content

Commit 38f18cc

Browse files
Fix logic for ignoring ambiguities
1 parent 2a798bc commit 38f18cc

File tree

2 files changed

+41
-23
lines changed

2 files changed

+41
-23
lines changed

crates/bevy_ecs/src/schedule/ambiguity_detection.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ pub fn find_ambiguities(
7070
systems: &[impl SystemContainer],
7171
crates_filter: &[String],
7272
// Should explicit attempts to ignore ambiguities be obeyed?
73-
respect_ignores: bool,
73+
report_level: ReportExecutionOrderAmbiguities,
7474
) -> Vec<SystemOrderAmbiguity> {
7575
fn should_ignore_ambiguity(
7676
systems: &[impl SystemContainer],
7777
index_a: usize,
7878
index_b: usize,
7979
crates_filter: &[String],
80-
respect_ignores: bool,
80+
report_level: ReportExecutionOrderAmbiguities,
8181
) -> bool {
82-
if !respect_ignores {
82+
if report_level == ReportExecutionOrderAmbiguities::Deterministic {
8383
return false;
8484
}
8585

@@ -144,13 +144,7 @@ pub fn find_ambiguities(
144144
// .take(index_a)
145145
{
146146
if !processed.contains(index_b)
147-
&& !should_ignore_ambiguity(
148-
systems,
149-
index_a,
150-
index_b,
151-
crates_filter,
152-
respect_ignores,
153-
)
147+
&& !should_ignore_ambiguity(systems, index_a, index_b, crates_filter, report_level)
154148
{
155149
let a_access = systems[index_a].component_access();
156150
let b_access = systems[index_b].component_access();
@@ -230,16 +224,14 @@ impl SystemStage {
230224
Vec::default()
231225
};
232226

233-
let respect_ignores = report_level == ReportExecutionOrderAmbiguities::Deterministic;
234-
235-
let parallel = find_ambiguities(&self.parallel, &ignored_crates, respect_ignores);
236-
let at_start = find_ambiguities(&self.exclusive_at_start, &ignored_crates, respect_ignores);
227+
let parallel = find_ambiguities(&self.parallel, &ignored_crates, report_level);
228+
let at_start = find_ambiguities(&self.exclusive_at_start, &ignored_crates, report_level);
237229
let before_commands = find_ambiguities(
238230
&self.exclusive_before_commands,
239231
&ignored_crates,
240-
respect_ignores,
232+
report_level,
241233
);
242-
let at_end = find_ambiguities(&self.exclusive_at_end, &ignored_crates, respect_ignores);
234+
let at_end = find_ambiguities(&self.exclusive_at_end, &ignored_crates, report_level);
243235

244236
[parallel, at_start, before_commands, at_end]
245237
}
@@ -424,7 +416,7 @@ mod tests {
424416
let test_stage = make_test_stage();
425417
assert_eq!(
426418
test_stage.n_ambiguities(ReportExecutionOrderAmbiguities::Minimal),
427-
3
419+
2
428420
);
429421
}
430422

@@ -433,7 +425,7 @@ mod tests {
433425
let test_stage = make_test_stage();
434426
assert_eq!(
435427
test_stage.n_ambiguities(ReportExecutionOrderAmbiguities::Verbose),
436-
3
428+
2
437429
);
438430
}
439431

crates/bevy_ecs/src/schedule/stage.rs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,11 +1420,12 @@ mod tests {
14201420
use super::SystemContainer;
14211421
use crate::schedule::find_ambiguities;
14221422
use crate::schedule::BoxedSystemLabel;
1423+
use crate::schedule::ReportExecutionOrderAmbiguities;
14231424

14241425
fn find_ambiguities_first_str_labels(
14251426
systems: &[impl SystemContainer],
14261427
) -> Vec<(BoxedSystemLabel, BoxedSystemLabel)> {
1427-
find_ambiguities(systems, &[], true)
1428+
find_ambiguities(systems, &[], ReportExecutionOrderAmbiguities::Deterministic)
14281429
.drain(..)
14291430
.map(|ambiguity| {
14301431
(
@@ -1439,7 +1440,11 @@ mod tests {
14391440
systems: &[impl SystemContainer],
14401441
filter: &[String],
14411442
) -> Vec<(BoxedSystemLabel, BoxedSystemLabel)> {
1442-
let mut find_ambiguities = find_ambiguities(systems, filter, true);
1443+
let mut find_ambiguities = find_ambiguities(
1444+
systems,
1445+
filter,
1446+
ReportExecutionOrderAmbiguities::Deterministic,
1447+
);
14431448

14441449
find_ambiguities
14451450
.drain(..)
@@ -1480,7 +1485,15 @@ mod tests {
14801485
.with_system(empty.label("4"));
14811486
stage.initialize_systems(&mut world);
14821487
stage.rebuild_orders_and_dependencies();
1483-
assert_eq!(find_ambiguities(&stage.parallel, &[], false).len(), 0);
1488+
assert_eq!(
1489+
find_ambiguities(
1490+
&stage.parallel,
1491+
&[],
1492+
ReportExecutionOrderAmbiguities::Deterministic
1493+
)
1494+
.len(),
1495+
0
1496+
);
14841497

14851498
let mut stage = SystemStage::parallel()
14861499
.with_system(empty.label("0"))
@@ -1520,7 +1533,15 @@ mod tests {
15201533
.with_system(component.label("4"));
15211534
stage.initialize_systems(&mut world);
15221535
stage.rebuild_orders_and_dependencies();
1523-
assert_eq!(find_ambiguities(&stage.parallel, &[], false).len(), 0);
1536+
assert_eq!(
1537+
find_ambiguities(
1538+
&stage.parallel,
1539+
&[],
1540+
ReportExecutionOrderAmbiguities::Deterministic
1541+
)
1542+
.len(),
1543+
0
1544+
);
15241545

15251546
let mut stage = SystemStage::parallel()
15261547
.with_system(component.label("0"))
@@ -1755,7 +1776,12 @@ mod tests {
17551776
stage.initialize_systems(&mut world);
17561777
stage.rebuild_orders_and_dependencies();
17571778
assert_eq!(
1758-
find_ambiguities(&stage.exclusive_at_start, &[], false).len(),
1779+
find_ambiguities(
1780+
&stage.exclusive_at_start,
1781+
&[],
1782+
ReportExecutionOrderAmbiguities::Deterministic
1783+
)
1784+
.len(),
17591785
0
17601786
);
17611787

0 commit comments

Comments
 (0)