bevy/crates/bevy_ecs/src/schedule
MiniaczQ e312da8c52
Reduce runtime panics through SystemParam validation (#15276)
# Objective

The goal of this PR is to introduce `SystemParam` validation in order to
reduce runtime panics.

Fixes #15265

## Solution

`SystemParam` now has a new method `validate_param(...) -> bool`, which
takes immutable variants of `get_param` arguments. The returned value
indicates whether the parameter can be acquired from the world. If
parameters cannot be acquired for a system, it won't be executed,
similarly to run conditions. This reduces panics when using params like
`Res`, `ResMut`, etc. as well as allows for new, ergonomic params like
#15264 or #15302.

Param validation happens at the level of executors. All validation
happens directly before executing a system, in case of normal systems
they are skipped, in case of conditions they return false.

Warning about system skipping is primitive and subject to change in
subsequent PRs.

## Testing

Two executor tests check that all executors:
- skip systems which have invalid parameters:
  - piped systems get skipped together,
  - dependent systems still run correctly,
- skip systems with invalid run conditions:
  - system conditions have invalid parameters,
  - system set conditions have invalid parameters.
2024-09-23 16:54:21 +00:00
..
executor Reduce runtime panics through SystemParam validation (#15276) 2024-09-23 16:54:21 +00:00
condition.rs Reduce runtime panics through SystemParam validation (#15276) 2024-09-23 16:54:21 +00:00
config.rs Group IntoSystemConfigs impls together (#15254) 2024-09-17 17:57:22 +00:00
graph_utils.rs Use a unstable sort to sort component ids in bevy_ecs (#13789) 2024-06-17 14:56:19 +00:00
mod.rs Separate component and resource access (#14561) 2024-08-06 01:19:39 +00:00
schedule.rs move ShortName to bevy_reflect (#15340) 2024-09-21 20:52:46 +00:00
set.rs Add on_unimplemented Diagnostics to Most Public Traits (#13347) (#13662) 2024-06-04 00:31:34 +00:00
stepping.rs Fix beta lints (#12980) 2024-04-16 02:46:46 +00:00