diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-01-28 23:03:36 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-01-28 23:31:03 +0530 |
| commit | c709ed2faf4ea28df1395a924453b5298b87fa57 (patch) | |
| tree | 9567cea197e37b96607f471b18dd1c77908c8965 /src/liballoc | |
| parent | 249c29fe2746d251dc8aab63cd8730df9ff8434c (diff) | |
| parent | a45e117733b866302fa99390553d1c548508dcca (diff) | |
| download | rust-c709ed2faf4ea28df1395a924453b5298b87fa57.tar.gz rust-c709ed2faf4ea28df1395a924453b5298b87fa57.zip | |
Merge remote-tracking branch 'origin/master' into rollup
Conflicts: src/libcollections/slice.rs src/libcore/nonzero.rs src/libcore/ops.rs
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 49 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 46 | ||||
| -rw-r--r-- | src/liballoc/heap.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/lib.rs | 7 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 60 |
5 files changed, 86 insertions, 78 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 5f8cd6baf9a..1b75289c64f 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![stable] +#![stable(feature = "rust1", since = "1.0.0")] //! Threadsafe reference-counted boxes (the `Arc<T>` type). //! @@ -110,7 +110,7 @@ use heap::deallocate; /// } /// ``` #[unsafe_no_drop_flag] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct Arc<T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -126,7 +126,8 @@ unsafe impl<T: Sync + Send> Sync for Arc<T> { } /// 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 = "Weak pointers may not belong in this module."] +#[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] pub struct Weak<T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -156,7 +157,7 @@ impl<T> Arc<T> { /// let five = Arc::new(5i); /// ``` #[inline] - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn new(data: T) -> Arc<T> { // 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 @@ -179,7 +180,8 @@ impl<T> Arc<T> { /// /// let weak_five = five.downgrade(); /// ``` - #[unstable = "Weak pointers may not belong in this module."] + #[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] pub fn downgrade(&self) -> Weak<T> { // See the clone() impl for why this is relaxed self.inner().weak.fetch_add(1, Relaxed); @@ -200,15 +202,15 @@ impl<T> Arc<T> { /// Get the number of weak references to this value. #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn weak_count<T>(this: &Arc<T>) -> uint { this.inner().weak.load(SeqCst) - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn strong_count<T>(this: &Arc<T>) -> uint { this.inner().strong.load(SeqCst) } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Clone for Arc<T> { /// Makes a clone of the `Arc<T>`. /// @@ -245,7 +247,7 @@ impl<T> BorrowFrom<Arc<T>> for T { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Deref for Arc<T> { type Target = T; @@ -271,7 +273,7 @@ impl<T: Send + Sync + Clone> Arc<T> { /// let mut_five = five.make_unique(); /// ``` #[inline] - #[unstable] + #[unstable(feature = "alloc")] pub fn make_unique(&mut self) -> &mut T { // Note that we hold a strong reference, which also counts as a weak reference, so we only // clone if there is an additional reference of either kind. @@ -289,7 +291,7 @@ impl<T: Send + Sync + Clone> Arc<T> { } #[unsafe_destructor] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Sync + Send> Drop for Arc<T> { /// Drops the `Arc<T>`. /// @@ -355,7 +357,8 @@ impl<T: Sync + Send> Drop for Arc<T> { } } -#[unstable = "Weak pointers may not belong in this module."] +#[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] impl<T: Sync + Send> Weak<T> { /// Upgrades a weak reference to a strong reference. /// @@ -393,7 +396,8 @@ impl<T: Sync + Send> Weak<T> { } } -#[unstable = "Weak pointers may not belong in this module."] +#[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] impl<T: Sync + Send> Clone for Weak<T> { /// Makes a clone of the `Weak<T>`. /// @@ -417,7 +421,7 @@ impl<T: Sync + Send> Clone for Weak<T> { } #[unsafe_destructor] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Sync + Send> Drop for Weak<T> { /// Drops the `Weak<T>`. /// @@ -460,7 +464,7 @@ impl<T: Sync + Send> Drop for Weak<T> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: PartialEq> PartialEq for Arc<T> { /// Equality for two `Arc<T>`s. /// @@ -492,7 +496,7 @@ impl<T: PartialEq> PartialEq for Arc<T> { /// ``` fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: PartialOrd> PartialOrd for Arc<T> { /// Partial comparison for two `Arc<T>`s. /// @@ -571,30 +575,30 @@ impl<T: PartialOrd> PartialOrd for Arc<T> { /// ``` fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Ord> Ord for Arc<T> { fn cmp(&self, other: &Arc<T>) -> Ordering { (**self).cmp(&**other) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Eq> Eq for Arc<T> {} -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Display> fmt::Display for Arc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug> fmt::Debug for Arc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Default + Sync + Send> Default for Arc<T> { - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn default() -> Arc<T> { Arc::new(Default::default()) } } @@ -605,7 +609,6 @@ impl<H: Hasher, T: Hash<H>> Hash<H> for Arc<T> { } #[cfg(test)] -#[allow(unstable)] mod tests { use std::clone::Clone; use std::sync::mpsc::channel; diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index c4abedf3fe8..51e5fc5820c 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -43,7 +43,7 @@ //! //! This will print `Cons(1i32, Box(Cons(2i32, Box(Nil))))`. -#![stable] +#![stable(feature = "rust1", since = "1.0.0")] use core::any::Any; use core::clone::Clone; @@ -77,14 +77,15 @@ use core::result::Result; /// } /// ``` #[lang = "exchange_heap"] -#[unstable = "may be renamed; uncertain about custom allocator design"] +#[unstable(feature = "alloc", + reason = "may be renamed; uncertain about custom allocator design")] pub static HEAP: () = (); /// A pointer type for heap allocation. /// /// See the [module-level documentation](../../std/boxed/index.html) for more. #[lang = "owned_box"] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct Box<T>(Unique<T>); impl<T> Box<T> { @@ -95,25 +96,25 @@ impl<T> Box<T> { /// ``` /// let x = Box::new(5); /// ``` - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn new(x: T) -> Box<T> { box x } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Default> Default for Box<T> { - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn default() -> Box<T> { box Default::default() } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Default for Box<[T]> { - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn default() -> Box<[T]> { box [] } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Clone> Clone for Box<T> { /// Returns a new box with a `clone()` of this box's contents. /// @@ -144,14 +145,14 @@ impl<T: Clone> Clone for Box<T> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + PartialEq> PartialEq for Box<T> { #[inline] fn eq(&self, other: &Box<T>) -> bool { PartialEq::eq(&**self, &**other) } #[inline] fn ne(&self, other: &Box<T>) -> bool { PartialEq::ne(&**self, &**other) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + PartialOrd> PartialOrd for Box<T> { #[inline] fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> { @@ -166,14 +167,14 @@ impl<T: ?Sized + PartialOrd> PartialOrd for Box<T> { #[inline] fn gt(&self, other: &Box<T>) -> bool { PartialOrd::gt(&**self, &**other) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + Ord> Ord for Box<T> { #[inline] fn cmp(&self, other: &Box<T>) -> Ordering { Ord::cmp(&**self, &**other) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + Eq> Eq for Box<T> {} impl<S: hash::Hasher, T: ?Sized + Hash<S>> Hash<S> for Box<T> { @@ -184,19 +185,20 @@ impl<S: hash::Hasher, T: ?Sized + Hash<S>> Hash<S> for Box<T> { } /// Extension methods for an owning `Any` trait object. -#[unstable = "this trait will likely disappear once compiler bugs blocking \ - a direct impl on `Box<Any>` have been fixed "] +#[unstable(feature = "alloc", + reason = "this trait will likely disappear once compiler bugs blocking \ + a direct impl on `Box<Any>` have been fixed ")] // FIXME(#18737): this should be a direct impl on `Box<Any>`. If you're // removing this please make sure that you can downcase on // `Box<Any + Send>` as well as `Box<Any>` pub trait BoxAny { /// Returns the boxed value if it is of type `T`, or /// `Err(Self)` if it isn't. - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn downcast<T: 'static>(self) -> Result<Box<T>, Self>; } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl BoxAny for Box<Any> { #[inline] fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> { @@ -215,35 +217,35 @@ impl BoxAny for Box<Any> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Display + ?Sized> fmt::Display for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Box<Any> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Box<Any>") } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> Deref for Box<T> { type Target = T; fn deref(&self) -> &T { &**self } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> DerefMut for Box<T> { fn deref_mut(&mut self) -> &mut T { &mut **self } } diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index a2643f4d0f7..dcbd4d57cf9 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -80,7 +80,7 @@ pub fn usable_size(size: uint, align: uint) -> uint { /// /// These statistics may be inconsistent if other threads use the allocator /// during the call. -#[unstable] +#[unstable(feature = "alloc")] pub fn stats_print() { imp::stats_print(); } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 231ef6e7e74..6830a1c33df 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -57,7 +57,8 @@ //! default global allocator. It is not compatible with the libc allocator API. #![crate_name = "alloc"] -#![unstable] +#![unstable(feature = "alloc")] +#![feature(staged_api)] #![staged_api] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -66,13 +67,15 @@ #![no_std] #![allow(unknown_features)] -#![allow(unstable)] #![feature(lang_items, unsafe_destructor)] #![feature(box_syntax)] #![feature(optin_builtin_traits)] // FIXME(#21363) remove `old_impl_check` when bug is fixed #![feature(old_impl_check)] #![allow(unknown_features)] #![feature(int_uint)] +#![feature(core)] +#![feature(hash)] +#![feature(libc)] #[macro_use] extern crate core; diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 5e82c4f1ade..d41673f56ed 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -142,7 +142,7 @@ //! } //! ``` -#![stable] +#![stable(feature = "rust1", since = "1.0.0")] use core::borrow::BorrowFrom; use core::cell::Cell; @@ -173,7 +173,7 @@ struct RcBox<T> { /// /// See the [module level documentation](../index.html) for more details. #[unsafe_no_drop_flag] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] pub struct Rc<T> { // FIXME #12808: strange names to try to avoid interfering with field accesses of the contained // type via Deref @@ -185,7 +185,6 @@ impl<T> !marker::Send for Rc<T> {} impl<T> !marker::Sync for Rc<T> {} impl<T> Rc<T> { - /// Constructs a new `Rc<T>`. /// /// # Examples @@ -195,7 +194,7 @@ impl<T> Rc<T> { /// /// let five = Rc::new(5i); /// ``` - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] pub fn new(value: T) -> Rc<T> { unsafe { Rc { @@ -222,7 +221,8 @@ impl<T> Rc<T> { /// /// let weak_five = five.downgrade(); /// ``` - #[unstable = "Weak pointers may not belong in this module"] + #[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module")] pub fn downgrade(&self) -> Weak<T> { self.inc_weak(); Weak { _ptr: self._ptr } @@ -231,12 +231,12 @@ impl<T> Rc<T> { /// Get the number of weak references to this value. #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn weak_count<T>(this: &Rc<T>) -> uint { this.weak() - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn strong_count<T>(this: &Rc<T>) -> uint { this.strong() } /// Returns true if there are no other `Rc` or `Weak<T>` values that share the same inner value. @@ -252,7 +252,7 @@ pub fn strong_count<T>(this: &Rc<T>) -> uint { this.strong() } /// rc::is_unique(&five); /// ``` #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn is_unique<T>(rc: &Rc<T>) -> bool { weak_count(rc) == 0 && strong_count(rc) == 1 } @@ -274,7 +274,7 @@ pub fn is_unique<T>(rc: &Rc<T>) -> bool { /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4u))); /// ``` #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> { if is_unique(&rc) { unsafe { @@ -308,7 +308,7 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> { /// assert!(rc::get_mut(&mut x).is_none()); /// ``` #[inline] -#[unstable] +#[unstable(feature = "alloc")] pub fn get_mut<'a, T>(rc: &'a mut Rc<T>) -> Option<&'a mut T> { if is_unique(rc) { let inner = unsafe { &mut **rc._ptr }; @@ -334,7 +334,7 @@ impl<T: Clone> Rc<T> { /// let mut_five = five.make_unique(); /// ``` #[inline] - #[unstable] + #[unstable(feature = "alloc")] pub fn make_unique(&mut self) -> &mut T { if !is_unique(self) { *self = Rc::new((**self).clone()) @@ -354,7 +354,7 @@ impl<T> BorrowFrom<Rc<T>> for T { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Deref for Rc<T> { type Target = T; @@ -365,7 +365,7 @@ impl<T> Deref for Rc<T> { } #[unsafe_destructor] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Drop for Rc<T> { /// Drops the `Rc<T>`. /// @@ -413,7 +413,7 @@ impl<T> Drop for Rc<T> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Clone for Rc<T> { /// Makes a clone of the `Rc<T>`. @@ -436,7 +436,7 @@ impl<T> Clone for Rc<T> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Default> Default for Rc<T> { /// Creates a new `Rc<T>`, with the `Default` value for `T`. /// @@ -449,13 +449,13 @@ impl<T: Default> Default for Rc<T> { /// let x: Rc<int> = Default::default(); /// ``` #[inline] - #[stable] + #[stable(feature = "rust1", since = "1.0.0")] fn default() -> Rc<T> { Rc::new(Default::default()) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: PartialEq> PartialEq for Rc<T> { /// Equality for two `Rc<T>`s. /// @@ -490,10 +490,10 @@ impl<T: PartialEq> PartialEq for Rc<T> { fn ne(&self, other: &Rc<T>) -> bool { **self != **other } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Eq> Eq for Rc<T> {} -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: PartialOrd> PartialOrd for Rc<T> { /// Partial comparison for two `Rc<T>`s. /// @@ -578,7 +578,7 @@ impl<T: PartialOrd> PartialOrd for Rc<T> { fn ge(&self, other: &Rc<T>) -> bool { **self >= **other } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: Ord> Ord for Rc<T> { /// Comparison for two `Rc<T>`s. /// @@ -605,14 +605,14 @@ impl<S: hash::Hasher, T: Hash<S>> Hash<S> for Rc<T> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Display> fmt::Display for Rc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug> fmt::Debug for Rc<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) @@ -625,21 +625,21 @@ impl<T: fmt::Debug> fmt::Debug for Rc<T> { /// /// See the [module level documentation](../index.html) for more. #[unsafe_no_drop_flag] -#[unstable = "Weak pointers may not belong in this module."] +#[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] pub struct Weak<T> { // FIXME #12808: strange names to try to avoid interfering with // field accesses of the contained type via Deref _ptr: NonZero<*mut RcBox<T>>, } -#[allow(unstable)] impl<T> !marker::Send for Weak<T> {} -#[allow(unstable)] impl<T> !marker::Sync for Weak<T> {} -#[unstable = "Weak pointers may not belong in this module."] +#[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] impl<T> Weak<T> { /// Upgrades a weak reference to a strong reference. @@ -670,7 +670,7 @@ impl<T> Weak<T> { } #[unsafe_destructor] -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T> Drop for Weak<T> { /// Drops the `Weak<T>`. /// @@ -713,7 +713,8 @@ impl<T> Drop for Weak<T> { } } -#[unstable = "Weak pointers may not belong in this module."] +#[unstable(feature = "alloc", + reason = "Weak pointers may not belong in this module.")] impl<T> Clone for Weak<T> { /// Makes a clone of the `Weak<T>`. @@ -736,7 +737,7 @@ impl<T> Clone for Weak<T> { } } -#[stable] +#[stable(feature = "rust1", since = "1.0.0")] impl<T: fmt::Debug> fmt::Debug for Weak<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "(Weak)") @@ -777,7 +778,6 @@ impl<T> RcBoxPtr<T> for Weak<T> { } #[cfg(test)] -#[allow(unstable)] mod tests { use super::{Rc, Weak, weak_count, strong_count}; use std::cell::RefCell; |
