diff --git a/src/liballoc/owned.rs b/src/liballoc/boxed.rs similarity index 77% rename from src/liballoc/owned.rs rename to src/liballoc/boxed.rs index addec396bbef8..56506d798d9df 100644 --- a/src/liballoc/owned.rs +++ b/src/liballoc/boxed.rs @@ -16,7 +16,6 @@ use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; use core::default::Default; use core::fmt; use core::intrinsics; -use core::kinds::Send; use core::mem; use core::option::Option; use core::raw::TraitObject; @@ -27,17 +26,19 @@ use core::result::{Ok, Err, Result}; /// /// The following two examples are equivalent: /// -/// use std::owned::HEAP; +/// use std::boxed::HEAP; /// /// # struct Bar; /// # impl Bar { fn new(_a: int) { } } /// let foo = box(HEAP) Bar::new(2); /// let foo = box Bar::new(2); -#[lang="exchange_heap"] +#[lang = "exchange_heap"] +#[experimental = "may be renamed; uncertain about custom allocator design"] pub static HEAP: () = (); /// A type that represents a uniquely-owned value. -#[lang="owned_box"] +#[lang = "owned_box"] +#[unstable = "custom allocators will add an additional type parameter (with default)"] pub struct Box(*mut T); impl Default for Box { @@ -57,7 +58,6 @@ impl Clone for Box { } } -// box pointers impl PartialEq for Box { #[inline] fn eq(&self, other: &Box) -> bool { *(*self) == *(*other) } @@ -85,48 +85,27 @@ impl Ord for Box { impl Eq for Box {} /// Extension methods for an owning `Any` trait object -pub trait AnyOwnExt { +#[unstable = "post-DST, the signature of `downcast` will change to take `Box`"] +pub trait BoxAny { /// Returns the boxed value if it is of type `T`, or /// `Err(Self)` if it isn't. - fn move(self) -> Result, Self>; -} - -impl AnyOwnExt for Box { - #[inline] - fn move(self) -> Result, Box> { - if self.is::() { - unsafe { - // Get the raw representation of the trait object - let to: TraitObject = - *mem::transmute::<&Box, &TraitObject>(&self); - - // Prevent destructor on self being run - intrinsics::forget(self); + fn downcast(self) -> Result, Self>; - // Extract the data pointer - Ok(mem::transmute(to.data)) - } - } else { - Err(self) - } + /// Deprecated; this method has been renamed to `downcast`. + #[deprecated = "use downcast instead"] + fn move(self) -> Result, Self> { + self.downcast::() } } -/// Extension methods for an owning `Any+Send` trait object -pub trait AnySendOwnExt { - /// Returns the boxed value if it is of type `T`, or - /// `Err(Self)` if it isn't. - fn move_send(self) -> Result, Self>; -} - -impl AnySendOwnExt for Box { +impl BoxAny for Box { #[inline] - fn move_send(self) -> Result, Box> { + fn downcast(self) -> Result, Box> { if self.is::() { unsafe { // Get the raw representation of the trait object let to: TraitObject = - *mem::transmute::<&Box, &TraitObject>(&self); + *mem::transmute::<&Box, &TraitObject>(&self); // Prevent destructor on self being run intrinsics::forget(self); @@ -166,11 +145,11 @@ mod test { let a = box 8u as Box; let b = box Test as Box; - match a.move::() { + match a.downcast::() { Ok(a) => { assert!(a == box 8u); } Err(..) => fail!() } - match b.move::() { + match b.downcast::() { Ok(a) => { assert!(a == box Test); } Err(..) => fail!() } @@ -178,8 +157,8 @@ mod test { let a = box 8u as Box; let b = box Test as Box; - assert!(a.move::>().is_err()); - assert!(b.move::>().is_err()); + assert!(a.downcast::>().is_err()); + assert!(b.downcast::>().is_err()); } #[test] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 80b6cee2a9db9..6ae91f3897104 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -21,11 +21,11 @@ //! //! Currently, there are four major definitions in this library. //! -//! ## Owned pointers +//! ## Boxed values //! -//! The [`Box`](owned/index.html) type is the core owned pointer type in rust. +//! The [`Box`](boxed/index.html) type is the core owned pointer type in rust. //! There can only be one owner of a `Box`, and the owner can decide to mutate -//! the contents. +//! the contents, which live on the heap. //! //! This type can be sent among tasks efficiently as the size of a `Box` value //! is just a pointer. Tree-like data structures are often built on owned @@ -82,6 +82,12 @@ extern crate libc; #[cfg(test)] #[phase(plugin, link)] extern crate std; #[cfg(test)] #[phase(plugin, link)] extern crate log; +// The deprecated name of the boxed module + +#[deprecated = "use boxed instead"] +#[cfg(not(test))] +pub use owned = boxed; + // Heaps provided for low-level allocation strategies pub mod heap; @@ -91,7 +97,7 @@ pub mod util; // Primitive types using the heaps above #[cfg(not(test))] -pub mod owned; +pub mod boxed; pub mod arc; pub mod rc; diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 2d138b1a1895f..6ee68f74438fe 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -20,7 +20,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::fmt; use core::fmt::Show; diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index ed2d673887667..226dd5a2356c9 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -23,7 +23,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::default::Default; use core::fmt; use core::iter; diff --git a/src/libcollections/hash/mod.rs b/src/libcollections/hash/mod.rs index e3d1c9a3216bc..357383207150e 100644 --- a/src/libcollections/hash/mod.rs +++ b/src/libcollections/hash/mod.rs @@ -65,7 +65,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use alloc::rc::Rc; use core::intrinsics::TypeId; use core::mem; diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 1451bf9d7c7bc..bb596530d4ab8 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -14,7 +14,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::default::Default; use core::fmt; use core::fmt::Show; diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 9b6355e121bea..29ec85590b320 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -12,7 +12,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::default::Default; use core::mem::zeroed; use core::mem; diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 355ee7c7a16f0..51b5d0aded800 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -163,11 +163,13 @@ use option::{None, Option, Some}; use ty::Unsafe; /// A mutable memory location that admits only `Copy` data. +#[unstable = "likely to be renamed; otherwise stable"] pub struct Cell { value: Unsafe, noshare: marker::NoShare, } +#[stable] impl Cell { /// Creates a new `Cell` containing the given value. pub fn new(value: T) -> Cell { @@ -192,13 +194,14 @@ impl Cell { } } -#[unstable] +#[unstable = "waiting for `Clone` trait to become stable"] impl Clone for Cell { fn clone(&self) -> Cell { Cell::new(self.get()) } } +#[unstable = "waiting for `PartialEq` trait to become stable"] impl PartialEq for Cell { fn eq(&self, other: &Cell) -> bool { self.get() == other.get() @@ -206,6 +209,7 @@ impl PartialEq for Cell { } /// A mutable memory location with dynamically checked borrow rules +#[unstable = "likely to be renamed; otherwise stable"] pub struct RefCell { value: Unsafe, borrow: Cell, @@ -221,6 +225,7 @@ static WRITING: BorrowFlag = -1; impl RefCell { /// Create a new `RefCell` containing `value` + #[stable] pub fn new(value: T) -> RefCell { RefCell { value: Unsafe::new(value), @@ -231,6 +236,7 @@ impl RefCell { } /// Consumes the `RefCell`, returning the wrapped value. + #[unstable = "may be renamed, depending on global conventions"] pub fn unwrap(self) -> T { debug_assert!(self.borrow.get() == UNUSED); unsafe{self.value.unwrap()} @@ -242,6 +248,7 @@ impl RefCell { /// immutable borrows can be taken out at the same time. /// /// Returns `None` if the value is currently mutably borrowed. + #[unstable = "may be renamed, depending on global conventions"] pub fn try_borrow<'a>(&'a self) -> Option> { match self.borrow.get() { WRITING => None, @@ -260,6 +267,7 @@ impl RefCell { /// # Failure /// /// Fails if the value is currently mutably borrowed. + #[unstable] pub fn borrow<'a>(&'a self) -> Ref<'a, T> { match self.try_borrow() { Some(ptr) => ptr, @@ -273,6 +281,7 @@ impl RefCell { /// cannot be borrowed while this borrow is active. /// /// Returns `None` if the value is currently borrowed. + #[unstable = "may be renamed, depending on global conventions"] pub fn try_borrow_mut<'a>(&'a self) -> Option> { match self.borrow.get() { UNUSED => { @@ -291,6 +300,7 @@ impl RefCell { /// # Failure /// /// Fails if the value is currently borrowed. + #[unstable] pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> { match self.try_borrow_mut() { Some(ptr) => ptr, @@ -299,13 +309,14 @@ impl RefCell { } } -#[unstable] +#[unstable = "waiting for `Clone` to become stable"] impl Clone for RefCell { fn clone(&self) -> RefCell { RefCell::new(self.borrow().clone()) } } +#[unstable = "waiting for `PartialEq` to become stable"] impl PartialEq for RefCell { fn eq(&self, other: &RefCell) -> bool { *self.borrow() == *other.borrow() @@ -313,6 +324,7 @@ impl PartialEq for RefCell { } /// Wraps a borrowed reference to a value in a `RefCell` box. +#[unstable] pub struct Ref<'b, T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -320,6 +332,7 @@ pub struct Ref<'b, T> { } #[unsafe_destructor] +#[unstable] impl<'b, T> Drop for Ref<'b, T> { fn drop(&mut self) { let borrow = self._parent.borrow.get(); @@ -328,6 +341,7 @@ impl<'b, T> Drop for Ref<'b, T> { } } +#[unstable = "waiting for `Deref` to become stable"] impl<'b, T> Deref for Ref<'b, T> { #[inline] fn deref<'a>(&'a self) -> &'a T { @@ -341,7 +355,7 @@ impl<'b, T> Deref for Ref<'b, T> { /// /// A `Clone` implementation would interfere with the widespread /// use of `r.borrow().clone()` to clone the contents of a `RefCell`. -#[experimental] +#[experimental = "likely to be moved to a method, pending language changes"] pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> { // Since this Ref exists, we know the borrow flag // is not set to WRITING. @@ -355,6 +369,7 @@ pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> { } /// Wraps a mutable borrowed reference to a value in a `RefCell` box. +#[unstable] pub struct RefMut<'b, T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -362,6 +377,7 @@ pub struct RefMut<'b, T> { } #[unsafe_destructor] +#[unstable] impl<'b, T> Drop for RefMut<'b, T> { fn drop(&mut self) { let borrow = self._parent.borrow.get(); @@ -370,6 +386,7 @@ impl<'b, T> Drop for RefMut<'b, T> { } } +#[unstable = "waiting for `Deref` to become stable"] impl<'b, T> Deref for RefMut<'b, T> { #[inline] fn deref<'a>(&'a self) -> &'a T { @@ -377,6 +394,7 @@ impl<'b, T> Deref for RefMut<'b, T> { } } +#[unstable = "waiting for `DerefMut` to become stable"] impl<'b, T> DerefMut for RefMut<'b, T> { #[inline] fn deref_mut<'a>(&'a mut self) -> &'a mut T { diff --git a/src/librustrt/args.rs b/src/librustrt/args.rs index 3c0a4aae251db..af6de0cf605a2 100644 --- a/src/librustrt/args.rs +++ b/src/librustrt/args.rs @@ -45,7 +45,7 @@ pub fn clone() -> Option>> { imp::clone() } mod imp { use core::prelude::*; - use alloc::owned::Box; + use alloc::boxed::Box; use collections::vec::Vec; use core::mem; use core::slice; diff --git a/src/librustrt/at_exit_imp.rs b/src/librustrt/at_exit_imp.rs index dcba7fb7cb6a6..1faf492e498ac 100644 --- a/src/librustrt/at_exit_imp.rs +++ b/src/librustrt/at_exit_imp.rs @@ -14,7 +14,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use collections::vec::Vec; use core::atomics; use core::mem; diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index c830b2e122ec0..0b611381aa2de 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -37,7 +37,7 @@ pub use self::unwind::{begin_unwind, begin_unwind_fmt}; use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::any::Any; use task::{Task, BlockedTask, TaskOpts}; diff --git a/src/librustrt/local.rs b/src/librustrt/local.rs index 7fe9dbc6d4ff5..bdb1c60b6d6f8 100644 --- a/src/librustrt/local.rs +++ b/src/librustrt/local.rs @@ -10,7 +10,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use local_ptr; use task::Task; diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index d4c87e9fc05c1..ace53478d0a03 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -40,7 +40,7 @@ assert_eq!(*key_vector.get().unwrap(), vec![4]); use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use collections::vec::Vec; use core::kinds::marker; use core::mem; diff --git a/src/librustrt/local_ptr.rs b/src/librustrt/local_ptr.rs index 813ea0f30f38b..c94e5c6187b3a 100644 --- a/src/librustrt/local_ptr.rs +++ b/src/librustrt/local_ptr.rs @@ -20,7 +20,7 @@ use core::prelude::*; use core::mem; -use alloc::owned::Box; +use alloc::boxed::Box; #[cfg(windows)] // mingw-w32 doesn't like thread_local things #[cfg(target_os = "android")] // see #10686 @@ -86,7 +86,7 @@ pub unsafe fn borrow() -> Borrowed { pub mod compiled { use core::prelude::*; - use alloc::owned::Box; + use alloc::boxed::Box; use core::mem; #[cfg(test)] @@ -237,7 +237,7 @@ pub mod compiled { pub mod native { use core::prelude::*; - use alloc::owned::Box; + use alloc::boxed::Box; use core::mem; use core::ptr; use tls = thread_local_storage; diff --git a/src/librustrt/rtio.rs b/src/librustrt/rtio.rs index 7a91cca6265a0..343b911fb83f3 100644 --- a/src/librustrt/rtio.rs +++ b/src/librustrt/rtio.rs @@ -11,7 +11,7 @@ //! The EventLoop and internal synchronous I/O interface. use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use collections::string::String; use collections::vec::Vec; use core::fmt; diff --git a/src/librustrt/stack.rs b/src/librustrt/stack.rs index 8e637207d2209..0eacd40f01cee 100644 --- a/src/librustrt/stack.rs +++ b/src/librustrt/stack.rs @@ -56,7 +56,7 @@ pub static RED_ZONE: uint = 20 * 1024; #[lang = "stack_exhausted"] extern fn stack_exhausted() { use core::prelude::*; - use alloc::owned::Box; + use alloc::boxed::Box; use local::Local; use task::Task; use core::intrinsics; diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 59401a8b66604..78c32889277b2 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -16,7 +16,7 @@ use core::prelude::*; use alloc::arc::Arc; -use alloc::owned::{AnyOwnExt, Box}; +use alloc::boxed::{BoxAny, Box}; use core::any::Any; use core::atomics::{AtomicUint, SeqCst}; use core::iter::Take; @@ -376,7 +376,7 @@ impl Task { unsafe { let imp = self.imp.take_unwrap(); let vtable = mem::transmute::<_, &raw::TraitObject>(&imp).vtable; - match imp.wrap().move::() { + match imp.wrap().downcast::() { Ok(t) => Some(t), Err(t) => { let data = mem::transmute::<_, raw::TraitObject>(t).data; diff --git a/src/librustrt/thread.rs b/src/librustrt/thread.rs index 59784328cdb50..7bc991cf72f3a 100644 --- a/src/librustrt/thread.rs +++ b/src/librustrt/thread.rs @@ -18,7 +18,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::mem; use core::uint; use libc; @@ -147,7 +147,7 @@ impl Drop for Thread { mod imp { use core::prelude::*; - use alloc::owned::Box; + use alloc::boxed::Box; use core::cmp; use core::mem; use core::ptr; @@ -215,7 +215,7 @@ mod imp { mod imp { use core::prelude::*; - use alloc::owned::Box; + use alloc::boxed::Box; use core::cmp; use core::mem; use core::ptr; diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index 18688cbcc64ca..f26cccdd3ed90 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -59,7 +59,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use collections::string::String; use collections::vec::Vec; use core::any::Any; diff --git a/src/libstd/collections/lru_cache.rs b/src/libstd/collections/lru_cache.rs index a02402271d083..45301737adb3d 100644 --- a/src/libstd/collections/lru_cache.rs +++ b/src/libstd/collections/lru_cache.rs @@ -45,7 +45,7 @@ use iter::{range, Iterator}; use mem; use ops::Drop; use option::{Some, None, Option}; -use owned::Box; +use boxed::Box; use ptr; use result::{Ok, Err}; diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 47ff85e2806d5..8c709d20d1904 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -10,7 +10,7 @@ #![experimental] -use alloc::owned::Box; +use alloc::boxed::Box; use any::{Any, AnyRefExt}; use fmt; use io::{Writer, IoResult}; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index ed183cbf3bc21..ff2b35160a151 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -62,7 +62,7 @@ use iter::Iterator; use kinds::Send; use libc; use option::{Some, None, Option}; -use owned::Box; +use boxed::Box; use path::{Path, GenericPath}; use path; use result::{Err, Ok}; diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 4ef2e51fcf0b6..db4df7a8a6f10 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -229,7 +229,7 @@ use mem::transmute; use ops::{BitOr, BitAnd, Sub, Not}; use option::{Option, Some, None}; use os; -use owned::Box; +use boxed::Box; use result::{Ok, Err, Result}; use rt::rtio; use slice::{Vector, MutableVector, ImmutableVector}; diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 49322098348ff..642654ba6ed81 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -29,7 +29,7 @@ use io::{Reader, Writer, Listener, Acceptor}; use from_str::FromStr; use kinds::Send; use option::{None, Some, Option}; -use owned::Box; +use boxed::Box; use rt::rtio::{IoFactory, LocalIo, RtioSocket, RtioTcpListener}; use rt::rtio::{RtioTcpAcceptor, RtioTcpStream}; use rt::rtio; diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 21903eb26439c..5f7563e7467ba 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -19,7 +19,7 @@ use clone::Clone; use io::net::ip::{SocketAddr, IpAddr}; use io::{Reader, Writer, IoResult, IoError}; use kinds::Send; -use owned::Box; +use boxed::Box; use option::Option; use result::{Ok, Err}; use rt::rtio::{RtioSocket, RtioUdpSocket, IoFactory, LocalIo}; diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index c5ddda9945de1..5e7c421497772 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -30,7 +30,7 @@ use c_str::ToCStr; use clone::Clone; use io::{Listener, Acceptor, Reader, Writer, IoResult, IoError}; use kinds::Send; -use owned::Box; +use boxed::Box; use rt::rtio::{IoFactory, LocalIo, RtioUnixListener}; use rt::rtio::{RtioUnixAcceptor, RtioPipe}; diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index a968f41a91563..c476a99fee9dc 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -20,7 +20,7 @@ use prelude::*; use io::{IoResult, IoError}; use libc; use os; -use owned::Box; +use boxed::Box; use rt::rtio::{RtioPipe, LocalIo}; /// A synchronous, in-memory pipe. diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 6ef730237795c..07574b7264579 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -21,7 +21,7 @@ use io::{IoResult, IoError}; use io; use libc; use mem; -use owned::Box; +use boxed::Box; use rt::rtio::{RtioProcess, ProcessConfig, IoFactory, LocalIo}; use rt::rtio; use c_str::CString; diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index 4a7655a63ce8c..d46f437cddd50 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -26,7 +26,7 @@ use iter::Iterator; use kinds::Send; use mem::drop; use option::{Some, None}; -use owned::Box; +use boxed::Box; use result::{Ok, Err}; use rt::rtio::{IoFactory, LocalIo, RtioSignal, Callback}; use slice::ImmutableVector; diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index cdd083202e085..45c084b345961 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -35,7 +35,7 @@ use iter::Iterator; use kinds::Send; use libc; use option::{Option, Some, None}; -use owned::Box; +use boxed::Box; use result::{Ok, Err}; use rt; use rt::local::Local; diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 432461c460634..1c9e428dcad82 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -20,7 +20,7 @@ and create receivers which will receive notifications after a period of time. use comm::{Receiver, Sender, channel}; use io::{IoResult, IoError}; use kinds::Send; -use owned::Box; +use boxed::Box; use rt::rtio::{IoFactory, LocalIo, RtioTimer, Callback}; /// A synchronous timer object diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 2acf12b76c00a..e928323030c4f 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -13,7 +13,7 @@ use prelude::*; use cmp; use io; -use owned::Box; +use boxed::Box; use slice::bytes::MutableByteVector; /// Wraps a `Reader`, limiting the number of bytes that can be read from it. @@ -263,7 +263,7 @@ impl> Reader for IterReader { mod test { use io::{MemReader, MemWriter, BufReader}; use io; - use owned::Box; + use boxed::Box; use super::*; use prelude::*; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 14782cafce347..34c1530f96ca1 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -138,7 +138,7 @@ extern crate rustrt; #[cfg(test)] pub use realstd::ops; #[cfg(test)] pub use realstd::cmp; #[cfg(test)] pub use realstd::ty; -#[cfg(test)] pub use realstd::owned; +#[cfg(test)] pub use realstd::boxed; #[cfg(test)] pub use realstd::gc; @@ -167,7 +167,10 @@ pub use core::unit; pub use core::result; pub use core::option; -pub use alloc::owned; +pub use alloc::boxed; +#[deprecated = "use boxed instead"] +pub use owned = boxed; + pub use alloc::rc; pub use core_collections::slice; diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 21f8077729312..a20ac112ac52c 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -72,7 +72,7 @@ #[doc(no_inline)] pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv}; #[doc(no_inline)] pub use num::{Signed, Unsigned, Primitive, Int, Float}; #[doc(no_inline)] pub use num::{FloatMath, ToPrimitive, FromPrimitive}; -#[doc(no_inline)] pub use owned::Box; +#[doc(no_inline)] pub use boxed::Box; #[doc(no_inline)] pub use path::{GenericPath, Path, PosixPath, WindowsPath}; #[doc(no_inline)] pub use ptr::RawPtr; #[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek}; diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 72cc596085e07..d7af92024eb5e 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -98,7 +98,7 @@ use comm::channel; use io::{Writer, stdio}; use kinds::{Send, marker}; use option::{None, Some, Option}; -use owned::Box; +use boxed::Box; use result::Result; use rt::local::Local; use rt::task; @@ -374,7 +374,7 @@ pub fn failing() -> bool { #[cfg(test)] mod test { use any::{Any, AnyRefExt}; - use owned::AnyOwnExt; + use boxed::BoxAny; use result; use result::{Ok, Err}; use str::StrAllocating; @@ -578,7 +578,7 @@ mod test { Err(e) => { type T = &'static str; assert!(e.is::()); - assert_eq!(*e.move::().unwrap(), "static string"); + assert_eq!(*e.downcast::().unwrap(), "static string"); } Ok(()) => fail!() } @@ -592,7 +592,7 @@ mod test { Err(e) => { type T = String; assert!(e.is::()); - assert_eq!(*e.move::().unwrap(), "owned string".to_string()); + assert_eq!(*e.downcast::().unwrap(), "owned string".to_string()); } Ok(()) => fail!() } @@ -606,9 +606,9 @@ mod test { Err(e) => { type T = Box; assert!(e.is::()); - let any = e.move::().unwrap(); + let any = e.downcast::().unwrap(); assert!(any.is::()); - assert_eq!(*any.move::().unwrap(), 413u16); + assert_eq!(*any.downcast::().unwrap(), 413u16); } Ok(()) => fail!() } diff --git a/src/libsync/atomics.rs b/src/libsync/atomics.rs index 195efb844a783..0be124ad58408 100644 --- a/src/libsync/atomics.rs +++ b/src/libsync/atomics.rs @@ -103,7 +103,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::mem; pub use core::atomics::{AtomicBool, AtomicInt, AtomicUint, AtomicPtr}; diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index 6c09a021c4338..e9a303634fe37 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -320,7 +320,7 @@ use core::prelude::*; use alloc::arc::Arc; -use alloc::owned::Box; +use alloc::boxed::Box; use core::cell::Cell; use core::kinds::marker; use core::mem; diff --git a/src/libsync/comm/oneshot.rs b/src/libsync/comm/oneshot.rs index 742686069e283..c9782db5c24b6 100644 --- a/src/libsync/comm/oneshot.rs +++ b/src/libsync/comm/oneshot.rs @@ -34,7 +34,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::mem; use rustrt::local::Local; use rustrt::task::{Task, BlockedTask}; diff --git a/src/libsync/comm/select.rs b/src/libsync/comm/select.rs index 230bca624f5a7..737a4bfe29916 100644 --- a/src/libsync/comm/select.rs +++ b/src/libsync/comm/select.rs @@ -54,7 +54,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::cell::Cell; use core::kinds::marker; use core::mem; diff --git a/src/libsync/comm/shared.rs b/src/libsync/comm/shared.rs index 5ad4dea5d2a89..d13b2c32978c4 100644 --- a/src/libsync/comm/shared.rs +++ b/src/libsync/comm/shared.rs @@ -20,7 +20,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::cmp; use core::int; use rustrt::local::Local; diff --git a/src/libsync/comm/stream.rs b/src/libsync/comm/stream.rs index 6f337f1730950..9747c207a2261 100644 --- a/src/libsync/comm/stream.rs +++ b/src/libsync/comm/stream.rs @@ -19,7 +19,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::cmp; use core::int; use rustrt::local::Local; diff --git a/src/libsync/comm/sync.rs b/src/libsync/comm/sync.rs index 4d54df2fc19e5..cc3c2197c13f0 100644 --- a/src/libsync/comm/sync.rs +++ b/src/libsync/comm/sync.rs @@ -35,7 +35,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use collections::Vec; use collections::Collection; use core::mem; diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs index 8d2192aeb537e..913a58010d496 100644 --- a/src/libsync/deque.rs +++ b/src/libsync/deque.rs @@ -54,7 +54,7 @@ use core::prelude::*; use alloc::arc::Arc; use alloc::heap::{allocate, deallocate}; -use alloc::owned::Box; +use alloc::boxed::Box; use collections::Vec; use core::kinds::marker; use core::mem::{forget, min_align_of, size_of, transmute}; diff --git a/src/libsync/mpsc_queue.rs b/src/libsync/mpsc_queue.rs index ecd37e6888055..759695fe5b6dd 100644 --- a/src/libsync/mpsc_queue.rs +++ b/src/libsync/mpsc_queue.rs @@ -42,7 +42,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::mem; use core::ty::Unsafe; diff --git a/src/libsync/mutex.rs b/src/libsync/mutex.rs index a10ec7458690a..990d743465d69 100644 --- a/src/libsync/mutex.rs +++ b/src/libsync/mutex.rs @@ -59,7 +59,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::atomics; use core::kinds::marker; use core::mem; diff --git a/src/libsync/spsc_queue.rs b/src/libsync/spsc_queue.rs index 2834d404c1879..cf4d3222ed0ed 100644 --- a/src/libsync/spsc_queue.rs +++ b/src/libsync/spsc_queue.rs @@ -37,7 +37,7 @@ use core::prelude::*; -use alloc::owned::Box; +use alloc::boxed::Box; use core::mem; use core::ty::Unsafe; diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/new-box-syntax-bad.rs index 383a0ac46193f..602ffe2680b04 100644 --- a/src/test/compile-fail/new-box-syntax-bad.rs +++ b/src/test/compile-fail/new-box-syntax-bad.rs @@ -14,7 +14,7 @@ // Tests that the new `box` syntax works with unique pointers and GC pointers. use std::gc::{Gc, GC}; -use std::owned::{Box, HEAP}; +use std::boxed::{Box, HEAP}; pub fn main() { let x: Gc = box(HEAP) 2; //~ ERROR mismatched types diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index b16bef3fc9902..f61a8837e2c7c 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -14,7 +14,7 @@ // Tests that the new `box` syntax works with unique pointers and GC pointers. use std::gc::{Gc, GC}; -use std::owned::{Box, HEAP}; +use std::boxed::{Box, HEAP}; struct Structure { x: int, @@ -33,4 +33,3 @@ pub fn main() { let c = box()(3i + 4); let d = box(GC)(5i + 6); } - diff --git a/src/test/run-pass/unit-like-struct-drop-run.rs b/src/test/run-pass/unit-like-struct-drop-run.rs index ae4623c6e66eb..3a1cc0331a3e6 100644 --- a/src/test/run-pass/unit-like-struct-drop-run.rs +++ b/src/test/run-pass/unit-like-struct-drop-run.rs @@ -10,7 +10,7 @@ // Make sure the destructor is run for unit-like structs. -use std::owned::AnyOwnExt; +use std::boxed::BoxAny; use std::task; struct Foo; @@ -26,6 +26,6 @@ pub fn main() { let _b = Foo; }); - let s = x.unwrap_err().move::<&'static str>().unwrap(); + let s = x.unwrap_err().downcast::<&'static str>().unwrap(); assert_eq!(s.as_slice(), "This failure should happen."); }