File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ impl<'scope> ScopeBuilder<'scope> {
3333 }
3434 }
3535
36+ // FIXME: &'scope Scope<'scope> means that we can spawn scopes during `scope` and after it.
37+ // and before it.
38+ // FIXME: Scopes spawned outside this function must not have access to `tlv`
3639 pub fn scope < OP , R > ( & ' scope mut self , op : OP ) -> R
3740 where
3841 OP : FnOnce ( & ' scope Scope < ' scope > ) -> R + ' scope ,
@@ -81,7 +84,9 @@ pub struct Scope<'scope> {
8184 /// all of which outlive `'scope`. They're not actually required to be
8285 /// `Sync`, but it's still safe to let the `Scope` implement `Sync` because
8386 /// the closures are only *moved* across threads to be executed.
84- marker : PhantomData < & ' scope ( ) > ,
87+ /// This also ensures 'scope is invariant, which is required for safety,
88+ /// since otherwise you could shrink it as spawn closures which reference shorter data.
89+ marker : PhantomData < Box < FnOnce ( & Scope < ' scope > ) + Send + Sync + ' scope > > ,
8590
8691 /// The TLV at the scope's creation. Used to set the TLV for spawned jobs.
8792 tlv : usize ,
You can’t perform that action at this time.
0 commit comments