@@ -233,7 +233,9 @@ impl<T> Drop for RWLock<T> {
233
233
}
234
234
}
235
235
236
- static DUMMY : UnsafeCell < ( ) > = UnsafeCell { value : ( ) } ;
236
+ struct Dummy ( UnsafeCell < ( ) > ) ;
237
+ unsafe impl Sync for Dummy { }
238
+ static DUMMY : Dummy = Dummy ( UnsafeCell { value : ( ) } ) ;
237
239
238
240
impl StaticRWLock {
239
241
/// Locks this rwlock with shared read access, blocking the current thread
@@ -244,7 +246,7 @@ impl StaticRWLock {
244
246
#[ unstable = "may be merged with RWLock in the future" ]
245
247
pub fn read ( & ' static self ) -> LockResult < RWLockReadGuard < ' static , ( ) > > {
246
248
unsafe { self . lock . read ( ) }
247
- RWLockReadGuard :: new ( self , & DUMMY )
249
+ RWLockReadGuard :: new ( self , & DUMMY . 0 )
248
250
}
249
251
250
252
/// Attempt to acquire this lock with shared read access.
@@ -255,7 +257,7 @@ impl StaticRWLock {
255
257
pub fn try_read ( & ' static self )
256
258
-> TryLockResult < RWLockReadGuard < ' static , ( ) > > {
257
259
if unsafe { self . lock . try_read ( ) } {
258
- Ok ( try!( RWLockReadGuard :: new ( self , & DUMMY ) ) )
260
+ Ok ( try!( RWLockReadGuard :: new ( self , & DUMMY . 0 ) ) )
259
261
} else {
260
262
Err ( TryLockError :: WouldBlock )
261
263
}
@@ -269,7 +271,7 @@ impl StaticRWLock {
269
271
#[ unstable = "may be merged with RWLock in the future" ]
270
272
pub fn write ( & ' static self ) -> LockResult < RWLockWriteGuard < ' static , ( ) > > {
271
273
unsafe { self . lock . write ( ) }
272
- RWLockWriteGuard :: new ( self , & DUMMY )
274
+ RWLockWriteGuard :: new ( self , & DUMMY . 0 )
273
275
}
274
276
275
277
/// Attempt to lock this rwlock with exclusive write access.
@@ -280,7 +282,7 @@ impl StaticRWLock {
280
282
pub fn try_write ( & ' static self )
281
283
-> TryLockResult < RWLockWriteGuard < ' static , ( ) > > {
282
284
if unsafe { self . lock . try_write ( ) } {
283
- Ok ( try!( RWLockWriteGuard :: new ( self , & DUMMY ) ) )
285
+ Ok ( try!( RWLockWriteGuard :: new ( self , & DUMMY . 0 ) ) )
284
286
} else {
285
287
Err ( TryLockError :: WouldBlock )
286
288
}
0 commit comments