We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 12cc7d9 commit 465c405Copy full SHA for 465c405
library/std/src/thread/scoped.rs
@@ -13,6 +13,19 @@ pub struct Scope<'env> {
13
data: ScopeData,
14
/// Invariance over 'env, to make sure 'env cannot shrink,
15
/// which is necessary for soundness.
16
+ ///
17
+ /// Without invariance, this would compile fine but be unsound:
18
19
+ /// ```compile_fail
20
+ /// #![feature(scoped_threads)]
21
22
+ /// std::thread::scope(|s| {
23
+ /// s.spawn(|s| {
24
+ /// let a = String::from("abcd");
25
+ /// s.spawn(|_| println!("{:?}", a)); // might run after `a` is dropped
26
+ /// });
27
28
+ /// ```
29
env: PhantomData<&'env mut &'env ()>,
30
}
31
0 commit comments