Fallout: AtomicPtr needs phantom data to indicate that it contains an unsafe pointer.

This commit is contained in:
Niko Matsakis 2015-02-12 10:47:02 -05:00
parent 2bcf3a4cd1
commit 1735e41d1c

View File

@ -76,6 +76,7 @@ use marker::Sync;
use intrinsics;
use cell::UnsafeCell;
use marker::PhantomData;
/// A boolean type which can be safely shared between threads.
#[stable(feature = "rust1", since = "1.0.0")]
@ -105,6 +106,7 @@ unsafe impl Sync for AtomicUsize {}
#[stable(feature = "rust1", since = "1.0.0")]
pub struct AtomicPtr<T> {
p: UnsafeCell<usize>,
_marker: PhantomData<*mut T>,
}
unsafe impl<T> Sync for AtomicPtr<T> {}
@ -791,7 +793,8 @@ impl<T> AtomicPtr<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(p: *mut T) -> AtomicPtr<T> {
AtomicPtr { p: UnsafeCell::new(p as usize) }
AtomicPtr { p: UnsafeCell::new(p as usize),
_marker: PhantomData }
}
/// Loads a value from the pointer.