@@ -124,8 +124,11 @@ use std::{
124
124
///
125
125
/// # Safety
126
126
///
127
- /// The implementor must ensure that [`SystemParam::init_state`] correctly registers all
128
- /// [`World`] accesses used by this [`SystemParam`] with the provided [`system_meta`](SystemMeta).
127
+ /// The implementor must ensure the following is true.
128
+ /// - [`SystemParam::init_state`] correctly registers all [`World`] accesses used
129
+ /// by [`SystemParam::get_param`] with the provided [`system_meta`](SystemMeta).
130
+ /// - None of the world accesses may conflict with any prior accesses registered
131
+ /// on `system_meta`.
129
132
pub unsafe trait SystemParam : Sized {
130
133
/// Used to store data which persists across invocations of a system.
131
134
type State : Send + Sync + ' static ;
@@ -158,7 +161,9 @@ pub unsafe trait SystemParam: Sized {
158
161
/// # Safety
159
162
///
160
163
/// This call might use any of the [`World`] accesses that were registered in [`Self::init_state`].
161
- /// You must ensure that none of those accesses conflict with any other [`SystemParam`]s running in parallel with this one.
164
+ /// - None of those accesses may conflict with any other [`SystemParam`]s
165
+ /// that exist at the same time, including those on other threads.
166
+ /// - `world` must be the same `World` that was used to initialize [`state`](SystemParam::init_state).
162
167
unsafe fn get_param < ' world , ' state > (
163
168
state : & ' state mut Self :: State ,
164
169
system_meta : & SystemMeta ,
@@ -589,7 +594,7 @@ unsafe impl<'a, T: Resource> SystemParam for Option<ResMut<'a, T>> {
589
594
// SAFETY: Commands only accesses internal state
590
595
unsafe impl < ' w , ' s > ReadOnlySystemParam for Commands < ' w , ' s > { }
591
596
592
- // SAFETY: only local state is accessed
597
+ // SAFETY: `Commands::get_param` does not access the world.
593
598
unsafe impl SystemParam for Commands < ' _ , ' _ > {
594
599
type State = CommandQueue ;
595
600
type Item < ' w , ' s > = Commands < ' w , ' s > ;
@@ -1305,7 +1310,6 @@ unsafe impl<'s> ReadOnlySystemParam for SystemName<'s> {}
1305
1310
1306
1311
macro_rules! impl_system_param_tuple {
1307
1312
( $( $param: ident) ,* ) => {
1308
-
1309
1313
// SAFETY: tuple consists only of ReadOnlySystemParams
1310
1314
unsafe impl <$( $param: ReadOnlySystemParam ) ,* > ReadOnlySystemParam for ( $( $param, ) * ) { }
1311
1315
0 commit comments