]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc/arc.rs
Rename std::ptr::Shared to NonNull
[rust.git] / src / liballoc / arc.rs
index 185af8835d1e49d14da8033e13deefa5329e8a71..49a6220d591a24413f294f0b88a36d7582b03ffa 100644 (file)
@@ -25,7 +25,7 @@
 use core::mem::{self, align_of_val, size_of_val, uninitialized};
 use core::ops::Deref;
 use core::ops::CoerceUnsized;
-use core::ptr::{self, Shared};
+use core::ptr::{self, NonNull};
 use core::marker::{Unsize, PhantomData};
 use core::hash::{Hash, Hasher};
 use core::{isize, usize};
 /// [rc_examples]: ../../std/rc/index.html#examples
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Arc<T: ?Sized> {
-    ptr: Shared<ArcInner<T>>,
+    ptr: NonNull<ArcInner<T>>,
     phantom: PhantomData<T>,
 }
 
@@ -234,7 +234,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
 /// [`None`]: ../../std/option/enum.Option.html#variant.None
 #[stable(feature = "arc_weak", since = "1.4.0")]
 pub struct Weak<T: ?Sized> {
-    ptr: Shared<ArcInner<T>>,
+    ptr: NonNull<ArcInner<T>>,
 }
 
 #[stable(feature = "arc_weak", since = "1.4.0")]
@@ -286,7 +286,7 @@ pub fn new(data: T) -> Arc<T> {
             weak: atomic::AtomicUsize::new(1),
             data,
         };
-        Arc { ptr: Shared::from(Box::into_unique(x)), phantom: PhantomData }
+        Arc { ptr: NonNull::from(Box::into_unique(x)), phantom: PhantomData }
     }
 
     /// Returns the contained value, if the `Arc` has exactly one strong reference.
@@ -397,7 +397,7 @@ pub unsafe fn from_raw(ptr: *const T) -> Self {
         let arc_ptr = set_data_ptr(fake_ptr, (ptr as *mut u8).offset(-offset));
 
         Arc {
-            ptr: Shared::new_unchecked(arc_ptr),
+            ptr: NonNull::new_unchecked(arc_ptr),
             phantom: PhantomData,
         }
     }
@@ -582,7 +582,7 @@ fn from_box(v: Box<T>) -> Arc<T> {
             // Free the allocation without dropping its contents
             box_free(bptr);
 
-            Arc { ptr: Shared::new_unchecked(ptr), phantom: PhantomData }
+            Arc { ptr: NonNull::new_unchecked(ptr), phantom: PhantomData }
         }
     }
 }
@@ -609,7 +609,7 @@ unsafe fn copy_from_slice(v: &[T]) -> Arc<[T]> {
             &mut (*ptr).data as *mut [T] as *mut T,
             v.len());
 
-        Arc { ptr: Shared::new_unchecked(ptr), phantom: PhantomData }
+        Arc { ptr: NonNull::new_unchecked(ptr), phantom: PhantomData }
     }
 }
 
@@ -669,7 +669,7 @@ fn drop(&mut self) {
             // All clear. Forget the guard so it doesn't free the new ArcInner.
             mem::forget(guard);
 
-            Arc { ptr: Shared::new_unchecked(ptr), phantom: PhantomData }
+            Arc { ptr: NonNull::new_unchecked(ptr), phantom: PhantomData }
         }
     }
 }
@@ -991,7 +991,7 @@ impl<T> Weak<T> {
     pub fn new() -> Weak<T> {
         unsafe {
             Weak {
-                ptr: Shared::from(Box::into_unique(box ArcInner {
+                ptr: NonNull::from(Box::into_unique(box ArcInner {
                     strong: atomic::AtomicUsize::new(0),
                     weak: atomic::AtomicUsize::new(1),
                     data: uninitialized(),