bevy/crates/bevy_ecs/src
JoJoJet 3fba34c9e6
Require read-only queries in QueryState::par_iter (#8832)
# Objective

The method `QueryState::par_iter` does not currently force the query to
be read-only. This means you can unsoundly mutate a world through an
immutable reference in safe code.

```rust
fn bad_system(world: &World, mut query: Local<QueryState<&mut T>>) {
    query.par_iter(world).for_each_mut(|mut x| *x = unsoundness);
}
```

## Solution

Use read-only versions of the `WorldQuery` types.

---

## Migration Guide

The function `QueryState::par_iter` now forces any world accesses to be
read-only, similar to how `QueryState::iter` works. Any code that
previously mutated the world using this method was *unsound*. If you
need to mutate the world, use `par_iter_mut` instead.
2023-06-13 01:17:40 +00:00
..
entity Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
query Require read-only queries in QueryState::par_iter (#8832) 2023-06-13 01:17:40 +00:00
schedule Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
storage Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
system Implement Clone for CombinatorSystem (#8826) 2023-06-12 19:44:51 +00:00
world Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
archetype.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
bundle.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
change_detection.rs Allow unsized types as mapped value in Ref::map (#8817) 2023-06-12 17:52:11 +00:00
component.rs Add last_changed_tick and added_tick to ComponentTicks (#8803) 2023-06-12 17:55:09 +00:00
event.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
lib.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
reflect.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00
removal_detection.rs Document every public item in bevy_ecs (#8731) 2023-06-10 23:23:48 +00:00