File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ mod tests;
6
6
use crate :: {
7
7
cell:: { Cell , UnsafeCell } ,
8
8
fmt,
9
+ marker:: PhantomData ,
9
10
mem:: { self , MaybeUninit } ,
10
11
ops:: { Deref , Drop } ,
11
12
panic:: { RefUnwindSafe , UnwindSafe } ,
@@ -46,6 +47,8 @@ pub struct SyncOnceCell<T> {
46
47
once : Once ,
47
48
// Whether or not the value is initialized is tracked by `state_and_queue`.
48
49
value : UnsafeCell < MaybeUninit < T > > ,
50
+ // Make sure dropck understands we're dropping T in our Drop impl.
51
+ _marker : PhantomData < T > ,
49
52
}
50
53
51
54
// Why do we need `T: Send`?
@@ -119,7 +122,11 @@ impl<T> SyncOnceCell<T> {
119
122
/// Creates a new empty cell.
120
123
#[ unstable( feature = "once_cell" , issue = "74465" ) ]
121
124
pub const fn new ( ) -> SyncOnceCell < T > {
122
- SyncOnceCell { once : Once :: new ( ) , value : UnsafeCell :: new ( MaybeUninit :: uninit ( ) ) }
125
+ SyncOnceCell {
126
+ once : Once :: new ( ) ,
127
+ value : UnsafeCell :: new ( MaybeUninit :: uninit ( ) ) ,
128
+ _marker : PhantomData ,
129
+ }
123
130
}
124
131
125
132
/// Gets the reference to the underlying value.
You can’t perform that action at this time.
0 commit comments