Skip to content

Commit

Permalink
remove unnecessary unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird committed Nov 4, 2022
1 parent 9483f1a commit 4453650
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crates/bevy_hierarchy/src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<'w, 's, 'a> DespawnRecursiveExt for EntityCommands<'w, 's, 'a> {

impl<'w> DespawnRecursiveExt for EntityMut<'w> {
/// Despawns the provided entity and its children.
fn despawn_recursive(mut self) {
fn despawn_recursive(self) {
let entity = self.id();

#[cfg(feature = "trace")]
Expand All @@ -114,11 +114,7 @@ impl<'w> DespawnRecursiveExt for EntityMut<'w> {
)
.entered();

// SAFETY: EntityMut is consumed so even though the location is no longer
// valid, it cannot be accessed again with the invalid location.
unsafe {
despawn_with_children_recursive(self.world_mut(), entity);
}
despawn_with_children_recursive(self.into_world_mut(), entity);
}

fn despawn_descendants(&mut self) {
Expand Down

0 comments on commit 4453650

Please sign in to comment.