File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,25 @@ pub struct SyncOnceCell<T> {
47
47
once : Once ,
48
48
// Whether or not the value is initialized is tracked by `state_and_queue`.
49
49
value : UnsafeCell < MaybeUninit < T > > ,
50
- // Make sure dropck understands we're dropping T in our Drop impl.
50
+ /// `PhantomData` to make sure dropck understands we're dropping T in our Drop impl.
51
+ ///
52
+ /// ```compile_fail,E0597
53
+ /// #![feature(once_cell)]
54
+ ///
55
+ /// use std::lazy::SyncOnceCell;
56
+ ///
57
+ /// struct A<'a>(&'a str);
58
+ ///
59
+ /// impl<'a> Drop for A<'a> {
60
+ /// fn drop(&mut self) {}
61
+ /// }
62
+ ///
63
+ /// let cell = SyncOnceCell::new();
64
+ /// {
65
+ /// let s = String::new();
66
+ /// let _ = cell.set(A(&s));
67
+ /// }
68
+ /// ```
51
69
_marker : PhantomData < T > ,
52
70
}
53
71
You can’t perform that action at this time.
0 commit comments