Skip to content

Commit 94ef67a

Browse files
committed
---
yaml --- r: 123763 b: refs/heads/try c: 296eb10 h: refs/heads/master i: 123761: d7c9ac0 123759: 67496ea v: v3
1 parent 3c868dd commit 94ef67a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+98
-108
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: da4e4e4e0a7778a85748aa4a303b13f603e96b4b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8ddd286ea4ba4384a0dc9eae393ed515460a986e
5-
refs/heads/try: 8bbf598d50960087342667fc47f5d38f4a9c2165
5+
refs/heads/try: 296eb104620b346d88bc4a2c2ab7693e6d3db019
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/liballoc/owned.rs renamed to branches/try/src/liballoc/boxed.rs

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
1616
use core::default::Default;
1717
use core::fmt;
1818
use core::intrinsics;
19-
use core::kinds::Send;
2019
use core::mem;
2120
use core::option::Option;
2221
use core::raw::TraitObject;
@@ -27,17 +26,19 @@ use core::result::{Ok, Err, Result};
2726
///
2827
/// The following two examples are equivalent:
2928
///
30-
/// use std::owned::HEAP;
29+
/// use std::boxed::HEAP;
3130
///
3231
/// # struct Bar;
3332
/// # impl Bar { fn new(_a: int) { } }
3433
/// let foo = box(HEAP) Bar::new(2);
3534
/// let foo = box Bar::new(2);
36-
#[lang="exchange_heap"]
35+
#[lang = "exchange_heap"]
36+
#[experimental = "may be renamed; uncertain about custom allocator design"]
3737
pub static HEAP: () = ();
3838

3939
/// A type that represents a uniquely-owned value.
40-
#[lang="owned_box"]
40+
#[lang = "owned_box"]
41+
#[unstable = "custom allocators will add an additional type parameter (with default)"]
4142
pub struct Box<T>(*mut T);
4243

4344
impl<T: Default> Default for Box<T> {
@@ -57,7 +58,6 @@ impl<T: Clone> Clone for Box<T> {
5758
}
5859
}
5960

60-
// box pointers
6161
impl<T:PartialEq> PartialEq for Box<T> {
6262
#[inline]
6363
fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
@@ -85,15 +85,16 @@ impl<T: Ord> Ord for Box<T> {
8585
impl<T: Eq> Eq for Box<T> {}
8686

8787
/// Extension methods for an owning `Any` trait object
88-
pub trait AnyOwnExt {
88+
#[unstable = "post-DST, the signature of `downcast` will change to take `Box<Self>`"]
89+
pub trait BoxAny {
8990
/// Returns the boxed value if it is of type `T`, or
9091
/// `Err(Self)` if it isn't.
91-
fn move<T: 'static>(self) -> Result<Box<T>, Self>;
92+
fn downcast<T: 'static>(self) -> Result<Box<T>, Self>;
9293
}
9394

94-
impl AnyOwnExt for Box<Any> {
95+
impl BoxAny for Box<Any> {
9596
#[inline]
96-
fn move<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
97+
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
9798
if self.is::<T>() {
9899
unsafe {
99100
// Get the raw representation of the trait object
@@ -112,34 +113,6 @@ impl AnyOwnExt for Box<Any> {
112113
}
113114
}
114115

115-
/// Extension methods for an owning `Any+Send` trait object
116-
pub trait AnySendOwnExt {
117-
/// Returns the boxed value if it is of type `T`, or
118-
/// `Err(Self)` if it isn't.
119-
fn move_send<T: 'static>(self) -> Result<Box<T>, Self>;
120-
}
121-
122-
impl AnySendOwnExt for Box<Any+Send> {
123-
#[inline]
124-
fn move_send<T: 'static>(self) -> Result<Box<T>, Box<Any+Send>> {
125-
if self.is::<T>() {
126-
unsafe {
127-
// Get the raw representation of the trait object
128-
let to: TraitObject =
129-
*mem::transmute::<&Box<Any+Send>, &TraitObject>(&self);
130-
131-
// Prevent destructor on self being run
132-
intrinsics::forget(self);
133-
134-
// Extract the data pointer
135-
Ok(mem::transmute(to.data))
136-
}
137-
} else {
138-
Err(self)
139-
}
140-
}
141-
}
142-
143116
impl<T: fmt::Show> fmt::Show for Box<T> {
144117
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
145118
(**self).fmt(f)
@@ -166,20 +139,20 @@ mod test {
166139
let a = box 8u as Box<Any>;
167140
let b = box Test as Box<Any>;
168141

169-
match a.move::<uint>() {
142+
match a.downcast::<uint>() {
170143
Ok(a) => { assert!(a == box 8u); }
171144
Err(..) => fail!()
172145
}
173-
match b.move::<Test>() {
146+
match b.downcast::<Test>() {
174147
Ok(a) => { assert!(a == box Test); }
175148
Err(..) => fail!()
176149
}
177150

178151
let a = box 8u as Box<Any>;
179152
let b = box Test as Box<Any>;
180153

181-
assert!(a.move::<Box<Test>>().is_err());
182-
assert!(b.move::<Box<uint>>().is_err());
154+
assert!(a.downcast::<Box<Test>>().is_err());
155+
assert!(b.downcast::<Box<uint>>().is_err());
183156
}
184157

185158
#[test]

branches/try/src/liballoc/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
//!
2222
//! Currently, there are four major definitions in this library.
2323
//!
24-
//! ## Owned pointers
24+
//! ## Boxed values
2525
//!
26-
//! The [`Box`](owned/index.html) type is the core owned pointer type in rust.
26+
//! The [`Box`](boxed/index.html) type is the core owned pointer type in rust.
2727
//! There can only be one owner of a `Box`, and the owner can decide to mutate
28-
//! the contents.
28+
//! the contents, which live on the heap.
2929
//!
3030
//! This type can be sent among tasks efficiently as the size of a `Box` value
3131
//! is just a pointer. Tree-like data structures are often built on owned
@@ -91,7 +91,7 @@ pub mod util;
9191
// Primitive types using the heaps above
9292

9393
#[cfg(not(test))]
94-
pub mod owned;
94+
pub mod boxed;
9595
pub mod arc;
9696
pub mod rc;
9797

branches/try/src/libcollections/btree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
use core::prelude::*;
2222

23-
use alloc::owned::Box;
23+
use alloc::boxed::Box;
2424
use core::fmt;
2525
use core::fmt::Show;
2626

branches/try/src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
use core::prelude::*;
2525

26-
use alloc::owned::Box;
26+
use alloc::boxed::Box;
2727
use core::default::Default;
2828
use core::fmt;
2929
use core::iter;

branches/try/src/libcollections/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
use core::prelude::*;
6767

68-
use alloc::owned::Box;
68+
use alloc::boxed::Box;
6969
use alloc::rc::Rc;
7070
use core::intrinsics::TypeId;
7171
use core::mem;

branches/try/src/libcollections/treemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
use core::prelude::*;
1616

17-
use alloc::owned::Box;
17+
use alloc::boxed::Box;
1818
use core::default::Default;
1919
use core::fmt;
2020
use core::fmt::Show;

branches/try/src/libcollections/trie.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use core::prelude::*;
1414

15-
use alloc::owned::Box;
15+
use alloc::boxed::Box;
1616
use core::default::Default;
1717
use core::mem::zeroed;
1818
use core::mem;

branches/try/src/libcore/cell.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ use option::{None, Option, Some};
163163
use ty::Unsafe;
164164

165165
/// A mutable memory location that admits only `Copy` data.
166+
#[unstable = "likety to be renamed; otherwise stable"]
166167
pub struct Cell<T> {
167168
value: Unsafe<T>,
168169
noshare: marker::NoShare,
169170
}
170171

172+
#[stable]
171173
impl<T:Copy> Cell<T> {
172174
/// Creates a new `Cell` containing the given value.
173175
pub fn new(value: T) -> Cell<T> {
@@ -192,20 +194,22 @@ impl<T:Copy> Cell<T> {
192194
}
193195
}
194196

195-
#[unstable]
197+
#[unstable = "waiting for `Clone` trait to become stable"]
196198
impl<T:Copy> Clone for Cell<T> {
197199
fn clone(&self) -> Cell<T> {
198200
Cell::new(self.get())
199201
}
200202
}
201203

204+
#[unstable = "waiting for `PartialEq` trait to become stable"]
202205
impl<T:PartialEq + Copy> PartialEq for Cell<T> {
203206
fn eq(&self, other: &Cell<T>) -> bool {
204207
self.get() == other.get()
205208
}
206209
}
207210

208211
/// A mutable memory location with dynamically checked borrow rules
212+
#[unstable = "likety to be renamed; otherwise stable"]
209213
pub struct RefCell<T> {
210214
value: Unsafe<T>,
211215
borrow: Cell<BorrowFlag>,
@@ -221,6 +225,7 @@ static WRITING: BorrowFlag = -1;
221225

222226
impl<T> RefCell<T> {
223227
/// Create a new `RefCell` containing `value`
228+
#[stable]
224229
pub fn new(value: T) -> RefCell<T> {
225230
RefCell {
226231
value: Unsafe::new(value),
@@ -231,6 +236,7 @@ impl<T> RefCell<T> {
231236
}
232237

233238
/// Consumes the `RefCell`, returning the wrapped value.
239+
#[unstable = "may be renamed, depending on global conventions"]
234240
pub fn unwrap(self) -> T {
235241
debug_assert!(self.borrow.get() == UNUSED);
236242
unsafe{self.value.unwrap()}
@@ -242,6 +248,7 @@ impl<T> RefCell<T> {
242248
/// immutable borrows can be taken out at the same time.
243249
///
244250
/// Returns `None` if the value is currently mutably borrowed.
251+
#[unstable = "may be renamed, depending on global conventions"]
245252
pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> {
246253
match self.borrow.get() {
247254
WRITING => None,
@@ -260,6 +267,7 @@ impl<T> RefCell<T> {
260267
/// # Failure
261268
///
262269
/// Fails if the value is currently mutably borrowed.
270+
#[unstable]
263271
pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
264272
match self.try_borrow() {
265273
Some(ptr) => ptr,
@@ -273,6 +281,7 @@ impl<T> RefCell<T> {
273281
/// cannot be borrowed while this borrow is active.
274282
///
275283
/// Returns `None` if the value is currently borrowed.
284+
#[unstable = "may be renamed, depending on global conventions"]
276285
pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> {
277286
match self.borrow.get() {
278287
UNUSED => {
@@ -291,6 +300,7 @@ impl<T> RefCell<T> {
291300
/// # Failure
292301
///
293302
/// Fails if the value is currently borrowed.
303+
#[unstable]
294304
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
295305
match self.try_borrow_mut() {
296306
Some(ptr) => ptr,
@@ -299,27 +309,30 @@ impl<T> RefCell<T> {
299309
}
300310
}
301311

302-
#[unstable]
312+
#[unstable = "waiting for `Clone` to become stable"]
303313
impl<T: Clone> Clone for RefCell<T> {
304314
fn clone(&self) -> RefCell<T> {
305315
RefCell::new(self.borrow().clone())
306316
}
307317
}
308318

319+
#[unstable = "waiting for `PartialEq` to become stable"]
309320
impl<T: PartialEq> PartialEq for RefCell<T> {
310321
fn eq(&self, other: &RefCell<T>) -> bool {
311322
*self.borrow() == *other.borrow()
312323
}
313324
}
314325

315326
/// Wraps a borrowed reference to a value in a `RefCell` box.
327+
#[unstable]
316328
pub struct Ref<'b, T> {
317329
// FIXME #12808: strange name to try to avoid interfering with
318330
// field accesses of the contained type via Deref
319331
_parent: &'b RefCell<T>
320332
}
321333

322334
#[unsafe_destructor]
335+
#[unstable]
323336
impl<'b, T> Drop for Ref<'b, T> {
324337
fn drop(&mut self) {
325338
let borrow = self._parent.borrow.get();
@@ -328,6 +341,7 @@ impl<'b, T> Drop for Ref<'b, T> {
328341
}
329342
}
330343

344+
#[unstable = "waiting for `Deref` to become stable"]
331345
impl<'b, T> Deref<T> for Ref<'b, T> {
332346
#[inline]
333347
fn deref<'a>(&'a self) -> &'a T {
@@ -341,7 +355,7 @@ impl<'b, T> Deref<T> for Ref<'b, T> {
341355
///
342356
/// A `Clone` implementation would interfere with the widespread
343357
/// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
344-
#[experimental]
358+
#[experimental = "likely to be moved to a method, pending language changes"]
345359
pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> {
346360
// Since this Ref exists, we know the borrow flag
347361
// is not set to WRITING.
@@ -355,13 +369,15 @@ pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> {
355369
}
356370

357371
/// Wraps a mutable borrowed reference to a value in a `RefCell` box.
372+
#[unstable]
358373
pub struct RefMut<'b, T> {
359374
// FIXME #12808: strange name to try to avoid interfering with
360375
// field accesses of the contained type via Deref
361376
_parent: &'b RefCell<T>
362377
}
363378

364379
#[unsafe_destructor]
380+
#[unstable]
365381
impl<'b, T> Drop for RefMut<'b, T> {
366382
fn drop(&mut self) {
367383
let borrow = self._parent.borrow.get();
@@ -370,13 +386,15 @@ impl<'b, T> Drop for RefMut<'b, T> {
370386
}
371387
}
372388

389+
#[unstable = "waiting for `Deref` to become stable"]
373390
impl<'b, T> Deref<T> for RefMut<'b, T> {
374391
#[inline]
375392
fn deref<'a>(&'a self) -> &'a T {
376393
unsafe { &*self._parent.value.get() }
377394
}
378395
}
379396

397+
#[unstable = "waiting for `DerefMut` to become stable"]
380398
impl<'b, T> DerefMut<T> for RefMut<'b, T> {
381399
#[inline]
382400
fn deref_mut<'a>(&'a mut self) -> &'a mut T {

branches/try/src/librustrt/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
4545
mod imp {
4646
use core::prelude::*;
4747

48-
use alloc::owned::Box;
48+
use alloc::boxed::Box;
4949
use collections::vec::Vec;
5050
use core::mem;
5151
use core::slice;

branches/try/src/librustrt/at_exit_imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
use core::prelude::*;
1616

17-
use alloc::owned::Box;
17+
use alloc::boxed::Box;
1818
use collections::vec::Vec;
1919
use core::atomics;
2020
use core::mem;

branches/try/src/librustrt/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub use self::unwind::{begin_unwind, begin_unwind_fmt};
3737

3838
use core::prelude::*;
3939

40-
use alloc::owned::Box;
40+
use alloc::boxed::Box;
4141
use core::any::Any;
4242

4343
use task::{Task, BlockedTask, TaskOpts};

0 commit comments

Comments
 (0)