From e5da6a71a6a0b46dd3630fc8326e6d5906a1fde6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 23 Jul 2014 19:10:12 -0700 Subject: std: Stabilize unit, bool, ty, tuple, arc, any This commit applies stability attributes to the contents of these modules, summarized here: * The `unit` and `bool` modules have become #[unstable] as they are purely meant for documentation purposes and are candidates for removal. * The `ty` module has been deprecated, and the inner `Unsafe` type has been renamed to `UnsafeCell` and moved to the `cell` module. The `marker1` field has been removed as the compiler now always infers `UnsafeCell` to be invariant. The `new` method i stable, but the `value` field, `get` and `unwrap` methods are all unstable. * The `tuple` module has its name as stable, the naming of the `TupleN` traits as stable while the methods are all #[unstable]. The other impls in the module have appropriate stability for the corresponding trait. * The `arc` module has received the exact same treatment as the `rc` module previously did. * The `any` module has its name as stable. The `Any` trait is also stable, with a new private supertrait which now contains the `get_type_id` method. This is to make the method a private implementation detail rather than a public-facing detail. The two extension traits in the module are marked #[unstable] as they will not be necessary with DST. The `is` method is #[stable], the as_{mut,ref} methods have been renamed to downcast_{mut,ref} and are #[unstable]. The extension trait `BoxAny` has been clarified as to why it is unstable as it will not be necessary with DST. This is a breaking change because the `marker1` field was removed from the `UnsafeCell` type. To deal with this change, you can simply delete the field and only specify the value of the `data` field in static initializers. [breaking-change] --- src/liballoc/arc.rs | 20 ++++++++++++++------ src/liballoc/boxed.rs | 5 ++++- src/liballoc/rc.rs | 1 - 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/liballoc') diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 27174de8e74..1ac2c9fc6be 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! - * Concurrency-enabled mechanisms for sharing mutable and/or immutable state - * between tasks. - */ +#![stable] + +//! Concurrency-enabled mechanisms for sharing mutable and/or immutable state +//! between tasks. use core::atomics; use core::clone::Clone; @@ -51,6 +51,7 @@ use heap::deallocate; /// } /// ``` #[unsafe_no_drop_flag] +#[stable] pub struct Arc { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -62,6 +63,7 @@ pub struct Arc { /// Weak pointers will not keep the data inside of the `Arc` alive, and can be /// used to break cycles between `Arc` pointers. #[unsafe_no_drop_flag] +#[experimental = "Weak pointers may not belong in this module."] pub struct Weak { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -77,6 +79,7 @@ struct ArcInner { impl Arc { /// Create an atomically reference counted wrapper. #[inline] + #[stable] pub fn new(data: T) -> Arc { // Start the weak pointer count as 1 which is the weak pointer that's // held by all the strong pointers (kinda), see std/rc.rs for more info @@ -103,6 +106,7 @@ impl Arc { /// Weak pointers will not keep the data alive. Once all strong references /// to the underlying data have been dropped, the data itself will be /// destroyed. + #[experimental = "Weak pointers may not belong in this module."] pub fn downgrade(&self) -> Weak { // See the clone() impl for why this is relaxed self.inner().weak.fetch_add(1, atomics::Relaxed); @@ -110,7 +114,7 @@ impl Arc { } } -#[unstable] +#[unstable = "waiting on stability of Clone"] impl Clone for Arc { /// Duplicate an atomically reference counted wrapper. /// @@ -135,6 +139,7 @@ impl Clone for Arc { } } +#[experimental = "Deref is experimental."] impl Deref for Arc { #[inline] fn deref<'a>(&'a self) -> &'a T { @@ -169,6 +174,7 @@ impl Arc { } #[unsafe_destructor] +#[experimental = "waiting on stability of Drop"] impl Drop for Arc { fn drop(&mut self) { // This structure has #[unsafe_no_drop_flag], so this drop glue may run @@ -212,6 +218,7 @@ impl Drop for Arc { } } +#[experimental = "Weak pointers may not belong in this module."] impl Weak { /// Attempts to upgrade this weak reference to a strong reference. /// @@ -237,7 +244,7 @@ impl Weak { } } -#[unstable] +#[experimental = "Weak pointers may not belong in this module."] impl Clone for Weak { #[inline] fn clone(&self) -> Weak { @@ -248,6 +255,7 @@ impl Clone for Weak { } #[unsafe_destructor] +#[experimental = "Weak pointers may not belong in this module."] impl Drop for Weak { fn drop(&mut self) { // see comments above for why this check is here diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 89f6e934ad2..58278d5664e 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -87,10 +87,12 @@ impl Ord for Box { impl Eq for Box {} /// Extension methods for an owning `Any` trait object -#[unstable = "post-DST, the signature of `downcast` will change to take `Box`"] +#[unstable = "post-DST and coherence changes, this will not be a trait but \ + rather a direct `impl` on `Box`"] pub trait BoxAny { /// Returns the boxed value if it is of type `T`, or /// `Err(Self)` if it isn't. + #[unstable = "naming conventions around accessing innards may change"] fn downcast(self) -> Result, Self>; /// Deprecated; this method has been renamed to `downcast`. @@ -100,6 +102,7 @@ pub trait BoxAny { } } +#[stable] impl BoxAny for Box { #[inline] fn downcast(self) -> Result, Box> { diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 8d4e788bc80..b31931c6de3 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -379,7 +379,6 @@ impl Drop for Weak { } } -#[unstable] #[experimental = "Weak pointers may not belong in this module."] impl Clone for Weak { #[inline] -- cgit 1.4.1-3-g733a5