diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 1f1909fd33c..876f335406f 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -316,7 +316,9 @@ impl fmt::Show for Arc { } } +#[stable] impl Default for Arc { + #[stable] fn default() -> Arc { Arc::new(Default::default()) } } diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index c6afeb063fb..879a8cc6951 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -45,11 +45,15 @@ pub static HEAP: () = (); #[unstable = "custom allocators will add an additional type parameter (with default)"] pub struct Box(*mut T); +#[stable] impl Default for Box { + #[stable] fn default() -> Box { box Default::default() } } +#[stable] impl Default for Box<[T]> { + #[stable] fn default() -> Box<[T]> { box [] } } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 7af816f2e09..0257c640d3c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -448,6 +448,7 @@ impl Default for Rc { /// let x: Rc = Default::default(); /// ``` #[inline] + #[stable] fn default() -> Rc { Rc::new(Default::default()) } diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index b107d6640a3..94211592698 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -172,8 +172,10 @@ pub struct BinaryHeap { data: Vec, } +#[stable] impl Default for BinaryHeap { #[inline] + #[stable] fn default() -> BinaryHeap { BinaryHeap::new() } } diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 6113e2323c1..df860d6000e 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -824,8 +824,10 @@ pub fn from_fn(len: uint, mut f: F) -> Bitv where F: FnMut(uint) -> bool { bitv } +#[stable] impl Default for Bitv { #[inline] + #[stable] fn default() -> Bitv { Bitv::new() } } diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index f7d73c10442..c7cbb5a1c29 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -832,7 +832,9 @@ impl, V: Hash> Hash for BTreeMap { } } +#[stable] impl Default for BTreeMap { + #[stable] fn default() -> BTreeMap { BTreeMap::new() } diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index dbba5ebdc99..8f75113c01d 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -439,7 +439,9 @@ impl Extend for BTreeSet { } } +#[stable] impl Default for BTreeSet { + #[stable] fn default() -> BTreeSet { BTreeSet::new() } diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 3ae66954e9c..e7454aef51e 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -192,8 +192,10 @@ impl DList { } } +#[stable] impl Default for DList { #[inline] + #[stable] fn default() -> DList { DList::new() } } diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index 2ad43eb7c74..cdb92d302e9 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -68,7 +68,9 @@ impl Drop for RingBuf { } } +#[stable] impl Default for RingBuf { + #[stable] #[inline] fn default() -> RingBuf { RingBuf::new() } } diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 062946652be..ba89fc133c4 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -826,6 +826,7 @@ impl StrAllocating for String { #[stable] impl Default for String { + #[stable] fn default() -> String { String::new() } diff --git a/src/libcollections/tree/map.rs b/src/libcollections/tree/map.rs index 5c2cf4a8180..2b14f9569b0 100644 --- a/src/libcollections/tree/map.rs +++ b/src/libcollections/tree/map.rs @@ -185,8 +185,10 @@ impl Show for TreeMap { } } +#[stable] impl Default for TreeMap { #[inline] + #[stable] fn default() -> TreeMap { TreeMap::new() } } diff --git a/src/libcollections/tree/set.rs b/src/libcollections/tree/set.rs index 6a0986d3283..c3aebc2736c 100644 --- a/src/libcollections/tree/set.rs +++ b/src/libcollections/tree/set.rs @@ -134,8 +134,10 @@ impl Show for TreeSet { } } +#[stable] impl Default for TreeSet { #[inline] + #[stable] fn default() -> TreeSet { TreeSet::new() } } diff --git a/src/libcollections/trie/map.rs b/src/libcollections/trie/map.rs index a4dee807648..67c5407eb6e 100644 --- a/src/libcollections/trie/map.rs +++ b/src/libcollections/trie/map.rs @@ -150,8 +150,10 @@ impl Show for TrieMap { } } +#[stable] impl Default for TrieMap { #[inline] + #[stable] fn default() -> TrieMap { TrieMap::new() } } diff --git a/src/libcollections/trie/set.rs b/src/libcollections/trie/set.rs index 7b7b4d8280b..5d24673ae75 100644 --- a/src/libcollections/trie/set.rs +++ b/src/libcollections/trie/set.rs @@ -69,8 +69,10 @@ impl Show for TrieSet { } } +#[stable] impl Default for TrieSet { #[inline] + #[stable] fn default() -> TrieSet { TrieSet::new() } } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index fa4cfc99753..1d2c935c90b 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1330,6 +1330,7 @@ impl Drop for Vec { #[stable] impl Default for Vec { + #[stable] fn default() -> Vec { Vec::new() } diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 60390e93753..9f1a0075352 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -66,7 +66,9 @@ pub struct VecMap { v: Vec>, } +#[stable] impl Default for VecMap { + #[stable] #[inline] fn default() -> VecMap { VecMap::new() } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index afb6249e7ae..01979e97577 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -215,8 +215,9 @@ impl Clone for Cell { } } -#[unstable] +#[stable] impl Default for Cell { + #[stable] fn default() -> Cell { Cell::new(Default::default()) } @@ -347,8 +348,9 @@ impl Clone for RefCell { } } -#[unstable] +#[stable] impl Default for RefCell { + #[stable] fn default() -> RefCell { RefCell::new(Default::default()) } diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 269a456542c..10facfe4750 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -97,6 +97,7 @@ /// bar: f32, /// } /// ``` +#[stable] pub trait Default { /// Returns the "default value" for a type. /// @@ -130,13 +131,16 @@ pub trait Default { /// fn default() -> Kind { Kind::A } /// } /// ``` + #[stable] fn default() -> Self; } macro_rules! default_impl( ($t:ty, $v:expr) => { + #[stable] impl Default for $t { #[inline] + #[stable] fn default() -> $t { $v } } } diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 62752072e2f..1f511ed759e 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -203,8 +203,10 @@ impl Clone for SipState { } } +#[stable] impl Default for SipState { #[inline] + #[stable] fn default() -> SipState { SipState::new() } diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 2fc4d23e7fd..e2afee9905d 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -217,6 +217,7 @@ extern "rust-intrinsic" { /// /// `forget` is unsafe because the caller is responsible for /// ensuring the argument is deallocated already. + #[stable] pub fn forget(_: T) -> (); /// Unsafely transforms a value of one type into a value of another type. @@ -232,6 +233,7 @@ extern "rust-intrinsic" { /// let v: &[u8] = unsafe { mem::transmute("L") }; /// assert!(v == [76u8]); /// ``` + #[stable] pub fn transmute(e: T) -> U; /// Gives the address for the return value of the enclosing function. diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 937f73a3262..6747d12e028 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -13,9 +13,13 @@ //! This module contains functions for querying the size and alignment of //! types, initializing and manipulating memory. +#![stable] + +use kinds::Sized; use intrinsics; use ptr; +#[stable] pub use intrinsics::transmute; /// Moves a thing into the void. @@ -223,7 +227,8 @@ pub unsafe fn transmute_copy(src: &T) -> U { #[inline] #[unstable = "this function may be removed in the future due to its \ questionable utility"] -pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T { +pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S, + ptr: &T) -> &'a T { transmute(ptr) } @@ -231,7 +236,8 @@ pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T { #[inline] #[unstable = "this function may be removed in the future due to its \ questionable utility"] -pub unsafe fn copy_mut_lifetime<'a, S, T:'a>(_ptr: &'a mut S, - ptr: &mut T) -> &'a mut T { +pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S, + ptr: &mut T) + -> &'a mut T { transmute(ptr) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 06eb30e88df..deb1cea1c0e 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -763,6 +763,7 @@ impl AsSlice for Option { #[stable] impl Default for Option { + #[stable] #[inline] #[stable] fn default() -> Option { None } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index db8ac810935..411a46ee1bd 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -645,8 +645,9 @@ impl<'a, T, Sized? U: AsSlice> AsSlice for &'a mut U { fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) } } -#[unstable = "waiting for DST"] +#[stable] impl<'a, T> Default for &'a [T] { + #[stable] fn default() -> &'a [T] { &[] } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index bd9a4959c05..1a7467555a5 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2349,7 +2349,9 @@ impl StrPrelude for str { fn len(&self) -> uint { self.repr().len } } +#[stable] impl<'a> Default for &'a str { + #[stable] fn default() -> &'a str { "" } } diff --git a/src/libcore/tuple/mod.rs b/src/libcore/tuple/mod.rs index 8160424be29..5ea84f7db91 100644 --- a/src/libcore/tuple/mod.rs +++ b/src/libcore/tuple/mod.rs @@ -182,6 +182,7 @@ macro_rules! tuple_impls { #[stable] impl<$($T:Default),+> Default for ($($T,)+) { + #[stable] #[inline] fn default() -> ($($T,)+) { ($({ let x: $T = Default::default(); x},)+) diff --git a/src/librand/reseeding.rs b/src/librand/reseeding.rs index 88c870579e6..46ee67940f2 100644 --- a/src/librand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -142,7 +142,9 @@ impl Reseeder for ReseedWithDefault { *rng = Default::default(); } } +#[stable] impl Default for ReseedWithDefault { + #[stable] fn default() -> ReseedWithDefault { ReseedWithDefault } } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index d22e7b2f764..08f5544effb 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1288,7 +1288,9 @@ impl + Show, V: Show, S, H: Hasher> Show for HashMap } } +#[stable] impl, V, S, H: Hasher + Default> Default for HashMap { + #[stable] fn default() -> HashMap { HashMap::with_hasher(Default::default()) } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index c4356d91064..e00c62cbe2d 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -608,7 +608,9 @@ impl, S, H: Hasher + Default> Extend for HashSet { } } +#[stable] impl, S, H: Hasher + Default> Default for HashSet { + #[stable] fn default() -> HashSet { HashSet::with_hasher(Default::default()) } diff --git a/src/libstd/hash.rs b/src/libstd/hash.rs index a63abec96d5..52e3c718b2d 100644 --- a/src/libstd/hash.rs +++ b/src/libstd/hash.rs @@ -95,7 +95,9 @@ impl Hasher for RandomSipHasher { } } +#[stable] impl Default for RandomSipHasher { + #[stable] #[inline] fn default() -> RandomSipHasher { RandomSipHasher::new() diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 6fc9d0bd172..6a6d467e86c 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1911,7 +1911,9 @@ bitflags! { } +#[stable] impl Default for FilePermission { + #[stable] #[inline] fn default() -> FilePermission { FilePermission::empty() } }