bevy/crates/bevy_ecs/src/system
Ida Iyes 96e09f004b Fix PipeSystem panicking with exclusive systems (#6698)
Without this fix, piped systems containing exclusive systems fail to run, giving a runtime panic.
With this PR, running piped systems that contain exclusive systems now works.

## Explanation of the bug

This is because, unless overridden, the default implementation of `run` from the `System` trait simply calls `run_unsafe`. That is not valid for exclusive systems. They must always be called via `run`, as `run_unsafe` takes `&World` instead of `&mut World`.

Trivial reproduction example:
```rust
fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_system(exclusive.pipe(another))
        .run();
}

fn exclusive(_world: &mut World) {}
fn another() {}
```
If you run this, you will get a panic 'Cannot run exclusive systems with a shared World reference' and the backtrace shows how bevy (correctly) tries to call the `run` method (because the system is exclusive), but it is the implementation from the `System` trait (because `PipeSystem` does not have its own), which calls `run_unsafe` (incorrect):
 - 3: <bevy_ecs::system::system_piping::PipeSystem<SystemA,SystemB> as bevy_ecs::system::system::System>::run_unsafe
 - 4: bevy_ecs::system::system::System::run
2022-11-21 14:23:21 +00:00
..
commands Improve logging consistency for entity despawning (#6501) 2022-11-07 19:23:34 +00:00
exclusive_function_system.rs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
exclusive_system_param.rs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
function_system.rs Rename system chaining to system piping (#6230) 2022-10-11 15:21:12 +00:00
mod.rs Fix query.to_readonly().get_component_mut() soundness bug (#6401) 2022-10-29 04:13:54 +00:00
query.rs Replace WorldQueryGats trait with actual gats (#6319) 2022-11-03 16:33:05 +00:00
system.rs Adding Debug implementations for App, Stage, Schedule, Query, QueryState, etc. (#6214) 2022-10-10 20:59:38 +00:00
system_param.rs Split Component Ticks (#6547) 2022-11-21 12:59:09 +00:00
system_piping.rs Fix PipeSystem panicking with exclusive systems (#6698) 2022-11-21 14:23:21 +00:00