bevy/crates/bevy_ecs/src
Boxy 637a149910 unsafeify World::entities_mut (#4093)
# Objective
make bevy ecs a lil bit less unsound

## Solution
make unsound API unsafe so that there is an unsafe block to blame:

```rust
use bevy_ecs::prelude::*;

#[derive(Debug, Component)]
struct Foo(u8);

fn main() {
    let mut world = World::new();
    let e1 = world.spawn().id();
    let e2 = world.spawn().insert(Foo(2)).id();
    world.entities_mut().meta[0] = world.entities_mut().meta[1].clone();
    let foo = world.entity(e1).get::<Foo>().unwrap();
    // whoo i love having components i dont have
    dbg!(foo);
}
```

This is not _strictly_ speaking UB, however: 
- `Query::get_multiple` cannot work if this is allowed
- bevy_ecs is a pile of unsafe code whose soundness generally depends on the world being in a "correct" state with "no funny business" so it seems best to disallow this
- it is trivial to get bevy to panic inside of functions with safety invariants that have been violated (the entity location is not valid)
- it seems to violate what the safety invariant on `Entities::flush` is trying to ensure
2022-03-30 23:52:45 +00:00
..
entity unsafeify World::entities_mut (#4093) 2022-03-30 23:52:45 +00:00
query Add get_multiple and get_multiple_mut APIs for Query and QueryState (#4298) 2022-03-30 19:16:48 +00:00
schedule Auto-label function systems with SystemTypeIdLabel (#4224) 2022-03-23 22:53:56 +00:00
storage Proper prehashing (#3963) 2022-02-18 03:26:01 +00:00
system Add get_multiple and get_multiple_mut APIs for Query and QueryState (#4298) 2022-03-30 19:16:48 +00:00
world unsafeify World::entities_mut (#4093) 2022-03-30 23:52:45 +00:00
archetype.rs Change Cow<[ComponentId]> to Box<[ComponentId]> (#4185) 2022-03-19 04:14:27 +00:00
bundle.rs small and mostly pointless refactoring (#2934) 2022-02-13 22:33:55 +00:00
change_detection.rs add missing into_inner to ReflectMut (#3841) 2022-02-04 03:37:45 +00:00
component.rs small and mostly pointless refactoring (#2934) 2022-02-13 22:33:55 +00:00
event.rs small and mostly pointless refactoring (#2934) 2022-02-13 22:33:55 +00:00
lib.rs ParamSet for conflicting SystemParam:s (#2765) 2022-03-29 23:39:38 +00:00
reflect.rs Add FromReflect trait to convert dynamic types to concrete types (#1395) 2021-12-26 18:49:01 +00:00