aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo_arc/lib.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2019-05-07 03:16:21 +0000
committerEmilio Cobos Álvarez <emilio@crisal.io>2019-05-10 12:42:53 +0200
commit1fba297bbc1816b4b5498c56bef3add4cf886666 (patch)
tree3e3eae64f5b71c275e0d51398a435de93e6436a4 /components/servo_arc/lib.rs
parentb1b47d8046ada8f6c7dc2da65ab68018b0676b0e (diff)
downloadservo-1fba297bbc1816b4b5498c56bef3add4cf886666.tar.gz
servo-1fba297bbc1816b4b5498c56bef3add4cf886666.zip
style: ThinArc should use NonNull.
If only for parallelism with Arc<>. Differential Revision: https://phabricator.services.mozilla.com/D30131
Diffstat (limited to 'components/servo_arc/lib.rs')
-rw-r--r--components/servo_arc/lib.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs
index f4a929e23f8..7d89238603f 100644
--- a/components/servo_arc/lib.rs
+++ b/components/servo_arc/lib.rs
@@ -21,7 +21,7 @@
//!
//! [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1360883
-// The semantics of `Arc` are alread documented in the Rust docs, so we don't
+// The semantics of `Arc` are already documented in the Rust docs, so we don't
// duplicate those here.
#![allow(missing_docs)]
@@ -767,7 +767,7 @@ type HeaderSliceWithLength<H, T> = HeaderSlice<HeaderWithLength<H>, T>;
/// via `HeaderSliceWithLength`.
#[repr(C)]
pub struct ThinArc<H, T> {
- ptr: *mut ArcInner<HeaderSliceWithLength<H, [T; 1]>>,
+ ptr: ptr::NonNull<ArcInner<HeaderSliceWithLength<H, [T; 1]>>>,
}
unsafe impl<H: Sync + Send, T: Sync + Send> Send for ThinArc<H, T> {}
@@ -796,7 +796,7 @@ impl<H, T> ThinArc<H, T> {
// Synthesize transient Arc, which never touches the refcount of the ArcInner.
let transient = unsafe {
NoDrop::new(Arc {
- p: ptr::NonNull::new_unchecked(thin_to_thick(self.ptr)),
+ p: ptr::NonNull::new_unchecked(thin_to_thick(self.ptr.as_ptr())),
})
};
@@ -851,7 +851,7 @@ impl<H, T> ThinArc<H, T> {
if is_static {
ptr::null()
} else {
- self.ptr as *const ArcInner<T> as *const c_void
+ self.ptr.as_ptr() as *const ArcInner<T> as *const c_void
}
}
}
@@ -861,7 +861,7 @@ impl<H, T> Deref for ThinArc<H, T> {
#[inline]
fn deref(&self) -> &Self::Target {
- unsafe { &(*thin_to_thick(self.ptr)).data }
+ unsafe { &(*thin_to_thick(self.ptr.as_ptr())).data }
}
}
@@ -893,7 +893,9 @@ impl<H, T> Arc<HeaderSliceWithLength<H, [T]>> {
mem::forget(a);
let thin_ptr = fat_ptr as *mut [usize] as *mut usize;
ThinArc {
- ptr: thin_ptr as *mut ArcInner<HeaderSliceWithLength<H, [T; 1]>>,
+ ptr: unsafe {
+ ptr::NonNull::new_unchecked(thin_ptr as *mut ArcInner<HeaderSliceWithLength<H, [T; 1]>>)
+ },
}
}
@@ -901,7 +903,7 @@ impl<H, T> Arc<HeaderSliceWithLength<H, [T]>> {
/// is not modified.
#[inline]
pub fn from_thin(a: ThinArc<H, T>) -> Self {
- let ptr = thin_to_thick(a.ptr);
+ let ptr = thin_to_thick(a.ptr.as_ptr());
mem::forget(a);
unsafe {
Arc {