Replace UnsafeCell<World> usage with UnsafeWorldCell in CombinatorSystem (#14706)
# Objective Replace usage of `UnsafeCell<World>` with our standard `UnsafeWorldCell` that seemed to have been missed. ## Solution Do just that.
This commit is contained in:
parent
91fa4bb649
commit
7f658cabf7
@ -1,6 +1,4 @@
|
|||||||
use std::{borrow::Cow, cell::UnsafeCell, marker::PhantomData};
|
use std::{borrow::Cow, marker::PhantomData};
|
||||||
|
|
||||||
use bevy_ptr::UnsafeCellDeref;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
archetype::ArchetypeComponentId,
|
archetype::ArchetypeComponentId,
|
||||||
@ -182,18 +180,16 @@ where
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run<'w>(&mut self, input: Self::In, world: &'w mut World) -> Self::Out {
|
fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out {
|
||||||
// SAFETY: Converting `&mut T` -> `&UnsafeCell<T>`
|
let world = world.as_unsafe_world_cell();
|
||||||
// is explicitly allowed in the docs for `UnsafeCell`.
|
|
||||||
let world: &'w UnsafeCell<World> = unsafe { std::mem::transmute(world) };
|
|
||||||
Func::combine(
|
Func::combine(
|
||||||
input,
|
input,
|
||||||
// SAFETY: Since these closures are `!Send + !Sync + !'static`, they can never
|
// SAFETY: Since these closures are `!Send + !Sync + !'static`, they can never
|
||||||
// be called in parallel. Since mutable access to `world` only exists within
|
// be called in parallel. Since mutable access to `world` only exists within
|
||||||
// the scope of either closure, we can be sure they will never alias one another.
|
// the scope of either closure, we can be sure they will never alias one another.
|
||||||
|input| self.a.run(input, unsafe { world.deref_mut() }),
|
|input| self.a.run(input, unsafe { world.world_mut() }),
|
||||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||||
|input| self.b.run(input, unsafe { world.deref_mut() }),
|
|input| self.b.run(input, unsafe { world.world_mut() }),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user