]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #8867 : thestinger/rust/smaller-arc, r=alexcrichton
authorbors <bors@rust-lang.org>
Fri, 30 Aug 2013 12:45:45 +0000 (05:45 -0700)
committerbors <bors@rust-lang.org>
Fri, 30 Aug 2013 12:45:45 +0000 (05:45 -0700)
src/libstd/unstable/sync.rs

index 8d1545ea2b4506061f8c1d1c48c3bf2b3af34a3b..26313323291e5e8d4bef786dec5d989cc6942971 100644 (file)
@@ -26,6 +26,7 @@
 /// An atomically reference counted pointer.
 ///
 /// Enforces no shared-memory safety.
+#[unsafe_no_drop_flag]
 pub struct UnsafeArc<T> {
     data: *mut ArcData<T>,
 }
@@ -221,8 +222,9 @@ fn clone(&self) -> UnsafeArc<T> {
 impl<T> Drop for UnsafeArc<T>{
     fn drop(&self) {
         unsafe {
+            // Happens when destructing an unwrapper's handle and from `#[unsafe_no_drop_flag]`
             if self.data.is_null() {
-                return; // Happens when destructing an unwrapper's handle.
+                return
             }
             let mut data: ~ArcData<T> = cast::transmute(self.data);
             // Must be acquire+release, not just release, to make sure this
@@ -440,6 +442,12 @@ mod tests {
     use super::{Exclusive, UnsafeArc, atomically};
     use task;
     use util;
+    use sys::size_of;
+
+    #[test]
+    fn test_size() {
+        assert_eq!(size_of::<UnsafeArc<[int, ..10]>>(), size_of::<*[int, ..10]>());
+    }
 
     #[test]
     fn test_atomically() {