File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ mod tests;
66use crate :: {
77 cell:: { Cell , UnsafeCell } ,
88 fmt,
9+ marker:: PhantomData ,
910 mem:: { self , MaybeUninit } ,
1011 ops:: { Deref , Drop } ,
1112 panic:: { RefUnwindSafe , UnwindSafe } ,
@@ -46,6 +47,8 @@ pub struct SyncOnceCell<T> {
4647 once : Once ,
4748 // Whether or not the value is initialized is tracked by `state_and_queue`.
4849 value : UnsafeCell < MaybeUninit < T > > ,
50+ // Make sure dropck understands we're dropping T in our Drop impl.
51+ _marker : PhantomData < T > ,
4952}
5053
5154// Why do we need `T: Send`?
@@ -119,7 +122,11 @@ impl<T> SyncOnceCell<T> {
119122 /// Creates a new empty cell.
120123 #[ unstable( feature = "once_cell" , issue = "74465" ) ]
121124 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+ }
123130 }
124131
125132 /// Gets the reference to the underlying value.
You can’t perform that action at this time.
0 commit comments