Skip to content

Commit 1572479

Browse files
committed
rollup merge of #19902: alexcrichton/second-pass-mem
This commit stabilizes the `mem` and `default` modules of std.
2 parents 8aa9876 + 9021f61 commit 1572479

30 files changed

+68
-6
lines changed

src/liballoc/arc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ impl<T: fmt::Show> fmt::Show for Arc<T> {
316316
}
317317
}
318318

319+
#[stable]
319320
impl<T: Default + Sync + Send> Default for Arc<T> {
321+
#[stable]
320322
fn default() -> Arc<T> { Arc::new(Default::default()) }
321323
}
322324

src/liballoc/boxed.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ pub static HEAP: () = ();
4444
#[unstable = "custom allocators will add an additional type parameter (with default)"]
4545
pub struct Box<T>(*mut T);
4646

47+
#[stable]
4748
impl<T: Default> Default for Box<T> {
49+
#[stable]
4850
fn default() -> Box<T> { box Default::default() }
4951
}
5052

53+
#[stable]
5154
impl<T> Default for Box<[T]> {
55+
#[stable]
5256
fn default() -> Box<[T]> { box [] }
5357
}
5458

src/liballoc/rc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ impl<T: Default> Default for Rc<T> {
447447
/// let x: Rc<int> = Default::default();
448448
/// ```
449449
#[inline]
450+
#[stable]
450451
fn default() -> Rc<T> {
451452
Rc::new(Default::default())
452453
}

src/libcollections/binary_heap.rs

+2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ pub struct BinaryHeap<T> {
172172
data: Vec<T>,
173173
}
174174

175+
#[stable]
175176
impl<T: Ord> Default for BinaryHeap<T> {
176177
#[inline]
178+
#[stable]
177179
fn default() -> BinaryHeap<T> { BinaryHeap::new() }
178180
}
179181

src/libcollections/bit.rs

+2
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,10 @@ pub fn from_fn<F>(len: uint, mut f: F) -> Bitv where F: FnMut(uint) -> bool {
824824
bitv
825825
}
826826

827+
#[stable]
827828
impl Default for Bitv {
828829
#[inline]
830+
#[stable]
829831
fn default() -> Bitv { Bitv::new() }
830832
}
831833

src/libcollections/btree/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,9 @@ impl<S: Writer, K: Hash<S>, V: Hash<S>> Hash<S> for BTreeMap<K, V> {
832832
}
833833
}
834834

835+
#[stable]
835836
impl<K: Ord, V> Default for BTreeMap<K, V> {
837+
#[stable]
836838
fn default() -> BTreeMap<K, V> {
837839
BTreeMap::new()
838840
}

src/libcollections/btree/set.rs

+2
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,9 @@ impl<T: Ord> Extend<T> for BTreeSet<T> {
439439
}
440440
}
441441

442+
#[stable]
442443
impl<T: Ord> Default for BTreeSet<T> {
444+
#[stable]
443445
fn default() -> BTreeSet<T> {
444446
BTreeSet::new()
445447
}

src/libcollections/dlist.rs

+2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ impl<T> DList<T> {
192192
}
193193
}
194194

195+
#[stable]
195196
impl<T> Default for DList<T> {
196197
#[inline]
198+
#[stable]
197199
fn default() -> DList<T> { DList::new() }
198200
}
199201

src/libcollections/hash/sip.rs

+2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,10 @@ impl Clone for SipState {
204204
}
205205
}
206206

207+
#[stable]
207208
impl Default for SipState {
208209
#[inline]
210+
#[stable]
209211
fn default() -> SipState {
210212
SipState::new()
211213
}

src/libcollections/ring_buf.rs

+2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ impl<T> Drop for RingBuf<T> {
6868
}
6969
}
7070

71+
#[stable]
7172
impl<T> Default for RingBuf<T> {
73+
#[stable]
7274
#[inline]
7375
fn default() -> RingBuf<T> { RingBuf::new() }
7476
}

src/libcollections/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ impl StrAllocating for String {
826826

827827
#[stable]
828828
impl Default for String {
829+
#[stable]
829830
fn default() -> String {
830831
String::new()
831832
}

src/libcollections/tree/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ impl<K: Ord + Show, V: Show> Show for TreeMap<K, V> {
185185
}
186186
}
187187

188+
#[stable]
188189
impl<K: Ord, V> Default for TreeMap<K,V> {
189190
#[inline]
191+
#[stable]
190192
fn default() -> TreeMap<K, V> { TreeMap::new() }
191193
}
192194

src/libcollections/tree/set.rs

+2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ impl<T: Ord + Show> Show for TreeSet<T> {
134134
}
135135
}
136136

137+
#[stable]
137138
impl<T: Ord> Default for TreeSet<T> {
138139
#[inline]
140+
#[stable]
139141
fn default() -> TreeSet<T> { TreeSet::new() }
140142
}
141143

src/libcollections/trie/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ impl<T: Show> Show for TrieMap<T> {
150150
}
151151
}
152152

153+
#[stable]
153154
impl<T> Default for TrieMap<T> {
154155
#[inline]
156+
#[stable]
155157
fn default() -> TrieMap<T> { TrieMap::new() }
156158
}
157159

src/libcollections/trie/set.rs

+2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ impl Show for TrieSet {
6969
}
7070
}
7171

72+
#[stable]
7273
impl Default for TrieSet {
7374
#[inline]
75+
#[stable]
7476
fn default() -> TrieSet { TrieSet::new() }
7577
}
7678

src/libcollections/vec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,7 @@ impl<T> Drop for Vec<T> {
13221322

13231323
#[stable]
13241324
impl<T> Default for Vec<T> {
1325+
#[stable]
13251326
fn default() -> Vec<T> {
13261327
Vec::new()
13271328
}

src/libcollections/vec_map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ pub struct VecMap<V> {
6666
v: Vec<Option<V>>,
6767
}
6868

69+
#[stable]
6970
impl<V> Default for VecMap<V> {
71+
#[stable]
7072
#[inline]
7173
fn default() -> VecMap<V> { VecMap::new() }
7274
}

src/libcore/cell.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ impl<T:Copy> Clone for Cell<T> {
215215
}
216216
}
217217

218-
#[unstable]
218+
#[stable]
219219
impl<T:Default + Copy> Default for Cell<T> {
220+
#[stable]
220221
fn default() -> Cell<T> {
221222
Cell::new(Default::default())
222223
}
@@ -349,8 +350,9 @@ impl<T: Clone> Clone for RefCell<T> {
349350
}
350351
}
351352

352-
#[unstable]
353+
#[stable]
353354
impl<T:Default> Default for RefCell<T> {
355+
#[stable]
354356
fn default() -> RefCell<T> {
355357
RefCell::new(Default::default())
356358
}

src/libcore/default.rs

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
/// bar: f32,
9898
/// }
9999
/// ```
100+
#[stable]
100101
pub trait Default {
101102
/// Returns the "default value" for a type.
102103
///
@@ -130,13 +131,16 @@ pub trait Default {
130131
/// fn default() -> Kind { Kind::A }
131132
/// }
132133
/// ```
134+
#[stable]
133135
fn default() -> Self;
134136
}
135137

136138
macro_rules! default_impl(
137139
($t:ty, $v:expr) => {
140+
#[stable]
138141
impl Default for $t {
139142
#[inline]
143+
#[stable]
140144
fn default() -> $t { $v }
141145
}
142146
}

src/libcore/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ extern "rust-intrinsic" {
217217
///
218218
/// `forget` is unsafe because the caller is responsible for
219219
/// ensuring the argument is deallocated already.
220+
#[stable]
220221
pub fn forget<T>(_: T) -> ();
221222

222223
/// Unsafely transforms a value of one type into a value of another type.
@@ -232,6 +233,7 @@ extern "rust-intrinsic" {
232233
/// let v: &[u8] = unsafe { mem::transmute("L") };
233234
/// assert!(v == [76u8]);
234235
/// ```
236+
#[stable]
235237
pub fn transmute<T,U>(e: T) -> U;
236238

237239
/// Gives the address for the return value of the enclosing function.

src/libcore/mem.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
//! This module contains functions for querying the size and alignment of
1414
//! types, initializing and manipulating memory.
1515
16+
#![stable]
17+
18+
use kinds::Sized;
1619
use intrinsics;
1720
use ptr;
1821

22+
#[stable]
1923
pub use intrinsics::transmute;
2024

2125
/// Moves a thing into the void.
@@ -223,15 +227,17 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
223227
#[inline]
224228
#[unstable = "this function may be removed in the future due to its \
225229
questionable utility"]
226-
pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T {
230+
pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
231+
ptr: &T) -> &'a T {
227232
transmute(ptr)
228233
}
229234

230235
/// Transforms lifetime of the second mutable pointer to match the first.
231236
#[inline]
232237
#[unstable = "this function may be removed in the future due to its \
233238
questionable utility"]
234-
pub unsafe fn copy_mut_lifetime<'a, S, T:'a>(_ptr: &'a mut S,
235-
ptr: &mut T) -> &'a mut T {
239+
pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S,
240+
ptr: &mut T)
241+
-> &'a mut T {
236242
transmute(ptr)
237243
}

src/libcore/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ impl<T> AsSlice<T> for Option<T> {
763763

764764
#[stable]
765765
impl<T> Default for Option<T> {
766+
#[stable]
766767
#[inline]
767768
#[stable]
768769
fn default() -> Option<T> { None }

src/libcore/slice.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,9 @@ impl<'a, T, Sized? U: AsSlice<T>> AsSlice<T> for &'a mut U {
647647
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
648648
}
649649

650-
#[unstable = "waiting for DST"]
650+
#[stable]
651651
impl<'a, T> Default for &'a [T] {
652+
#[stable]
652653
fn default() -> &'a [T] { &[] }
653654
}
654655

src/libcore/str.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,9 @@ impl StrPrelude for str {
23492349
fn len(&self) -> uint { self.repr().len }
23502350
}
23512351

2352+
#[stable]
23522353
impl<'a> Default for &'a str {
2354+
#[stable]
23532355
fn default() -> &'a str { "" }
23542356
}
23552357

src/libcore/tuple/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ macro_rules! tuple_impls {
182182

183183
#[stable]
184184
impl<$($T:Default),+> Default for ($($T,)+) {
185+
#[stable]
185186
#[inline]
186187
fn default() -> ($($T,)+) {
187188
($({ let x: $T = Default::default(); x},)+)

src/librand/reseeding.rs

+2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
142142
*rng = Default::default();
143143
}
144144
}
145+
#[stable]
145146
impl Default for ReseedWithDefault {
147+
#[stable]
146148
fn default() -> ReseedWithDefault { ReseedWithDefault }
147149
}
148150

src/libstd/collections/hash/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,9 @@ impl<K: Eq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H>
12881288
}
12891289
}
12901290

1291+
#[stable]
12911292
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
1293+
#[stable]
12921294
fn default() -> HashMap<K, V, H> {
12931295
HashMap::with_hasher(Default::default())
12941296
}

src/libstd/collections/hash/set.rs

+2
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extend<T> for HashSet<T, H> {
608608
}
609609
}
610610

611+
#[stable]
611612
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Default for HashSet<T, H> {
613+
#[stable]
612614
fn default() -> HashSet<T, H> {
613615
HashSet::with_hasher(Default::default())
614616
}

src/libstd/hash.rs

+2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ impl Hasher<sip::SipState> for RandomSipHasher {
9595
}
9696
}
9797

98+
#[stable]
9899
impl Default for RandomSipHasher {
100+
#[stable]
99101
#[inline]
100102
fn default() -> RandomSipHasher {
101103
RandomSipHasher::new()

src/libstd/io/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,9 @@ bitflags! {
19111911
}
19121912

19131913

1914+
#[stable]
19141915
impl Default for FilePermission {
1916+
#[stable]
19151917
#[inline]
19161918
fn default() -> FilePermission { FilePermission::empty() }
19171919
}

0 commit comments

Comments
 (0)