Skip to content

Commit 0ac3e02

Browse files
committed
auto merge of #8867 : thestinger/rust/smaller-arc, r=alexcrichton
2 parents 1f9bd62 + 05bb4c4 commit 0ac3e02

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/libstd/unstable/sync.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use vec;
2626
/// An atomically reference counted pointer.
2727
///
2828
/// Enforces no shared-memory safety.
29+
#[unsafe_no_drop_flag]
2930
pub struct UnsafeArc<T> {
3031
data: *mut ArcData<T>,
3132
}
@@ -221,8 +222,9 @@ impl<T: Send> Clone for UnsafeArc<T> {
221222
impl<T> Drop for UnsafeArc<T>{
222223
fn drop(&self) {
223224
unsafe {
225+
// Happens when destructing an unwrapper's handle and from `#[unsafe_no_drop_flag]`
224226
if self.data.is_null() {
225-
return; // Happens when destructing an unwrapper's handle.
227+
return
226228
}
227229
let mut data: ~ArcData<T> = cast::transmute(self.data);
228230
// Must be acquire+release, not just release, to make sure this
@@ -440,6 +442,12 @@ mod tests {
440442
use super::{Exclusive, UnsafeArc, atomically};
441443
use task;
442444
use util;
445+
use sys::size_of;
446+
447+
#[test]
448+
fn test_size() {
449+
assert_eq!(size_of::<UnsafeArc<[int, ..10]>>(), size_of::<*[int, ..10]>());
450+
}
443451

444452
#[test]
445453
fn test_atomically() {

0 commit comments

Comments
 (0)