diff options
| author | bors <bors@rust-lang.org> | 2015-03-27 23:11:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-27 23:11:21 +0000 |
| commit | 552080181c58beef03493a110b4a38b20b6b5da5 (patch) | |
| tree | 3dbfd8c87647f67e1d17c726e72b153609d7eea8 /src/liballoc | |
| parent | 0c9de8140b8abdd2d0a83db93746c58e8bc0da2c (diff) | |
| parent | d3a4f362cba36a4bf0bb8f8a951ae9d6858ae73e (diff) | |
| download | rust-552080181c58beef03493a110b4a38b20b6b5da5.tar.gz rust-552080181c58beef03493a110b4a38b20b6b5da5.zip | |
Auto merge of #23796 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 12 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 9 |
4 files changed, 17 insertions, 12 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index b5d16d29272..338d7e33631 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -33,7 +33,7 @@ //! //! Sharing some immutable data between tasks: //! -//! ``` +//! ```no_run //! use std::sync::Arc; //! use std::thread; //! @@ -50,7 +50,7 @@ //! //! Sharing mutable data safely between tasks with a `Mutex`: //! -//! ``` +//! ```no_run //! use std::sync::{Arc, Mutex}; //! use std::thread; //! @@ -94,6 +94,9 @@ use heap::deallocate; /// With simple pipes, without `Arc`, a copy would have to be made for each /// task. /// +/// When you clone an `Arc<T>`, it will create another pointer to the data and +/// increase the reference counter. +/// /// ``` /// # #![feature(alloc, core)] /// use std::sync::Arc; @@ -354,7 +357,8 @@ impl<T> Drop for Arc<T> { // more than once (but it is guaranteed to be zeroed after the first if // it's run more than once) let ptr = *self._ptr; - if ptr.is_null() { return } + // if ptr.is_null() { return } + if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return } // Because `fetch_sub` is already atomic, we do not need to synchronize // with other threads unless we are going to delete the object. This @@ -485,7 +489,7 @@ impl<T> Drop for Weak<T> { let ptr = *self._ptr; // see comments above for why this check is here - if ptr.is_null() { return } + if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return } // If we find out that we were the last weak pointer, then its time to // deallocate the data entirely. See the discussion in Arc::drop() about diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 8b18fbf554a..f9bd0ab2f1e 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -244,13 +244,13 @@ pub trait BoxAny { /// Returns the boxed value if it is of type `T`, or /// `Err(Self)` if it isn't. #[stable(feature = "rust1", since = "1.0.0")] - fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>>; + fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>>; } #[stable(feature = "rust1", since = "1.0.0")] impl BoxAny for Box<Any> { #[inline] - fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> { + fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> { if self.is::<T>() { unsafe { // Get the raw representation of the trait object @@ -270,7 +270,7 @@ impl BoxAny for Box<Any> { #[stable(feature = "rust1", since = "1.0.0")] impl BoxAny for Box<Any+Send> { #[inline] - fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> { + fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> { <Box<Any>>::downcast(self) } } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 541de2d37fb..b92dfa9117e 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -75,7 +75,7 @@ #![feature(box_syntax)] #![feature(optin_builtin_traits)] #![feature(unboxed_closures)] -#![feature(unsafe_no_drop_flag)] +#![feature(unsafe_no_drop_flag, filling_drop)] #![feature(core)] #![feature(unique)] #![cfg_attr(test, feature(test, alloc, rustc_private))] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index eb3c5c16726..7cdd4888426 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -160,7 +160,7 @@ use core::default::Default; use core::fmt; use core::hash::{Hasher, Hash}; use core::marker; -use core::mem::{min_align_of, size_of, forget}; +use core::mem::{self, min_align_of, size_of, forget}; use core::nonzero::NonZero; use core::ops::{Deref, Drop}; use core::option::Option; @@ -407,7 +407,7 @@ impl<T> Drop for Rc<T> { fn drop(&mut self) { unsafe { let ptr = *self._ptr; - if !ptr.is_null() { + if !ptr.is_null() && ptr as usize != mem::POST_DROP_USIZE { self.dec_strong(); if self.strong() == 0 { ptr::read(&**self); // destroy the contained object @@ -431,7 +431,8 @@ impl<T> Clone for Rc<T> { /// Makes a clone of the `Rc<T>`. /// - /// This increases the strong reference count. + /// When you clone an `Rc<T>`, it will create another pointer to the data and + /// increase the strong reference counter. /// /// # Examples /// @@ -718,7 +719,7 @@ impl<T> Drop for Weak<T> { fn drop(&mut self) { unsafe { let ptr = *self._ptr; - if !ptr.is_null() { + if !ptr.is_null() && ptr as usize != mem::POST_DROP_USIZE { self.dec_weak(); // the weak count starts at 1, and will only go to zero if all // the strong pointers have disappeared. |
