From d6bd8d8491e89277edbfc9a4e0f8953847abbdd6 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Fri, 16 Oct 2015 11:54:05 -0400 Subject: Add `Shared` pointer and have `{Arc, Rc}` use it This change has two consequences: 1. It makes `Arc` and `Rc` covariant in `T`. 2. It causes the compiler to reject code that was unsound with respect to dropck. See compile-fail/issue-29106.rs for an example of code that no longer compiles. Because of this, this is a [breaking-change]. Fixes #29037. Fixes #29106. --- src/libstd/sync/mutex.rs | 1 + src/libstd/sync/rwlock.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index aabc06b1986..c0cd6d127d2 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -293,6 +293,7 @@ impl Mutex { #[stable(feature = "rust1", since = "1.0.0")] impl Drop for Mutex { + #[unsafe_destructor_blind_to_params] fn drop(&mut self) { // This is actually safe b/c we know that there is no further usage of // this mutex (it's up to the user to arrange for a mutex to get diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 9278481f2d6..750c9e30c5c 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -314,6 +314,7 @@ impl RwLock { #[stable(feature = "rust1", since = "1.0.0")] impl Drop for RwLock { + #[unsafe_destructor_blind_to_params] fn drop(&mut self) { // IMPORTANT: This code needs to be kept in sync with `RwLock::into_inner`. unsafe { self.inner.lock.destroy() } -- cgit 1.4.1-3-g733a5