Skip to content

Commit

Permalink
yeet World::components_mut >:( (bevyengine#4092)
Browse files Browse the repository at this point in the history
# Objective
make bevy ecs a lil bit less unsound
## Solution
yeet unsound API `World::components_mut`:
```rust
use bevy_ecs::prelude::*;

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

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

fn main() {
    let mut world = World::new();
    let e = world.spawn().insert(Foo(0)).id();
    *world.components_mut() = Default::default();
    let bar = world.entity_mut(e).remove::<Bar>().unwrap();
    // oopsies reading memory copied from outside allocation
    dbg!(bar);
}
```
  • Loading branch information
BoxyUwU authored and ItsDoot committed Feb 1, 2023
1 parent 2cf2149 commit c222b34
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ impl World {
&self.components
}

/// Retrieves a mutable reference to this world's [Components] collection
#[inline]
pub fn components_mut(&mut self) -> &mut Components {
&mut self.components
}

/// Retrieves this world's [Storages] collection
#[inline]
pub fn storages(&self) -> &Storages {
Expand Down

0 comments on commit c222b34

Please sign in to comment.