From c44f5399e4dd2f9d55e107d365d6fe98f6491dc9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 Jun 2015 11:52:41 -0700 Subject: [PATCH] alloc: Split apart the global `alloc` feature --- src/liballoc/arc.rs | 16 ++++++++-------- src/liballoc/boxed.rs | 6 +++--- src/liballoc/heap.rs | 7 ++++++- src/liballoc/lib.rs | 10 +++++++--- src/liballoc/rc.rs | 20 ++++++++++---------- src/libarena/lib.rs | 3 ++- src/libcollections/lib.rs | 3 +++ src/liblog/lib.rs | 5 +++-- src/librustc_resolve/lib.rs | 2 +- src/librustc_trans/lib.rs | 2 +- src/libstd/lib.rs | 3 +++ src/libtest/lib.rs | 13 +++++++------ 12 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 616071f0df7..e0d459d877f 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -134,7 +134,7 @@ impl, U: ?Sized> CoerceUnsized> for 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] -#[unstable(feature = "alloc", +#[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] pub struct Weak { // FIXME #12808: strange name to try to avoid interfering with @@ -198,7 +198,7 @@ impl Arc { /// /// let weak_five = five.downgrade(); /// ``` - #[unstable(feature = "alloc", + #[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] pub fn downgrade(&self) -> Weak { // See the clone() impl for why this is relaxed @@ -236,12 +236,12 @@ impl Arc { /// Get the number of weak references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "arc_extras")] pub fn weak_count(this: &Arc) -> usize { this.inner().weak.load(SeqCst) - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "arc_extras")] pub fn strong_count(this: &Arc) -> usize { this.inner().strong.load(SeqCst) } @@ -271,7 +271,7 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.loa /// # } /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "arc_extras")] pub unsafe fn get_mut(this: &mut Arc) -> Option<&mut T> { // FIXME(#24880) potential race with upgraded weak pointers here if strong_count(this) == 1 && weak_count(this) == 0 { @@ -352,7 +352,7 @@ impl Arc { /// # } /// ``` #[inline] - #[unstable(feature = "alloc")] + #[unstable(feature = "arc_extras")] pub unsafe fn make_unique(&mut self) -> &mut T { // FIXME(#24880) potential race with upgraded weak pointers here // @@ -438,7 +438,7 @@ impl Drop for Arc { } } -#[unstable(feature = "alloc", +#[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] impl Weak { /// Upgrades a weak reference to a strong reference. @@ -479,7 +479,7 @@ impl Weak { } } -#[unstable(feature = "alloc", +#[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] impl Clone for Weak { /// Makes a clone of the `Weak`. diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 91cbd3915d0..ffc4186dee8 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -81,7 +81,7 @@ use core::raw::{TraitObject}; /// } /// ``` #[lang = "exchange_heap"] -#[unstable(feature = "alloc", +#[unstable(feature = "box_heap", reason = "may be renamed; uncertain about custom allocator design")] pub const HEAP: () = (); @@ -121,7 +121,7 @@ impl Box { /// Function is unsafe, because improper use of this function may /// lead to memory problems like double-free, for example if the /// function is called twice on the same raw pointer. - #[unstable(feature = "alloc", + #[unstable(feature = "box_raw", reason = "may be renamed or moved out of Box scope")] #[inline] pub unsafe fn from_raw(raw: *mut T) -> Self { @@ -146,7 +146,7 @@ impl Box { /// let raw = boxed::into_raw(seventeen); /// let boxed_again = unsafe { Box::from_raw(raw) }; /// ``` -#[unstable(feature = "alloc", +#[unstable(feature = "box_raw", reason = "may be renamed")] #[inline] pub fn into_raw(b: Box) -> *mut T { diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 1cc63588fdd..14797d7f4b5 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -8,6 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![unstable(feature = "heap_api", + reason = "the precise API and guarantees it provides may be tweaked \ + slightly, especially to possibly take into account the \ + types being stored to make room for a future \ + tracing garbage collector")] + use core::{isize, usize}; #[inline(always)] @@ -94,7 +100,6 @@ pub fn usable_size(size: usize, align: usize) -> usize { /// /// These statistics may be inconsistent if other threads use the allocator /// during the call. -#[unstable(feature = "alloc")] pub fn stats_print() { imp::stats_print(); } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 91585c3cb6c..e297d4cbf77 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -59,9 +59,11 @@ // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "alloc"] -#![unstable(feature = "alloc")] -#![staged_api] #![crate_type = "rlib"] +#![staged_api] +#![unstable(feature = "alloc", + reason = "this library is unlikely to be stabilized in its current \ + form or name")] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", @@ -86,11 +88,11 @@ #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] #![feature(unsize)] + #![cfg_attr(test, feature(test, alloc, rustc_private))] #![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")), feature(libc))] - #[macro_use] extern crate core; @@ -124,6 +126,7 @@ pub mod rc; /// Common out-of-memory routine #[cold] #[inline(never)] +#[unstable(feature = "oom", reason = "not a scrutinized interface")] pub fn oom() -> ! { // FIXME(#14674): This really needs to do something other than just abort // here, but any printing done must be *guaranteed* to not @@ -144,4 +147,5 @@ pub fn oom() -> ! { // to get linked in to libstd successfully (the linker won't // optimize it out). #[doc(hidden)] +#[unstable(feature = "issue_14344_fixme")] pub fn fixme_14344_be_sure_to_link_to_collections() {} diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 44f4a6a6290..04dde7a07f9 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -236,7 +236,7 @@ impl Rc { /// /// let weak_five = five.downgrade(); /// ``` - #[unstable(feature = "alloc", + #[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module")] pub fn downgrade(&self) -> Weak { self.inc_weak(); @@ -246,12 +246,12 @@ impl Rc { /// Get the number of weak references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn weak_count(this: &Rc) -> usize { this.weak() - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn strong_count(this: &Rc) -> usize { this.strong() } /// Returns true if there are no other `Rc` or `Weak` values that share the @@ -269,7 +269,7 @@ pub fn strong_count(this: &Rc) -> usize { this.strong() } /// rc::is_unique(&five); /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn is_unique(rc: &Rc) -> bool { weak_count(rc) == 0 && strong_count(rc) == 1 } @@ -292,7 +292,7 @@ pub fn is_unique(rc: &Rc) -> bool { /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn try_unwrap(rc: Rc) -> Result> { if is_unique(&rc) { unsafe { @@ -327,7 +327,7 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// assert!(rc::get_mut(&mut x).is_none()); /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { if is_unique(rc) { let inner = unsafe { &mut **rc._ptr }; @@ -354,7 +354,7 @@ impl Rc { /// let mut_five = five.make_unique(); /// ``` #[inline] - #[unstable(feature = "alloc")] + #[unstable(feature = "rc_extras")] pub fn make_unique(&mut self) -> &mut T { if !is_unique(self) { *self = Rc::new((**self).clone()) @@ -652,7 +652,7 @@ impl fmt::Pointer for Rc { /// /// See the [module level documentation](./index.html) for more. #[unsafe_no_drop_flag] -#[unstable(feature = "alloc", +#[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module.")] pub struct Weak { // FIXME #12808: strange names to try to avoid interfering with @@ -663,7 +663,7 @@ pub struct Weak { impl !marker::Send for Weak {} impl !marker::Sync for Weak {} -#[unstable(feature = "alloc", +#[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module.")] impl Weak { @@ -741,7 +741,7 @@ impl Drop for Weak { } } -#[unstable(feature = "alloc", +#[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module.")] impl Clone for Weak { diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 73641647bf4..109ad8a942c 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -33,10 +33,11 @@ #![feature(alloc)] #![feature(box_syntax)] #![feature(core_intrinsics)] +#![feature(heap_api)] +#![feature(oom)] #![feature(ptr_as_ref)] #![feature(raw)] #![feature(staged_api)] -#![feature(unboxed_closures)] #![cfg_attr(test, feature(test))] extern crate alloc; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 0c1349bc2e6..ecf5bace382 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -29,6 +29,7 @@ #![feature(alloc)] #![feature(box_patterns)] +#![feature(box_raw)] #![feature(box_syntax)] #![feature(copy_lifetime)] #![feature(core)] @@ -36,6 +37,7 @@ #![feature(core_prelude)] #![feature(core_slice_ext)] #![feature(core_str_ext)] +#![feature(heap_api)] #![feature(iter_cmp)] #![feature(iter_idx)] #![feature(iter_order)] @@ -43,6 +45,7 @@ #![feature(iter_sum)] #![feature(lang_items)] #![feature(num_bits_bytes)] +#![feature(oom)] #![feature(pattern)] #![feature(ptr_as_ref)] #![feature(raw)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 0760ccb723b..0238bf1f4be 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -169,10 +169,11 @@ html_playground_url = "http://play.rust-lang.org/")] #![deny(missing_docs)] -#![feature(alloc)] -#![feature(staged_api)] +#![feature(box_raw)] #![feature(box_syntax)] +#![feature(const_fn)] #![feature(iter_cmp)] +#![feature(staged_api)] #![feature(std_misc)] use std::boxed; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c47922dd954..0c0fd3f93dc 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -19,9 +19,9 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(alloc)] #![feature(associated_consts)] #![feature(collections)] +#![feature(rc_weak)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 6173e3c8205..d0fadd6565c 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -25,7 +25,6 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(alloc)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(collections)] @@ -40,6 +39,7 @@ #![feature(path_relative_from)] #![feature(path_relative_from)] #![feature(quote)] +#![feature(rc_weak)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8f7ed6388f5..75044881223 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -107,6 +107,7 @@ #![feature(allow_internal_unstable)] #![feature(associated_consts)] #![feature(borrow_state)] +#![feature(box_raw)] #![feature(box_syntax)] #![feature(char_internals)] #![feature(collections)] @@ -117,6 +118,7 @@ #![feature(core_prelude)] #![feature(core_simd)] #![feature(fnbox)] +#![feature(heap_api)] #![feature(int_error_internals)] #![feature(into_cow)] #![feature(iter_order)] @@ -126,6 +128,7 @@ #![feature(macro_reexport)] #![feature(no_std)] #![feature(num_bits_bytes)] +#![feature(oom)] #![feature(optin_builtin_traits)] #![feature(rand)] #![feature(raw)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 9850e0a6c2f..6ee6f8c2e24 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -37,14 +37,15 @@ #![feature(asm)] #![feature(box_syntax)] #![feature(collections)] -#![feature(core)] -#![feature(rustc_private)] -#![feature(staged_api)] -#![feature(std_misc)] -#![feature(libc)] -#![feature(set_stdio)] #![feature(duration)] #![feature(duration_span)] +#![feature(fnbox)] +#![feature(iter_cmp)] +#![feature(libc)] +#![feature(rustc_private)] +#![feature(set_stdio)] +#![feature(staged_api)] +#![feature(std_misc)] extern crate getopts; extern crate serialize;