Skip to content

Commit 4051465

Browse files
Make NonSendMarker !Send (#19107)
# Objective In #18301, `NonSendMarker` was defined in such a way that it actually implements `Send`. This isn't strictly a soundness issue, as its goal is to be used as a `SystemParam`, and it _does_ appropriately mark system access as `!Send`. It just seems odd that `NonSendMarker: Send`. ## Solution - Made `NonSendMarker` wrap `PhantomData<*mut ()>`, which forces it to be `!Send`. ## Testing - CI --- ## Notes This does mean constructing a `NonSendMarker` _value_ will require using the `SystemParam` trait, but I think that's acceptable as the marker as a value should be rarely required if at all.
1 parent 73cde28 commit 4051465

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ unsafe impl<T: SystemBuffer> SystemParam for Deferred<'_, T> {
14701470
}
14711471

14721472
/// A dummy type that is [`!Send`](Send), to force systems to run on the main thread.
1473-
pub struct NonSendMarker;
1473+
pub struct NonSendMarker(PhantomData<*mut ()>);
14741474

14751475
// SAFETY: No world access.
14761476
unsafe impl SystemParam for NonSendMarker {
@@ -1489,7 +1489,7 @@ unsafe impl SystemParam for NonSendMarker {
14891489
_world: UnsafeWorldCell<'world>,
14901490
_change_tick: Tick,
14911491
) -> Self::Item<'world, 'state> {
1492-
Self
1492+
Self(PhantomData)
14931493
}
14941494
}
14951495

0 commit comments

Comments
 (0)