diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el index f436bcb27ce36..580e5f89cd4e0 100644 --- a/src/etc/emacs/rust-mode.el +++ b/src/etc/emacs/rust-mode.el @@ -169,7 +169,7 @@ ;; Font-locking definitions and helpers (defconst rust-mode-keywords '("as" - "break" + "box" "break" "continue" "crate" "do" "else" "enum" "extern" diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index ec14820fc5db9..95062d84e0985 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -517,7 +517,7 @@ mod tests { #[bench] pub fn bench_copy_nonarena(b: &mut Bencher) { b.iter(|| { - ~Point { + box Point { x: 1, y: 2, z: 3, @@ -569,7 +569,7 @@ mod tests { #[bench] pub fn bench_noncopy_nonarena(b: &mut Bencher) { b.iter(|| { - ~Noncopy { + box Noncopy { string: "hello world".to_owned(), array: vec!( 1, 2, 3, 4, 5 ), } diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index b6dc790ea88a0..30add69564640 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -377,8 +377,8 @@ impl Leaf { == Less); let branch_return = Node::new_branch(vec!(BranchElt::new(midpoint.key.clone(), midpoint.value.clone(), - ~Node::new_leaf(left_leaf))), - ~Node::new_leaf(right_leaf)); + box Node::new_leaf(left_leaf))), + box Node::new_leaf(right_leaf)); return (branch_return, true); } (Node::new_leaf(self.elts.clone()), true) @@ -540,10 +540,10 @@ impl Branch { //so we can return false. LeafNode(..) => { if index.unwrap() == self.elts.len() { - self.rightmost_child = ~new_branch.clone(); + self.rightmost_child = box new_branch.clone(); } else { - self.elts.get_mut(index.unwrap()).left = ~new_branch.clone(); + self.elts.get_mut(index.unwrap()).left = box new_branch.clone(); } return (Node::new_branch(self.clone().elts, self.clone().rightmost_child), @@ -561,10 +561,10 @@ impl Branch { //and return it, saying we have inserted a new element. LeafNode(..) => { if index.unwrap() == self.elts.len() { - self.rightmost_child = ~new_branch; + self.rightmost_child = box new_branch; } else { - self.elts.get_mut(index.unwrap()).left = ~new_branch; + self.elts.get_mut(index.unwrap()).left = box new_branch; } return (Node::new_branch(self.clone().elts, self.clone().rightmost_child), @@ -604,9 +604,9 @@ impl Branch { new_branch = Node::new_branch( vec!(BranchElt::new(midpoint.clone().key, midpoint.clone().value, - ~Node::new_branch(new_left, + box Node::new_branch(new_left, midpoint.clone().left))), - ~Node::new_branch(new_right, self.clone().rightmost_child)); + box Node::new_branch(new_right, self.clone().rightmost_child)); return (new_branch, true); } } diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index df1bc28508c15..0f82942d7e788 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -238,7 +238,7 @@ impl Deque for DList { /// /// O(1) fn push_front(&mut self, elt: T) { - self.push_front_node(~Node::new(elt)) + self.push_front_node(box Node::new(elt)) } /// Remove the first element and return it, or None if the list is empty @@ -252,7 +252,7 @@ impl Deque for DList { /// /// O(1) fn push_back(&mut self, elt: T) { - self.push_back_node(~Node::new(elt)) + self.push_back_node(box Node::new(elt)) } /// Remove the last element and return it, or None if the list is empty @@ -555,7 +555,7 @@ impl<'a, A> MutItems<'a, A> { impl<'a, A> ListInsertion for MutItems<'a, A> { #[inline] fn insert_next(&mut self, elt: A) { - self.insert_next_node(~Node::new(elt)) + self.insert_next_node(box Node::new(elt)) } #[inline] @@ -675,19 +675,19 @@ mod tests { assert_eq!(m.pop_front(), None); assert_eq!(m.pop_back(), None); assert_eq!(m.pop_front(), None); - m.push_front(~1); + m.push_front(box 1); assert_eq!(m.pop_front(), Some(~1)); - m.push_back(~2); - m.push_back(~3); + m.push_back(box 2); + m.push_back(box 3); assert_eq!(m.len(), 2); assert_eq!(m.pop_front(), Some(~2)); assert_eq!(m.pop_front(), Some(~3)); assert_eq!(m.len(), 0); assert_eq!(m.pop_front(), None); - m.push_back(~1); - m.push_back(~3); - m.push_back(~5); - m.push_back(~7); + m.push_back(box 1); + m.push_back(box 3); + m.push_back(box 5); + m.push_back(box 7); assert_eq!(m.pop_front(), Some(~1)); let mut n = DList::new(); diff --git a/src/libcollections/lru_cache.rs b/src/libcollections/lru_cache.rs index 097513c6c5701..22876bf39752c 100644 --- a/src/libcollections/lru_cache.rs +++ b/src/libcollections/lru_cache.rs @@ -93,7 +93,7 @@ impl LruCache { let cache = LruCache { map: HashMap::new(), max_size: capacity, - head: unsafe{ cast::transmute(~mem::uninit::>()) }, + head: unsafe{ cast::transmute(box mem::uninit::>()) }, }; unsafe { (*cache.head).next = cache.head; @@ -111,7 +111,7 @@ impl LruCache { (node_ptr, None) } None => { - let mut node = ~LruEntry::new(k, v); + let mut node = box LruEntry::new(k, v); let node_ptr: *mut LruEntry = &mut *node; (node_ptr, Some(node)) } diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index dd1db85fc20c4..e37e2a6f234b7 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -273,19 +273,19 @@ mod tests { let mut heap = PriorityQueue::from_vec(vec!(~2, ~4, ~9)); assert_eq!(heap.len(), 3); assert!(*heap.top() == ~9); - heap.push(~11); + heap.push(box 11); assert_eq!(heap.len(), 4); assert!(*heap.top() == ~11); - heap.push(~5); + heap.push(box 5); assert_eq!(heap.len(), 5); assert!(*heap.top() == ~11); - heap.push(~27); + heap.push(box 27); assert_eq!(heap.len(), 6); assert!(*heap.top() == ~27); - heap.push(~3); + heap.push(box 3); assert_eq!(heap.len(), 7); assert!(*heap.top() == ~27); - heap.push(~103); + heap.push(box 103); assert_eq!(heap.len(), 8); assert!(*heap.top() == ~103); } diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 5bfe04c7e512c..e236e58b08d38 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -459,7 +459,7 @@ mod test_map { #[test] fn test_move_iter() { let mut m = SmallIntMap::new(); - m.insert(1, ~2); + m.insert(1, box 2); let mut called = false; for (k, v) in m.move_iter() { assert!(!called); @@ -468,7 +468,7 @@ mod test_map { assert_eq!(v, ~2); } assert!(called); - m.insert(2, ~1); + m.insert(2, box 1); } } diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index ec1d3f5750adf..3f993fc64a4af 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -834,7 +834,7 @@ fn insert(node: &mut Option<~TreeNode>, } } None => { - *node = Some(~TreeNode::new(key, value)); + *node = Some(box TreeNode::new(key, value)); None } } diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 3a0d81070fef0..1bff058d6f5b8 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -448,7 +448,7 @@ fn insert(count: &mut uint, child: &mut Child, key: uint, value: T, // have to move out of `child`. match mem::replace(child, Nothing) { External(stored_key, stored_value) => { - let mut new = ~TrieNode::new(); + let mut new = box TrieNode::new(); insert(&mut new.count, &mut new.children[chunk(stored_key, idx)], stored_key, stored_value, idx + 1); diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index 3aa3d6742eb00..4da0214c27cf4 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -23,7 +23,7 @@ use std::unstable::sync::Exclusive; /// This is the only exported function from this module. pub fn event_loop() -> ~EventLoop:Send { - ~BasicLoop::new() as ~EventLoop:Send + box BasicLoop::new() as ~EventLoop:Send } struct BasicLoop { @@ -143,7 +143,7 @@ impl EventLoop for BasicLoop { fn pausable_idle_callback(&mut self, cb: ~Callback:Send) -> ~PausableIdleCallback:Send { - let callback = ~BasicPausable::new(self, cb); + let callback = box BasicPausable::new(self, cb); rtassert!(self.idle.is_none()); unsafe { let cb_ptr: &*mut BasicPausable = cast::transmute(&callback); @@ -156,7 +156,7 @@ impl EventLoop for BasicLoop { let id = self.next_remote; self.next_remote += 1; self.remotes.push((id, f)); - ~BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback:Send + box BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback:Send } fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory> { None } diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index 0a3d6a7803464..c30a93c23230f 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -152,7 +152,7 @@ struct Registers { #[cfg(target_arch = "x86")] fn new_regs() -> ~Registers { - ~Registers { + box Registers { eax: 0, ebx: 0, ecx: 0, edx: 0, ebp: 0, esi: 0, edi: 0, esp: 0, cs: 0, ds: 0, ss: 0, es: 0, fs: 0, gs: 0, @@ -190,9 +190,9 @@ type Registers = [uint, ..34]; type Registers = [uint, ..22]; #[cfg(windows, target_arch = "x86_64")] -fn new_regs() -> ~Registers { ~([0, .. 34]) } +fn new_regs() -> ~Registers { box [0, .. 34] } #[cfg(not(windows), target_arch = "x86_64")] -fn new_regs() -> ~Registers { ~([0, .. 22]) } +fn new_regs() -> ~Registers { box {let v = [0, .. 22]; v} } #[cfg(target_arch = "x86_64")] fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, @@ -241,7 +241,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, type Registers = [uint, ..32]; #[cfg(target_arch = "arm")] -fn new_regs() -> ~Registers { ~([0, .. 32]) } +fn new_regs() -> ~Registers { box {[0, .. 32]} } #[cfg(target_arch = "arm")] fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, @@ -270,7 +270,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, type Registers = [uint, ..32]; #[cfg(target_arch = "mips")] -fn new_regs() -> ~Registers { ~([0, .. 32]) } +fn new_regs() -> ~Registers { box [0, .. 32] } #[cfg(target_arch = "mips")] fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 77715b1f5fb38..f86743d10c706 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -427,7 +427,7 @@ impl SchedPool { for worker in workers.move_iter() { rtdebug!("inserting a regular scheduler"); - let mut sched = ~Scheduler::new(pool.id, + let mut sched = box Scheduler::new(pool.id, (pool.factory)(), worker, pool.stealers.clone(), @@ -488,7 +488,7 @@ impl SchedPool { // Create the new scheduler, using the same sleeper list as all the // other schedulers as well as having a stealer handle to all other // schedulers. - let mut sched = ~Scheduler::new(self.id, + let mut sched = box Scheduler::new(self.id, (self.factory)(), worker, self.stealers.clone(), diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index 74872086b35c6..c323dbb92d742 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -183,7 +183,7 @@ impl Scheduler { pub fn bootstrap(mut ~self) { // Build an Idle callback. - let cb = ~SchedRunner as ~Callback:Send; + let cb = box SchedRunner as ~Callback:Send; self.idle_callback = Some(self.event_loop.pausable_idle_callback(cb)); // Create a task for the scheduler with an empty context. @@ -869,7 +869,7 @@ impl Scheduler { } pub fn make_handle(&mut self) -> SchedHandle { - let remote = self.event_loop.remote_callback(~SchedRunner); + let remote = self.event_loop.remote_callback(box SchedRunner); return SchedHandle { remote: remote, @@ -1140,7 +1140,7 @@ mod test { let (_p, state) = TaskState::new(); // Our normal scheduler - let mut normal_sched = ~Scheduler::new( + let mut normal_sched = box Scheduler::new( 1, basic::event_loop(), normal_worker, @@ -1152,7 +1152,7 @@ mod test { let friend_handle = normal_sched.make_handle(); // Our special scheduler - let mut special_sched = ~Scheduler::new_special( + let mut special_sched = box Scheduler::new_special( 1, basic::event_loop(), special_worker, @@ -1403,7 +1403,7 @@ mod test { impl Drop for S { fn drop(&mut self) { - let _foo = ~0; + let _foo = box 0; } } diff --git a/src/libgreen/simple.rs b/src/libgreen/simple.rs index 4f2f0c1addb36..37b0aa4f611a7 100644 --- a/src/libgreen/simple.rs +++ b/src/libgreen/simple.rs @@ -82,8 +82,8 @@ impl Runtime for SimpleTask { } pub fn task() -> ~Task { - let mut task = ~Task::new(); - task.put_runtime(~SimpleTask { + let mut task = box Task::new(); + task.put_runtime(box SimpleTask { lock: unsafe {NativeMutex::new()}, awoken: false, }); diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index 150e2704c5977..846fcdb1881d5 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -159,14 +159,14 @@ impl GreenTask { /// useful when creating scheduler tasks. pub fn new_typed(coroutine: Option, task_type: TaskType) -> ~GreenTask { - ~GreenTask { + box GreenTask { pool_id: 0, coroutine: coroutine, task_type: task_type, sched: None, handle: None, nasty_deschedule_lock: unsafe { NativeMutex::new() }, - task: Some(~Task::new()), + task: Some(box Task::new()), } } diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 87c82e1dd7d42..1571370d03314 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -203,7 +203,7 @@ pub fn log(level: u32, args: &fmt::Arguments) { // frob the slot while we're doing the logging. This will destroy any logger // set during logging. let mut logger = local_data::pop(local_logger).unwrap_or_else(|| { - ~DefaultLogger { handle: io::stderr() } as ~Logger:Send + box DefaultLogger { handle: io::stderr() } as ~Logger:Send }); logger.log(level, args); local_data::set(local_logger, logger); @@ -286,7 +286,7 @@ fn init() { LOG_LEVEL = max_level; assert!(DIRECTIVES.is_null()); - DIRECTIVES = cast::transmute(~directives); + DIRECTIVES = cast::transmute(box directives); // Schedule the cleanup for this global for when the runtime exits. rt::at_exit(proc() { diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index d97a0430fea4b..7c19eb5432624 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -176,7 +176,7 @@ impl rtio::RtioPipe for FileDesc { self.inner_write(buf) } fn clone(&self) -> ~rtio::RtioPipe:Send { - ~FileDesc { inner: self.inner.clone() } as ~rtio::RtioPipe:Send + box FileDesc { inner: self.inner.clone() } as ~rtio::RtioPipe:Send } } diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index de515659bf7ad..6a6fb31d3e3f7 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -207,7 +207,7 @@ impl rtio::RtioPipe for FileDesc { self.inner_write(buf) } fn clone(&self) -> ~rtio::RtioPipe:Send { - ~FileDesc { inner: self.inner.clone() } as ~rtio::RtioPipe:Send + box FileDesc { inner: self.inner.clone() } as ~rtio::RtioPipe:Send } } diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs index 944766e8fd070..fb92d0d55cf39 100644 --- a/src/libnative/io/mod.rs +++ b/src/libnative/io/mod.rs @@ -167,20 +167,20 @@ impl rtio::IoFactory for IoFactory { // networking fn tcp_connect(&mut self, addr: SocketAddr, timeout: Option) -> IoResult<~RtioTcpStream:Send> { - net::TcpStream::connect(addr, timeout).map(|s| ~s as ~RtioTcpStream:Send) + net::TcpStream::connect(addr, timeout).map(|s| box s as ~RtioTcpStream:Send) } fn tcp_bind(&mut self, addr: SocketAddr) -> IoResult<~RtioTcpListener:Send> { - net::TcpListener::bind(addr).map(|s| ~s as ~RtioTcpListener:Send) + net::TcpListener::bind(addr).map(|s| box s as ~RtioTcpListener:Send) } fn udp_bind(&mut self, addr: SocketAddr) -> IoResult<~RtioUdpSocket:Send> { - net::UdpSocket::bind(addr).map(|u| ~u as ~RtioUdpSocket:Send) + net::UdpSocket::bind(addr).map(|u| box u as ~RtioUdpSocket:Send) } fn unix_bind(&mut self, path: &CString) -> IoResult<~RtioUnixListener:Send> { - pipe::UnixListener::bind(path).map(|s| ~s as ~RtioUnixListener:Send) + pipe::UnixListener::bind(path).map(|s| box s as ~RtioUnixListener:Send) } fn unix_connect(&mut self, path: &CString, timeout: Option) -> IoResult<~RtioPipe:Send> { - pipe::UnixStream::connect(path, timeout).map(|s| ~s as ~RtioPipe:Send) + pipe::UnixStream::connect(path, timeout).map(|s| box s as ~RtioPipe:Send) } fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>, hint: Option) -> IoResult<~[ai::Info]> { @@ -194,11 +194,11 @@ impl rtio::IoFactory for IoFactory { rtio::CloseSynchronously | rtio::CloseAsynchronously => true, rtio::DontClose => false }; - ~file::FileDesc::new(fd, close) as ~RtioFileStream:Send + box file::FileDesc::new(fd, close) as ~RtioFileStream:Send } fn fs_open(&mut self, path: &CString, fm: io::FileMode, fa: io::FileAccess) -> IoResult<~RtioFileStream:Send> { - file::open(path, fm, fa).map(|fd| ~fd as ~RtioFileStream:Send) + file::open(path, fm, fa).map(|fd| box fd as ~RtioFileStream:Send) } fn fs_unlink(&mut self, path: &CString) -> IoResult<()> { file::unlink(path) @@ -245,26 +245,26 @@ impl rtio::IoFactory for IoFactory { // misc fn timer_init(&mut self) -> IoResult<~RtioTimer:Send> { - timer::Timer::new().map(|t| ~t as ~RtioTimer:Send) + timer::Timer::new().map(|t| box t as ~RtioTimer:Send) } fn spawn(&mut self, config: ProcessConfig) -> IoResult<(~RtioProcess:Send, ~[Option<~RtioPipe:Send>])> { process::Process::spawn(config).map(|(p, io)| { - (~p as ~RtioProcess:Send, - io.move_iter().map(|p| p.map(|p| ~p as ~RtioPipe:Send)).collect()) + (box p as ~RtioProcess:Send, + io.move_iter().map(|p| p.map(|p| box p as ~RtioPipe:Send)).collect()) }) } fn kill(&mut self, pid: libc::pid_t, signum: int) -> IoResult<()> { process::Process::kill(pid, signum) } fn pipe_open(&mut self, fd: c_int) -> IoResult<~RtioPipe:Send> { - Ok(~file::FileDesc::new(fd, true) as ~RtioPipe:Send) + Ok(box file::FileDesc::new(fd, true) as ~RtioPipe:Send) } fn tty_open(&mut self, fd: c_int, _readable: bool) -> IoResult<~RtioTTY:Send> { if unsafe { libc::isatty(fd) } != 0 { - Ok(~file::FileDesc::new(fd, true) as ~RtioTTY:Send) + Ok(box file::FileDesc::new(fd, true) as ~RtioTTY:Send) } else { Err(IoError { kind: io::MismatchedFileTypeForOperation, diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index cc41da846b2b2..c47e549b20acc 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -352,7 +352,7 @@ impl rtio::RtioTcpStream for TcpStream { } fn clone(&self) -> ~rtio::RtioTcpStream:Send { - ~TcpStream { inner: self.inner.clone() } as ~rtio::RtioTcpStream:Send + box TcpStream { inner: self.inner.clone() } as ~rtio::RtioTcpStream:Send } fn close_write(&mut self) -> IoResult<()> { super::mkerr_libc(unsafe { @@ -419,7 +419,7 @@ impl TcpListener { impl rtio::RtioTcpListener for TcpListener { fn listen(~self) -> IoResult<~rtio::RtioTcpAcceptor:Send> { - self.native_listen(128).map(|a| ~a as ~rtio::RtioTcpAcceptor:Send) + self.native_listen(128).map(|a| box a as ~rtio::RtioTcpAcceptor:Send) } } @@ -466,7 +466,7 @@ impl rtio::RtioSocket for TcpAcceptor { impl rtio::RtioTcpAcceptor for TcpAcceptor { fn accept(&mut self) -> IoResult<~rtio::RtioTcpStream:Send> { - self.native_accept().map(|s| ~s as ~rtio::RtioTcpStream:Send) + self.native_accept().map(|s| box s as ~rtio::RtioTcpStream:Send) } fn accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) } @@ -638,6 +638,6 @@ impl rtio::RtioUdpSocket for UdpSocket { } fn clone(&self) -> ~rtio::RtioUdpSocket:Send { - ~UdpSocket { inner: self.inner.clone() } as ~rtio::RtioUdpSocket:Send + box UdpSocket { inner: self.inner.clone() } as ~rtio::RtioUdpSocket:Send } } diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs index 190cae05d4343..178247f3190f8 100644 --- a/src/libnative/io/pipe_unix.rs +++ b/src/libnative/io/pipe_unix.rs @@ -145,7 +145,7 @@ impl rtio::RtioPipe for UnixStream { } fn clone(&self) -> ~rtio::RtioPipe:Send { - ~UnixStream { inner: self.inner.clone() } as ~rtio::RtioPipe:Send + box UnixStream { inner: self.inner.clone() } as ~rtio::RtioPipe:Send } } @@ -177,7 +177,7 @@ impl UnixListener { impl rtio::RtioUnixListener for UnixListener { fn listen(~self) -> IoResult<~rtio::RtioUnixAcceptor:Send> { - self.native_listen(128).map(|a| ~a as ~rtio::RtioUnixAcceptor:Send) + self.native_listen(128).map(|a| box a as ~rtio::RtioUnixAcceptor:Send) } } @@ -210,7 +210,7 @@ impl UnixAcceptor { impl rtio::RtioUnixAcceptor for UnixAcceptor { fn accept(&mut self) -> IoResult<~rtio::RtioPipe:Send> { - self.native_accept().map(|s| ~s as ~rtio::RtioPipe:Send) + self.native_accept().map(|s| box s as ~rtio::RtioPipe:Send) } fn set_timeout(&mut self, timeout: Option) { self.deadline = timeout.map(|a| ::io::timer::now() + a).unwrap_or(0); diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs index a4f09ded0ac11..bf7f82ef6622c 100644 --- a/src/libnative/io/pipe_win32.rs +++ b/src/libnative/io/pipe_win32.rs @@ -354,7 +354,7 @@ impl rtio::RtioPipe for UnixStream { } fn clone(&self) -> ~rtio::RtioPipe:Send { - ~UnixStream { + box UnixStream { inner: self.inner.clone(), read: None, write: None, @@ -403,7 +403,7 @@ impl Drop for UnixListener { impl rtio::RtioUnixListener for UnixListener { fn listen(~self) -> IoResult<~rtio::RtioUnixAcceptor:Send> { - self.native_listen().map(|a| ~a as ~rtio::RtioUnixAcceptor:Send) + self.native_listen().map(|a| box a as ~rtio::RtioUnixAcceptor:Send) } } @@ -527,7 +527,7 @@ impl UnixAcceptor { impl rtio::RtioUnixAcceptor for UnixAcceptor { fn accept(&mut self) -> IoResult<~rtio::RtioPipe:Send> { - self.native_accept().map(|s| ~s as ~rtio::RtioPipe:Send) + self.native_accept().map(|s| box s as ~rtio::RtioPipe:Send) } fn set_timeout(&mut self, timeout: Option) { self.deadline = timeout.map(|i| i + ::io::timer::now()).unwrap_or(0); diff --git a/src/libnative/io/timer_helper.rs b/src/libnative/io/timer_helper.rs index 4b29feab84fd0..298dd2f368df6 100644 --- a/src/libnative/io/timer_helper.rs +++ b/src/libnative/io/timer_helper.rs @@ -48,7 +48,7 @@ pub fn boot(helper: fn(imp::signal, Receiver)) { let (tx, rx) = channel(); // promote this to a shared channel drop(tx.clone()); - HELPER_CHAN = cast::transmute(~tx); + HELPER_CHAN = cast::transmute(box tx); let (receive, send) = imp::new(); HELPER_SIGNAL = send; diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs index e5d4a6bb02b86..8435c05c7716a 100644 --- a/src/libnative/io/timer_unix.rs +++ b/src/libnative/io/timer_unix.rs @@ -207,7 +207,7 @@ impl Timer { let id = unsafe { ID.fetch_add(1, atomics::Relaxed) }; Ok(Timer { id: id, - inner: Some(~Inner { + inner: Some(box Inner { tx: None, interval: 0, target: 0, diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 8a82ae55faa37..512080e420480 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -32,7 +32,7 @@ use task; /// Creates a new Task which is ready to execute as a 1:1 task. pub fn new(stack_bounds: (uint, uint)) -> ~Task { - let mut task = ~Task::new(); + let mut task = box Task::new(); let mut ops = ops(); ops.stack_bounds = stack_bounds; task.put_runtime(ops); @@ -40,7 +40,7 @@ pub fn new(stack_bounds: (uint, uint)) -> ~Task { } fn ops() -> ~Ops { - ~Ops { + box Ops { lock: unsafe { NativeMutex::new() }, awoken: false, io: io::IoFactory::new(), @@ -62,7 +62,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc():Send) { stderr, stdout, } = opts; - let mut task = ~Task::new(); + let mut task = box Task::new(); task.name = name; task.stderr = stderr; task.stdout = stdout; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 237030f365dd5..3393abc8b2615 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -602,7 +602,7 @@ pub fn task_rng() -> TaskRng { Ok(r) => r, Err(e) => fail!("could not initialize task_rng: {}", e) }; - let mut rng = ~reseeding::ReseedingRng::new(r, + let mut rng = box reseeding::ReseedingRng::new(r, TASK_RNG_RESEED_THRESHOLD, TaskRngReseeder); let ptr = &mut *rng as *mut TaskRngInner; diff --git a/src/librand/rand_impls.rs b/src/librand/rand_impls.rs index fbd160554602f..b4551fcc312df 100644 --- a/src/librand/rand_impls.rs +++ b/src/librand/rand_impls.rs @@ -216,7 +216,7 @@ impl Rand for Option { impl Rand for ~T { #[inline] - fn rand(rng: &mut R) -> ~T { ~rng.gen() } + fn rand(rng: &mut R) -> ~T { box rng.gen() } } impl Rand for @T { diff --git a/src/librand/reader.rs b/src/librand/reader.rs index 025dc2a25754b..d098c2cf0c144 100644 --- a/src/librand/reader.rs +++ b/src/librand/reader.rs @@ -78,7 +78,7 @@ mod test { #[test] fn test_reader_rng_u64() { // transmute from the target to avoid endianness concerns. - let v = ~[1u64, 2u64, 3u64]; + let v = box [1u64, 2u64, 3u64]; let bytes: ~[u8] = unsafe {cast::transmute(v)}; let mut rng = ReaderRng::new(MemReader::new(bytes.move_iter().collect())); @@ -89,7 +89,7 @@ mod test { #[test] fn test_reader_rng_u32() { // transmute from the target to avoid endianness concerns. - let v = ~[1u32, 2u32, 3u32]; + let v = box [1u32, 2u32, 3u32]; let bytes: ~[u8] = unsafe {cast::transmute(v)}; let mut rng = ReaderRng::new(MemReader::new(bytes.move_iter().collect())); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index b579a9b9c64c1..a754c934a25d0 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -673,11 +673,11 @@ pub fn pretty_print_input(sess: Session, let mut rdr = MemReader::new(src); let out = match ofile { - None => ~io::stdout() as ~Writer, + None => box io::stdout() as ~Writer, Some(p) => { let r = io::File::create(&p); match r { - Ok(w) => ~w as ~Writer, + Ok(w) => box w as ~Writer, Err(e) => fail!("print-print failed to open {} due to {}", p.display(), e), } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index c9a40cffe587c..a94715bdaa505 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -387,7 +387,7 @@ pub fn monitor(f: proc():Send) { let mut r = io::ChanReader::new(rx); match task_builder.try(proc() { - io::stdio::set_stderr(~w); + io::stdio::set_stderr(box w); f() }) { Ok(()) => { /* fallthrough */ } @@ -425,7 +425,7 @@ pub fn monitor(f: proc():Send) { // Fail so the process returns a failure code, but don't pollute the // output with some unnecessary failure messages, we've already // printed everything that we needed to. - io::stdio::set_stderr(~io::util::NullWriter); + io::stdio::set_stderr(box io::util::NullWriter); fail!(); } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 742daa82ecd43..edbc787fe5cec 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -316,7 +316,7 @@ impl<'a, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, O> { debug!("Dataflow result:"); debug!("{}", { - self.pretty_print_to(~io::stderr(), blk).unwrap(); + self.pretty_print_to(box io::stderr(), blk).unwrap(); "" }); } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 74355357fe72c..0638fd5c4827e 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -60,7 +60,7 @@ impl<'a> MarkSymbolVisitor<'a> { MarkSymbolVisitor { worklist: worklist, tcx: tcx, - live_symbols: ~HashSet::new(), + live_symbols: box HashSet::new(), } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 9d8f668a4e1f6..a2dadc420669e 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1922,7 +1922,7 @@ fn trans_match_inner<'a>(scope_cx: &'a Block<'a>, if ty::type_is_empty(tcx, t) { // Special case for empty types let fail_cx = Cell::new(None); - let fail_handler = ~DynamicFailureHandler { + let fail_handler = box DynamicFailureHandler { bcx: scope_cx, sp: discr_expr.span, msg: InternedString::new("scrutinizing value that can't \ diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 1672e1f74eb08..97c9dcce5ef64 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -236,7 +236,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ if !ty::type_needs_drop(self.ccx.tcx(), ty) { return; } - let drop = ~DropValue { + let drop = box DropValue { is_immediate: false, on_unwind: ty::type_needs_unwind_cleanup(self.ccx.tcx(), ty), val: val, @@ -260,7 +260,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { */ if !ty::type_needs_drop(self.ccx.tcx(), ty) { return; } - let drop = ~DropValue { + let drop = box DropValue { is_immediate: true, on_unwind: ty::type_needs_unwind_cleanup(self.ccx.tcx(), ty), val: val, @@ -284,7 +284,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { * operation. */ - let drop = ~FreeValue { ptr: val, heap: heap }; + let drop = box FreeValue { ptr: val, heap: heap }; debug!("schedule_free_value({:?}, val={}, heap={:?})", cleanup_scope, diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 1b78079d74dc5..e8654da3457ee 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -757,7 +757,7 @@ pub fn create_function_debug_context(cx: &CrateContext, }); // Initialize fn debug context (including scope map and namespace map) - let fn_debug_context = ~FunctionDebugContextData { + let fn_debug_context = box FunctionDebugContextData { scope_map: RefCell::new(HashMap::new()), fn_metadata: fn_metadata, argument_counter: Cell::new(1), diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index bb4ac63529f7d..c114097fefa26 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1231,7 +1231,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t { } } - let t = ~t_box_ { + let t = box t_box_ { sty: st, id: cx.next_id.get(), flags: flags, @@ -1400,7 +1400,7 @@ pub fn mk_slice(cx: &ctxt, r: Region, tm: mt) -> t { pub fn mk_tup(cx: &ctxt, ts: Vec) -> t { mk_t(cx, ty_tup(ts)) } pub fn mk_closure(cx: &ctxt, fty: ClosureTy) -> t { - mk_t(cx, ty_closure(~fty)) + mk_t(cx, ty_closure(box fty)) } pub fn mk_bare_fn(cx: &ctxt, fty: BareFnTy) -> t { @@ -1433,7 +1433,7 @@ pub fn mk_trait(cx: &ctxt, bounds: BuiltinBounds) -> t { // take a copy of substs so that we own the vectors inside - let inner = ~TyTrait { + let inner = box TyTrait { def_id: did, substs: substs, store: store, diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index a4cc9f0cc2f2a..f8f9ca30712d5 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -150,7 +150,7 @@ pub fn super_fold_sty(this: &mut T, ty::ty_enum(tid, this.fold_substs(substs)) } ty::ty_trait(~ty::TyTrait { def_id, ref substs, store, bounds }) => { - ty::ty_trait(~ty::TyTrait{ + ty::ty_trait(box ty::TyTrait{ def_id: def_id, substs: this.fold_substs(substs), store: this.fold_trait_store(store), @@ -164,7 +164,7 @@ pub fn super_fold_sty(this: &mut T, ty::ty_bare_fn(this.fold_bare_fn_ty(f)) } ty::ty_closure(ref f) => { - ty::ty_closure(~this.fold_closure_ty(*f)) + ty::ty_closure(box this.fold_closure_ty(*f)) } ty::ty_rptr(r, ref tm) => { ty::ty_rptr(this.fold_region(r), diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index cbc3be3f6e164..16faccbc9c2e4 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -593,7 +593,7 @@ mod tests { let tests = wikipedia_tests; - let mut sh = ~Sha256::new(); + let mut sh = box Sha256::new(); test_hash(sh, tests.as_slice()); } diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 06d768b434250..73812df252de5 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -724,14 +724,14 @@ impl Clean for ast::Ty { debug!("span corresponds to `{}`", codemap.span_to_str(self.span)); match self.node { TyNil => Unit, - TyPtr(ref m) => RawPointer(m.mutbl.clean(), ~m.ty.clean()), + TyPtr(ref m) => RawPointer(m.mutbl.clean(), box m.ty.clean()), TyRptr(ref l, ref m) => BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(), - type_: ~m.ty.clean()}, - TyBox(ty) => Managed(~ty.clean()), - TyUniq(ty) => Unique(~ty.clean()), - TyVec(ty) => Vector(~ty.clean()), - TyFixedLengthVec(ty, ref e) => FixedVector(~ty.clean(), + type_: box m.ty.clean()}, + TyBox(ty) => Managed(box ty.clean()), + TyUniq(ty) => Unique(box ty.clean()), + TyVec(ty) => Vector(box ty.clean()), + TyFixedLengthVec(ty, ref e) => FixedVector(box ty.clean(), e.span.to_src()), TyTup(ref tys) => Tuple(tys.iter().map(|x| x.clean()).collect()), TyPath(ref p, ref tpbs, id) => { @@ -739,9 +739,9 @@ impl Clean for ast::Ty { tpbs.clean().map(|x| x.move_iter().collect()), id) } - TyClosure(ref c, region) => Closure(~c.clean(), region.clean()), - TyProc(ref c) => Proc(~c.clean()), - TyBareFn(ref barefn) => BareFunction(~barefn.clean()), + TyClosure(ref c, region) => Closure(box c.clean(), region.clean()), + TyProc(ref c) => Proc(box c.clean()), + TyBareFn(ref barefn) => BareFunction(box barefn.clean()), TyBot => Bottom, ref x => fail!("Unimplemented type {:?}", x), } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index f4c2151916932..24b3e1128ea5f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -379,9 +379,9 @@ fn json_output(krate: clean::Crate, res: Vec , // "crate": { parsed crate ... }, // "plugins": { output of plugins ... } // } - let mut json = ~collections::TreeMap::new(); + let mut json = box collections::TreeMap::new(); json.insert("schema".to_owned(), json::String(SCHEMA_VERSION.to_owned())); - let plugins_json = ~res.move_iter().filter_map(|opt| opt).collect(); + let plugins_json = box res.move_iter().filter_map(|opt| opt).collect(); // FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode // straight to the Rust JSON representation. diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index b05fdc826ff10..01cbd15be222a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -123,17 +123,17 @@ fn runtest(test: &str, cratename: &str, libs: HashSet, should_fail: bool, let (tx, rx) = channel(); let w1 = io::ChanWriter::new(tx); let w2 = w1.clone(); - let old = io::stdio::set_stderr(~w1); + let old = io::stdio::set_stderr(box w1); spawn(proc() { let mut p = io::ChanReader::new(rx); - let mut err = old.unwrap_or(~io::stderr() as ~Writer:Send); + let mut err = old.unwrap_or(box io::stderr() as ~Writer:Send); io::util::copy(&mut p, &mut err).unwrap(); }); - let emitter = diagnostic::EmitterWriter::new(~w2); + let emitter = diagnostic::EmitterWriter::new(box w2); // Compile the code let codemap = CodeMap::new(); - let diagnostic_handler = diagnostic::mk_handler(~emitter); + let diagnostic_handler = diagnostic::mk_handler(box emitter); let span_diagnostic_handler = diagnostic::mk_span_handler(diagnostic_handler, codemap); diff --git a/src/librustuv/async.rs b/src/librustuv/async.rs index dcbd0baf6f329..7b19be09bde50 100644 --- a/src/librustuv/async.rs +++ b/src/librustuv/async.rs @@ -37,7 +37,7 @@ impl AsyncWatcher { uvll::uv_async_init(loop_.handle, handle, async_cb) }, 0); let flag = Exclusive::new(false); - let payload = ~Payload { callback: cb, exit_flag: flag.clone() }; + let payload = box Payload { callback: cb, exit_flag: flag.clone() }; unsafe { let payload: *u8 = cast::transmute(payload); uvll::set_data_for_uv_handle(handle, payload); @@ -146,7 +146,7 @@ mod test_remote { } let (tx, rx) = channel(); - let cb = ~MyCallback(Some(tx)); + let cb = box MyCallback(Some(tx)); let watcher = AsyncWatcher::new(&mut local_loop().loop_, cb); let thread = Thread::start(proc() { diff --git a/src/librustuv/idle.rs b/src/librustuv/idle.rs index 4d7da29aa9a83..9fb525bc260b1 100644 --- a/src/librustuv/idle.rs +++ b/src/librustuv/idle.rs @@ -28,7 +28,7 @@ impl IdleWatcher { assert_eq!(unsafe { uvll::uv_idle_init(loop_.handle, handle) }, 0); - let me = ~IdleWatcher { + let me = box IdleWatcher { handle: handle, idle_flag: false, closed: false, @@ -41,7 +41,7 @@ impl IdleWatcher { let handle = UvHandle::alloc(None::, uvll::UV_IDLE); unsafe { assert_eq!(uvll::uv_idle_init(loop_.handle, handle), 0); - let data: *c_void = cast::transmute(~f); + let data: *c_void = cast::transmute(box f); uvll::set_data_for_uv_handle(handle, data); assert_eq!(uvll::uv_idle_start(handle, onetime_cb), 0) } @@ -128,7 +128,7 @@ mod test { fn mk(v: uint) -> (~IdleWatcher, Chan) { let rc = Rc::new(RefCell::new((None, 0))); - let cb = ~MyCallback(rc.clone(), v); + let cb = box MyCallback(rc.clone(), v); let cb = cb as ~Callback:; let cb = unsafe { cast::transmute(cb) }; (IdleWatcher::new(&mut local_loop().loop_, cb), rc) @@ -173,7 +173,7 @@ mod test { // never reschedule us, so we're guaranteed to stay on the same // task/event loop. use std::io; - drop(io::stdio::set_stderr(~io::util::NullWriter)); + drop(io::stdio::set_stderr(box io::util::NullWriter)); let (mut idle, _chan) = mk(1); idle.resume(); diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index d994a9aece214..f7631f8e41dfa 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -125,7 +125,7 @@ pub mod stream; /// } /// ``` pub fn event_loop() -> ~rtio::EventLoop:Send { - ~uvio::UvEventLoop::new() as ~rtio::EventLoop:Send + box uvio::UvEventLoop::new() as ~rtio::EventLoop:Send } /// A type that wraps a uv handle diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index 470a343b84ed6..e12276e8f5bb0 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -456,7 +456,7 @@ impl rtio::RtioTcpStream for TcpWatcher { } fn clone(&self) -> ~rtio::RtioTcpStream:Send { - ~TcpWatcher { + box TcpWatcher { handle: self.handle, stream: StreamWatcher::new(self.handle), home: self.home.clone(), @@ -522,7 +522,7 @@ impl TcpListener { uvll::uv_tcp_init(io.uv_loop(), handle) }, 0); let (tx, rx) = channel(); - let l = ~TcpListener { + let l = box TcpListener { home: io.make_handle(), handle: handle, closing_task: None, @@ -559,7 +559,7 @@ impl rtio::RtioSocket for TcpListener { impl rtio::RtioTcpListener for TcpListener { fn listen(~self) -> Result<~rtio::RtioTcpAcceptor:Send, IoError> { // create the acceptor object from ourselves - let mut acceptor = ~TcpAcceptor { + let mut acceptor = box TcpAcceptor { listener: self, timeout: AcceptTimeout::new(), }; @@ -583,7 +583,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: c_int) { }); let client = TcpWatcher::new_home(&loop_, tcp.home().clone()); assert_eq!(unsafe { uvll::uv_accept(server, client.handle) }, 0); - Ok(~client as ~rtio::RtioTcpStream:Send) + Ok(box client as ~rtio::RtioTcpStream:Send) } n => Err(uv_error_to_io_error(UvError(n))) }; @@ -880,7 +880,7 @@ impl rtio::RtioUdpSocket for UdpWatcher { } fn clone(&self) -> ~rtio::RtioUdpSocket:Send { - ~UdpWatcher { + box UdpWatcher { handle: self.handle, home: self.home.clone(), refcount: self.refcount.clone(), diff --git a/src/librustuv/pipe.rs b/src/librustuv/pipe.rs index 7277be1616b71..99551e8f35ba1 100644 --- a/src/librustuv/pipe.rs +++ b/src/librustuv/pipe.rs @@ -122,7 +122,7 @@ impl RtioPipe for PipeWatcher { } fn clone(&self) -> ~RtioPipe:Send { - ~PipeWatcher { + box PipeWatcher { stream: StreamWatcher::new(self.stream.handle), defused: false, home: self.home.clone(), @@ -165,7 +165,7 @@ impl PipeListener { // we close the pipe differently. We can't rely on // StreamWatcher's default close method. let (tx, rx) = channel(); - let p = ~PipeListener { + let p = box PipeListener { home: io.make_handle(), pipe: pipe.unwrap(), incoming: rx, @@ -181,7 +181,7 @@ impl PipeListener { impl RtioUnixListener for PipeListener { fn listen(~self) -> Result<~RtioUnixAcceptor:Send, IoError> { // create the acceptor object from ourselves - let mut acceptor = ~PipeAcceptor { + let mut acceptor = box PipeAcceptor { listener: self, timeout: net::AcceptTimeout::new(), }; @@ -214,7 +214,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) { }); let client = PipeWatcher::new_home(&loop_, pipe.home().clone(), false); assert_eq!(unsafe { uvll::uv_accept(server, client.handle()) }, 0); - Ok(~client as ~RtioPipe:Send) + Ok(box client as ~RtioPipe:Send) } n => Err(uv_error_to_io_error(UvError(n))) }; diff --git a/src/librustuv/process.rs b/src/librustuv/process.rs index 7b5b5d3235ba0..d6d1f754b2329 100644 --- a/src/librustuv/process.rs +++ b/src/librustuv/process.rs @@ -87,7 +87,7 @@ impl Process { }; let handle = UvHandle::alloc(None::, uvll::UV_PROCESS); - let process = ~Process { + let process = box Process { handle: handle, home: io_loop.make_handle(), to_wake: None, diff --git a/src/librustuv/queue.rs b/src/librustuv/queue.rs index 9e75991434f41..58761045b97fe 100644 --- a/src/librustuv/queue.rs +++ b/src/librustuv/queue.rs @@ -114,7 +114,7 @@ impl QueuePool { lock: unsafe {NativeMutex::new()}, queue: mpsc::Queue::new(), }); - let q = ~QueuePool { + let q = box QueuePool { refcnt: 0, queue: state, }; diff --git a/src/librustuv/signal.rs b/src/librustuv/signal.rs index 2dcf2de681c39..3f56d3ad6863b 100644 --- a/src/librustuv/signal.rs +++ b/src/librustuv/signal.rs @@ -28,7 +28,7 @@ pub struct SignalWatcher { impl SignalWatcher { pub fn new(io: &mut UvIoFactory, signum: Signum, channel: Sender) -> Result<~SignalWatcher, UvError> { - let s = ~SignalWatcher { + let s = box SignalWatcher { handle: UvHandle::alloc(None::, uvll::UV_SIGNAL), home: io.make_handle(), channel: channel, diff --git a/src/librustuv/timer.rs b/src/librustuv/timer.rs index 5c34fd8cc12e8..66c1a9039100a 100644 --- a/src/librustuv/timer.rs +++ b/src/librustuv/timer.rs @@ -34,7 +34,7 @@ pub enum NextAction { impl TimerWatcher { pub fn new(io: &mut UvIoFactory) -> ~TimerWatcher { let handle = io.make_handle(); - let me = ~TimerWatcher::new_home(&io.loop_, handle); + let me = box TimerWatcher::new_home(&io.loop_, handle); me.install() } diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 77b1fd1e4c4ba..80c09cc24d60c 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -103,7 +103,7 @@ impl EventLoop for UvEventLoop { fn remote_callback(&mut self, f: ~rtio::Callback:Send) -> ~rtio::RemoteCallback:Send { - ~AsyncWatcher::new(&mut self.uvio.loop_, f) as ~rtio::RemoteCallback:Send + box AsyncWatcher::new(&mut self.uvio.loop_, f) as ~rtio::RemoteCallback:Send } fn io<'a>(&'a mut self) -> Option<&'a mut rtio::IoFactory> { @@ -154,7 +154,7 @@ impl IoFactory for UvIoFactory { -> Result<~rtio::RtioTcpStream:Send, IoError> { match TcpWatcher::connect(self, addr, timeout) { - Ok(t) => Ok(~t as ~rtio::RtioTcpStream:Send), + Ok(t) => Ok(box t as ~rtio::RtioTcpStream:Send), Err(e) => Err(uv_error_to_io_error(e)), } } @@ -168,7 +168,7 @@ impl IoFactory for UvIoFactory { fn udp_bind(&mut self, addr: SocketAddr) -> Result<~rtio::RtioUdpSocket:Send, IoError> { match UdpWatcher::bind(self, addr) { - Ok(u) => Ok(~u as ~rtio::RtioUdpSocket:Send), + Ok(u) => Ok(box u as ~rtio::RtioUdpSocket:Send), Err(e) => Err(uv_error_to_io_error(e)), } } @@ -185,7 +185,7 @@ impl IoFactory for UvIoFactory { fn fs_from_raw_fd(&mut self, fd: c_int, close: rtio::CloseBehavior) -> ~rtio::RtioFileStream:Send { - ~FileWatcher::new(self, fd, close) as ~rtio::RtioFileStream:Send + box FileWatcher::new(self, fd, close) as ~rtio::RtioFileStream:Send } fn fs_open(&mut self, path: &CString, fm: FileMode, fa: FileAccess) @@ -205,7 +205,7 @@ impl IoFactory for UvIoFactory { }; match FsRequest::open(self, path, flags as int, mode as int) { - Ok(fs) => Ok(~fs as ~rtio::RtioFileStream:Send), + Ok(fs) => Ok(box fs as ~rtio::RtioFileStream:Send), Err(e) => Err(uv_error_to_io_error(e)) } } @@ -275,7 +275,7 @@ impl IoFactory for UvIoFactory { match Process::spawn(self, config) { Ok((p, io)) => { Ok((p as ~rtio::RtioProcess:Send, - io.move_iter().map(|i| i.map(|p| ~p as ~rtio::RtioPipe:Send)).collect())) + io.move_iter().map(|i| i.map(|p| box p as ~rtio::RtioPipe:Send)).collect())) } Err(e) => Err(uv_error_to_io_error(e)), } @@ -296,7 +296,7 @@ impl IoFactory for UvIoFactory { fn unix_connect(&mut self, path: &CString, timeout: Option) -> Result<~rtio::RtioPipe:Send, IoError> { match PipeWatcher::connect(self, path, timeout) { - Ok(p) => Ok(~p as ~rtio::RtioPipe:Send), + Ok(p) => Ok(box p as ~rtio::RtioPipe:Send), Err(e) => Err(uv_error_to_io_error(e)), } } @@ -304,14 +304,14 @@ impl IoFactory for UvIoFactory { fn tty_open(&mut self, fd: c_int, readable: bool) -> Result<~rtio::RtioTTY:Send, IoError> { match TtyWatcher::new(self, fd, readable) { - Ok(tty) => Ok(~tty as ~rtio::RtioTTY:Send), + Ok(tty) => Ok(box tty as ~rtio::RtioTTY:Send), Err(e) => Err(uv_error_to_io_error(e)) } } fn pipe_open(&mut self, fd: c_int) -> Result<~rtio::RtioPipe:Send, IoError> { match PipeWatcher::open(self, fd) { - Ok(s) => Ok(~s as ~rtio::RtioPipe:Send), + Ok(s) => Ok(box s as ~rtio::RtioPipe:Send), Err(e) => Err(uv_error_to_io_error(e)) } } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 25ee03a44c2c3..3d411672bc148 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1772,7 +1772,7 @@ impl> Builder { fn build_object(&mut self) -> Result { self.bump(); - let mut values = ~TreeMap::new(); + let mut values = box TreeMap::new(); while self.token != None { match self.token { @@ -2213,7 +2213,7 @@ impl ToJson for (A, B) { fn to_json(&self) -> Json { match *self { (ref a, ref b) => { - List(~[a.to_json(), b.to_json()]) + List(box [a.to_json(), b.to_json()]) } } } @@ -2223,7 +2223,7 @@ impl ToJson for (A, B, C) { fn to_json(&self) -> Json { match *self { (ref a, ref b, ref c) => { - List(~[a.to_json(), b.to_json(), c.to_json()]) + List(box [a.to_json(), b.to_json(), c.to_json()]) } } } @@ -2239,7 +2239,7 @@ impl ToJson for TreeMap<~str, A> { for (key, value) in self.iter() { d.insert((*key).clone(), value.to_json()); } - Object(~d) + Object(box d) } } @@ -2249,7 +2249,7 @@ impl ToJson for HashMap<~str, A> { for (key, value) in self.iter() { d.insert((*key).clone(), value.to_json()); } - Object(~d) + Object(box d) } } @@ -2305,7 +2305,7 @@ mod tests { } fn mk_object(items: &[(~str, Json)]) -> Json { - let mut d = ~TreeMap::new(); + let mut d = box TreeMap::new(); for item in items.iter() { match *item { @@ -2370,10 +2370,10 @@ mod tests { ]".to_owned() ); - let long_test_list = List(~[ + let long_test_list = List(box [ Boolean(false), Null, - List(~[String("foo\nbar".to_owned()), Number(3.5)])]); + List(box [String("foo\nbar".to_owned()), Number(3.5)])]); assert_eq!(long_test_list.to_str(), "[false,null,[\"foo\\nbar\",3.5]]".to_owned()); @@ -2409,7 +2409,7 @@ mod tests { ); let complex_obj = mk_object([ - ("b".to_owned(), List(~[ + ("b".to_owned(), List(box [ mk_object([("c".to_owned(), String("\x0c\r".to_owned()))]), mk_object([("d".to_owned(), String("".to_owned()))]) ])) @@ -2441,7 +2441,7 @@ mod tests { let a = mk_object([ ("a".to_owned(), Boolean(true)), - ("b".to_owned(), List(~[ + ("b".to_owned(), List(box [ mk_object([("c".to_owned(), String("\x0c\r".to_owned()))]), mk_object([("d".to_owned(), String("".to_owned()))]) ])) @@ -3111,34 +3111,34 @@ mod tests { assert_stream_equal( "{}", - ~[(ObjectStart, ~[]), (ObjectEnd, ~[])] + box [(ObjectStart, box []), (ObjectEnd, box [])] ); assert_stream_equal( "{\"a\": 3}", - ~[ - (ObjectStart, ~[]), - (NumberValue(3.0), ~[Key("a")]), - (ObjectEnd, ~[]), + box [ + (ObjectStart, box []), + (NumberValue(3.0), box [Key("a")]), + (ObjectEnd, box []), ] ); assert_stream_equal( "{ \"a\": null, \"b\" : true }", - ~[ - (ObjectStart, ~[]), - (NullValue, ~[Key("a")]), - (BooleanValue(true), ~[Key("b")]), - (ObjectEnd, ~[]), + box [ + (ObjectStart, box []), + (NullValue, box [Key("a")]), + (BooleanValue(true), box [Key("b")]), + (ObjectEnd, box []), ] ); assert_stream_equal( "{\"a\" : 1.0 ,\"b\": [ true ]}", - ~[ - (ObjectStart, ~[]), - (NumberValue(1.0), ~[Key("a")]), - (ListStart, ~[Key("b")]), - (BooleanValue(true),~[Key("b"), Index(0)]), - (ListEnd, ~[Key("b")]), - (ObjectEnd, ~[]), + box [ + (ObjectStart, box []), + (NumberValue(1.0), box [Key("a")]), + (ListStart, box [Key("b")]), + (BooleanValue(true),box [Key("b"), Index(0)]), + (ListEnd, box [Key("b")]), + (ObjectEnd, box []), ] ); assert_stream_equal( @@ -3170,70 +3170,70 @@ mod tests { fn test_read_list_streaming() { assert_stream_equal( "[]", - ~[ - (ListStart, ~[]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (ListEnd, box []), ] ); assert_stream_equal( "[ ]", - ~[ - (ListStart, ~[]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (ListEnd, box []), ] ); assert_stream_equal( "[true]", - ~[ - (ListStart, ~[]), - (BooleanValue(true), ~[Index(0)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (BooleanValue(true), box [Index(0)]), + (ListEnd, box []), ] ); assert_stream_equal( "[ false ]", - ~[ - (ListStart, ~[]), - (BooleanValue(false), ~[Index(0)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (BooleanValue(false), box [Index(0)]), + (ListEnd, box []), ] ); assert_stream_equal( "[null]", - ~[ - (ListStart, ~[]), - (NullValue, ~[Index(0)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NullValue, box [Index(0)]), + (ListEnd, box []), ] ); assert_stream_equal( "[3, 1]", - ~[ - (ListStart, ~[]), - (NumberValue(3.0), ~[Index(0)]), - (NumberValue(1.0), ~[Index(1)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NumberValue(3.0), box [Index(0)]), + (NumberValue(1.0), box [Index(1)]), + (ListEnd, box []), ] ); assert_stream_equal( "\n[3, 2]\n", - ~[ - (ListStart, ~[]), - (NumberValue(3.0), ~[Index(0)]), - (NumberValue(2.0), ~[Index(1)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NumberValue(3.0), box [Index(0)]), + (NumberValue(2.0), box [Index(1)]), + (ListEnd, box []), ] ); assert_stream_equal( "[2, [4, 1]]", - ~[ - (ListStart, ~[]), - (NumberValue(2.0), ~[Index(0)]), - (ListStart, ~[Index(1)]), - (NumberValue(4.0), ~[Index(1), Index(0)]), - (NumberValue(1.0), ~[Index(1), Index(1)]), - (ListEnd, ~[Index(1)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NumberValue(2.0), box [Index(0)]), + (ListStart, box [Index(1)]), + (NumberValue(4.0), box [Index(1), Index(0)]), + (NumberValue(1.0), box [Index(1), Index(1)]), + (ListEnd, box [Index(1)]), + (ListEnd, box []), ] ); diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 9801a243efa52..65f1016515fbe 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -399,7 +399,7 @@ impl,T:Encodable> Encodable for ~T { impl,T:Decodable> Decodable for ~T { fn decode(d: &mut D) -> Result<~T, E> { - Ok(~try!(Decodable::decode(d))) + Ok(box try!(Decodable::decode(d))) } } diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 5a6ecdb1f21a7..e448b7b8e2422 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -190,7 +190,7 @@ mod tests { #[test] fn any_owning() { - let (a, b, c) = (~5u as ~Any, ~TEST as ~Any, ~Test as ~Any); + let (a, b, c) = (box 5u as ~Any, box TEST as ~Any, box Test as ~Any); assert!(a.is::()); assert!(!b.is::()); @@ -223,7 +223,7 @@ mod tests { #[test] fn any_as_mut() { let mut a = 5u; - let mut b = ~7u; + let mut b = box 7u; let a_r = &mut a as &mut Any; let tmp: &mut uint = b; @@ -268,20 +268,20 @@ mod tests { #[test] fn any_move() { - let a = ~8u as ~Any; - let b = ~Test as ~Any; + let a = box 8u as ~Any; + let b = box Test as ~Any; match a.move::() { - Ok(a) => { assert_eq!(a, ~8u); } + Ok(a) => { assert_eq!(a, box 8u); } Err(..) => fail!() } match b.move::() { - Ok(a) => { assert_eq!(a, ~Test); } + Ok(a) => { assert_eq!(a, box Test); } Err(..) => fail!() } - let a = ~8u as ~Any; - let b = ~Test as ~Any; + let a = box 8u as ~Any; + let b = box Test as ~Any; assert!(a.move::<~Test>().is_err()); assert!(b.move::<~uint>().is_err()); @@ -289,8 +289,8 @@ mod tests { #[test] fn test_show() { - let a = ~8u as ~Any; - let b = ~Test as ~Any; + let a = box 8u as ~Any; + let b = box Test as ~Any; assert_eq!(format!("{}", a), "~Any".to_owned()); assert_eq!(format!("{}", b), "~Any".to_owned()); diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 6ffe0cfe57d56..5b4400593b483 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -492,7 +492,7 @@ mod tests { macro_rules! v2ascii ( ( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); (&[$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); - (~[$($e:expr),*]) => (~[$(Ascii{chr:$e}),*]); + (~[$($e:expr),*]) => (box [$(Ascii{chr:$e}),*]); ) macro_rules! vec2ascii ( @@ -536,7 +536,7 @@ mod tests { assert_eq!("( ;".to_ascii(), v2ascii!([40, 32, 59])); // FIXME: #5475 borrowchk error, owned vectors do not live long enough // if chained-from directly - let v = ~[40u8, 32u8, 59u8]; assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); + let v = box [40u8, 32u8, 59u8]; assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); let v = "( ;".to_owned(); assert_eq!(v.to_ascii(), v2ascii!([40, 32, 59])); assert_eq!("abCDef&?#".to_ascii().to_lower().into_str(), "abcdef&?#".to_owned()); @@ -569,7 +569,7 @@ mod tests { #[test] fn test_owned_ascii_vec() { assert_eq!(("( ;".to_owned()).into_ascii(), v2ascii!(~[40, 32, 59])); - assert_eq!((~[40u8, 32u8, 59u8]).into_ascii(), v2ascii!(~[40, 32, 59])); + assert_eq!((box [40u8, 32u8, 59u8]).into_ascii(), v2ascii!(~[40, 32, 59])); } #[test] @@ -586,7 +586,7 @@ mod tests { #[test] fn test_ascii_to_bytes() { - assert_eq!(v2ascii!(~[40, 32, 59]).into_bytes(), ~[40u8, 32u8, 59u8]); + assert_eq!(v2ascii!(~[40, 32, 59]).into_bytes(), box [40u8, 32u8, 59u8]); } #[test] #[should_fail] @@ -625,8 +625,8 @@ mod tests { assert_eq!(v.to_ascii_opt(), Some(v2)); assert_eq!("zoä华".to_ascii_opt(), None); - assert_eq!((~[40u8, 32u8, 59u8]).into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); - assert_eq!((~[127u8, 128u8, 255u8]).into_ascii_opt(), None); + assert_eq!((box [40u8, 32u8, 59u8]).into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); + assert_eq!((box [127u8, 128u8, 255u8]).into_ascii_opt(), None); assert_eq!(("( ;".to_owned()).into_ascii_opt(), Some(v2ascii!(~[40, 32, 59]))); assert_eq!(("zoä华".to_owned()).into_ascii_opt(), None); diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index eb7eb8d1df92e..bcbf804d7b308 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -142,7 +142,7 @@ mod tests { #[test] fn test_transmute2() { unsafe { - assert_eq!(~[76u8], transmute("L".to_owned())); + assert_eq!(box [76u8], transmute("L".to_owned())); } } } diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index cf5a9c6711c62..e25f9c5ad4f7a 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -42,7 +42,7 @@ pub trait Clone { impl Clone for ~T { /// Return a copy of the owned box. #[inline] - fn clone(&self) -> ~T { ~(**self).clone() } + fn clone(&self) -> ~T { box {(**self).clone()} } /// Perform copy-assignment from `source` by reusing the existing allocation. #[inline] @@ -126,7 +126,7 @@ extern_fn_clone!(A, B, C, D, E, F, G, H) #[test] fn test_owned_clone() { - let a = ~5i; + let a = box 5i; let b: ~int = a.clone(); assert_eq!(a, b); } @@ -148,8 +148,8 @@ fn test_borrowed_clone() { #[test] fn test_clone_from() { - let a = ~5; - let mut b = ~10; + let a = box 5; + let mut b = box 10; b.clone_from(&a); assert_eq!(*b, 5); } diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index ce1c09af07cad..92e3e82c1c5a1 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -976,14 +976,14 @@ mod test { test!(fn drop_full() { let (tx, _rx) = channel(); - tx.send(~1); + tx.send(box 1); }) test!(fn drop_full_shared() { let (tx, _rx) = channel(); drop(tx.clone()); drop(tx.clone()); - tx.send(~1); + tx.send(box 1); }) test!(fn smoke_shared() { @@ -1179,7 +1179,7 @@ mod test { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = channel::<~int>(); drop(rx); - tx.send(~0); + tx.send(box 0); } #[should_fail]) test!(fn oneshot_single_thread_recv_chan_close() { @@ -1195,8 +1195,8 @@ mod test { test!(fn oneshot_single_thread_send_then_recv() { let (tx, rx) = channel::<~int>(); - tx.send(~10); - assert!(rx.recv() == ~10); + tx.send(box 10); + assert!(rx.recv() == box 10); }) test!(fn oneshot_single_thread_try_send_open() { @@ -1245,10 +1245,10 @@ mod test { test!(fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::<~int>(); spawn(proc() { - assert!(rx.recv() == ~10); + assert!(rx.recv() == box 10); }); - tx.send(~10); + tx.send(box 10); }) test!(fn oneshot_multi_task_recv_then_close() { @@ -1257,7 +1257,7 @@ mod test { drop(tx); }); let res = task::try(proc() { - assert!(rx.recv() == ~10); + assert!(rx.recv() == box 10); }); assert!(res.is_err()); }) @@ -1305,10 +1305,10 @@ mod test { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); spawn(proc() { - tx.send(~10); + tx.send(box 10); }); spawn(proc() { - assert!(rx.recv() == ~10); + assert!(rx.recv() == box 10); }); } }) @@ -1324,7 +1324,7 @@ mod test { if i == 10 { return } spawn(proc() { - tx.send(~i); + tx.send(box i); send(tx, i + 1); }); } @@ -1333,7 +1333,7 @@ mod test { if i == 10 { return } spawn(proc() { - assert!(rx.recv() == ~i); + assert!(rx.recv() == box i); recv(rx, i + 1); }); } @@ -1509,7 +1509,7 @@ mod sync_tests { test!(fn drop_full() { let (tx, _rx) = sync_channel(1); - tx.send(~1); + tx.send(box 1); }) test!(fn smoke_shared() { @@ -1639,7 +1639,7 @@ mod sync_tests { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = sync_channel::<~int>(0); drop(rx); - tx.send(~0); + tx.send(box 0); } #[should_fail]) test!(fn oneshot_single_thread_recv_chan_close() { @@ -1655,8 +1655,8 @@ mod sync_tests { test!(fn oneshot_single_thread_send_then_recv() { let (tx, rx) = sync_channel::<~int>(1); - tx.send(~10); - assert!(rx.recv() == ~10); + tx.send(box 10); + assert!(rx.recv() == box 10); }) test!(fn oneshot_single_thread_try_send_open() { @@ -1710,10 +1710,10 @@ mod sync_tests { test!(fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::<~int>(0); spawn(proc() { - assert!(rx.recv() == ~10); + assert!(rx.recv() == box 10); }); - tx.send(~10); + tx.send(box 10); }) test!(fn oneshot_multi_task_recv_then_close() { @@ -1722,7 +1722,7 @@ mod sync_tests { drop(tx); }); let res = task::try(proc() { - assert!(rx.recv() == ~10); + assert!(rx.recv() == box 10); }); assert!(res.is_err()); }) @@ -1770,10 +1770,10 @@ mod sync_tests { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel(0); spawn(proc() { - tx.send(~10); + tx.send(box 10); }); spawn(proc() { - assert!(rx.recv() == ~10); + assert!(rx.recv() == box 10); }); } }) @@ -1789,7 +1789,7 @@ mod sync_tests { if i == 10 { return } spawn(proc() { - tx.send(~i); + tx.send(box i); send(tx, i + 1); }); } @@ -1798,7 +1798,7 @@ mod sync_tests { if i == 10 { return } spawn(proc() { - assert!(rx.recv() == ~i); + assert!(rx.recv() == box i); recv(rx, i + 1); }); } diff --git a/src/libstd/default.rs b/src/libstd/default.rs index 60f38e3b3defa..8dcce3fd146ee 100644 --- a/src/libstd/default.rs +++ b/src/libstd/default.rs @@ -21,5 +21,5 @@ impl Default for @T { } impl Default for ~T { - fn default() -> ~T { ~Default::default() } + fn default() -> ~T { box Default::default() } } diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 36ffb8572378f..0ba8cff742b41 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -499,7 +499,7 @@ impl<'a> Parser<'a> { vec!() } }; - ~Select(arms, other) + box Select(arms, other) } /// Parses a 'plural' statement (after the initial 'plural' word) @@ -597,7 +597,7 @@ impl<'a> Parser<'a> { vec!() } }; - ~Plural(offset, arms, other) + box Plural(offset, arms, other) } /// Parses a Count parameter at the current position. This does not check @@ -912,25 +912,25 @@ mod tests { same("{, select, other { haha } }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Select(vec![], vec![String(" haha ")])) + method: Some(box Select(vec![], vec![String(" haha ")])) })]); same("{1, select, other { haha } }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(vec![], vec![String(" haha ")])) + method: Some(box Select(vec![], vec![String(" haha ")])) })]); same("{1, select, other {#} }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(vec![], vec![CurrentArgument])) + method: Some(box Select(vec![], vec![CurrentArgument])) })]); same("{1, select, other {{2, select, other {lol}}} }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(vec![], vec![Argument(Argument{ + method: Some(box Select(vec![], vec![Argument(Argument{ position: ArgumentIs(2), format: fmtdflt(), - method: Some(~Select(vec![], vec![String("lol")])) + method: Some(box Select(vec![], vec![String("lol")])) })])) // wat })]); } @@ -940,7 +940,7 @@ mod tests { same("{1, select, a{1} b{2} c{3} other{4} }", [Argument(Argument{ position: ArgumentIs(1), format: fmtdflt(), - method: Some(~Select(vec![ + method: Some(box Select(vec![ SelectArm{ selector: "a", result: vec![String("1")] }, SelectArm{ selector: "b", result: vec![String("2")] }, SelectArm{ selector: "c", result: vec![String("3")] }, @@ -964,18 +964,18 @@ mod tests { same("{, plural, other { haha } }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Plural(None, vec![], vec![String(" haha ")])) + method: Some(box Plural(None, vec![], vec![String(" haha ")])) })]); same("{:, plural, other { haha } }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Plural(None, vec![], vec![String(" haha ")])) + method: Some(box Plural(None, vec![], vec![String(" haha ")])) })]); same("{, plural, offset:1 =2{2} =3{3} many{yes} other{haha} }", [Argument(Argument{ position: ArgumentNext, format: fmtdflt(), - method: Some(~Plural(Some(1), vec![ + method: Some(box Plural(Some(1), vec![ PluralArm{ selector: Literal(2), result: vec![String("2")] }, PluralArm{ selector: Literal(3), result: vec![String("3")] }, PluralArm{ selector: Keyword(Many), result: vec![String("yes")] } diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs index bd383218ba134..7387eff3dfc90 100644 --- a/src/libstd/gc.rs +++ b/src/libstd/gc.rs @@ -117,7 +117,7 @@ mod tests { #[test] fn test_destructor() { - let x = Gc::new(~5); + let x = Gc::new(box 5); assert_eq!(**x.borrow(), 5); } } diff --git a/src/libstd/hash/sip.rs b/src/libstd/hash/sip.rs index eae1373580951..3c1d5897e38e1 100644 --- a/src/libstd/hash/sip.rs +++ b/src/libstd/hash/sip.rs @@ -467,7 +467,7 @@ mod tests { } fn result_bytes(h: u64) -> ~[u8] { - ~[(h >> 0) as u8, + box [(h >> 0) as u8, (h >> 8) as u8, (h >> 16) as u8, (h >> 24) as u8, diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index bb45e519e5e71..45f783698cd3b 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -139,40 +139,40 @@ mod test { fn test_rx_reader() { let (tx, rx) = channel(); task::spawn(proc() { - tx.send(~[1u8, 2u8]); - tx.send(~[]); - tx.send(~[3u8, 4u8]); - tx.send(~[5u8, 6u8]); - tx.send(~[7u8, 8u8]); + tx.send(box [1u8, 2u8]); + tx.send(box []); + tx.send(box [3u8, 4u8]); + tx.send(box [5u8, 6u8]); + tx.send(box [7u8, 8u8]); }); let mut reader = ChanReader::new(rx); - let mut buf = ~[0u8, ..3]; + let mut buf = box [0u8, ..3]; assert_eq!(Ok(0), reader.read([])); assert_eq!(Ok(3), reader.read(buf)); - assert_eq!(~[1,2,3], buf); + assert_eq!(box [1,2,3], buf); assert_eq!(Ok(3), reader.read(buf)); - assert_eq!(~[4,5,6], buf); + assert_eq!(box [4,5,6], buf); assert_eq!(Ok(2), reader.read(buf)); - assert_eq!(~[7,8,6], buf); + assert_eq!(box [7,8,6], buf); match reader.read(buf) { Ok(..) => fail!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } - assert_eq!(~[7,8,6], buf); + assert_eq!(box [7,8,6], buf); // Ensure it continues to fail in the same way. match reader.read(buf) { Ok(..) => fail!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } - assert_eq!(~[7,8,6], buf); + assert_eq!(box [7,8,6], buf); } #[test] @@ -181,7 +181,7 @@ mod test { let mut writer = ChanWriter::new(tx); writer.write_be_u32(42).unwrap(); - let wanted = ~[0u8, 0u8, 0u8, 42u8]; + let wanted = box [0u8, 0u8, 0u8, 42u8]; let got = task::try(proc() { rx.recv() }).unwrap(); assert_eq!(wanted, got); diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 955d4c07d28b8..c2e8fbeeb784e 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -447,7 +447,7 @@ mod test { #[test] fn test_read_f32() { //big-endian floating-point 8.1250 - let buf = ~[0x41, 0x02, 0x00, 0x00]; + let buf = box [0x41, 0x02, 0x00, 0x00]; let mut writer = MemWriter::new(); writer.write(buf).unwrap(); diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 2f64592ec7a31..9abe1bee9a32d 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -450,7 +450,7 @@ mod test { #[test] fn test_buf_reader() { - let in_buf = ~[0, 1, 2, 3, 4, 5, 6, 7]; + let in_buf = box [0, 1, 2, 3, 4, 5, 6, 7]; let mut reader = BufReader::new(in_buf); let mut buf = []; assert_eq!(reader.read(buf), Ok(0)); diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 86d8be4940106..184069bab33d3 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -243,7 +243,7 @@ mod test { spawn(proc() { match UdpSocket::bind(client_ip) { Ok(client) => { - let client = ~client; + let client = box client; let mut stream = client.connect(server_ip); rx1.recv(); stream.write([99]).unwrap(); @@ -255,7 +255,7 @@ mod test { match UdpSocket::bind(server_ip) { Ok(server) => { - let server = ~server; + let server = box server; let mut stream = server.connect(client_ip); tx1.send(()); let mut buf = [0]; @@ -281,7 +281,7 @@ mod test { spawn(proc() { match UdpSocket::bind(client_ip) { Ok(client) => { - let client = ~client; + let client = box client; let mut stream = client.connect(server_ip); rx1.recv(); stream.write([99]).unwrap(); @@ -293,7 +293,7 @@ mod test { match UdpSocket::bind(server_ip) { Ok(server) => { - let server = ~server; + let server = box server; let mut stream = server.connect(client_ip); tx1.send(()); let mut buf = [0]; diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index b507f61bb45d0..b89e3ec3c77bc 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -417,7 +417,7 @@ impl Drop for Process { drop(self.stdin.take()); drop(self.stdout.take()); drop(self.stderr.take()); - drop(mem::replace(&mut self.extra_io, ~[])); + drop(mem::replace(&mut self.extra_io, box [])); self.wait(); } @@ -804,7 +804,7 @@ mod tests { }) iotest!(fn test_add_to_env() { - let new_env = ~[("RUN_TEST_NEW_ENV".to_owned(), "123".to_owned())]; + let new_env = box [("RUN_TEST_NEW_ENV".to_owned(), "123".to_owned())]; let mut prog = run_env(Some(new_env)); let result = prog.wait_with_output(); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index afef21e7c688f..7cb58e1ea486c 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -216,7 +216,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()> ) { Local::put(task); if my_stdout.is_none() { - my_stdout = Some(~stdout() as ~Writer:Send); + my_stdout = Some(box stdout() as ~Writer:Send); } let ret = f(*my_stdout.get_mut_ref()); @@ -396,7 +396,7 @@ mod tests { let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); spawn(proc() { - set_stdout(~w); + set_stdout(box w); println!("hello!"); }); assert_eq!(r.read_to_str().unwrap(), "hello!\n".to_owned()); @@ -408,7 +408,7 @@ mod tests { let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); spawn(proc() { - set_stderr(~w); + set_stderr(box w); fail!("my special message"); }); let s = r.read_to_str().unwrap(); diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index cbe157633b20f..5cae79d371fdf 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -235,7 +235,7 @@ mod test { #[test] fn test_null_writer() { let mut s = NullWriter; - let buf = ~[0, 0, 0]; + let buf = box [0, 0, 0]; s.write(buf).unwrap(); s.flush().unwrap(); } @@ -243,15 +243,15 @@ mod test { #[test] fn test_zero_reader() { let mut s = ZeroReader; - let mut buf = ~[1, 2, 3]; + let mut buf = box [1, 2, 3]; assert_eq!(s.read(buf), Ok(3)); - assert_eq!(~[0, 0, 0], buf); + assert_eq!(box [0, 0, 0], buf); } #[test] fn test_null_reader() { let mut r = NullReader; - let mut buf = ~[0]; + let mut buf = box [0]; assert!(r.read(buf).is_err()); } @@ -273,8 +273,8 @@ mod test { } } - let mut multi = MultiWriter::new(vec!(~TestWriter as ~Writer, - ~TestWriter as ~Writer)); + let mut multi = MultiWriter::new(vec!(box TestWriter as ~Writer, + box TestWriter as ~Writer)); multi.write([1, 2, 3]).unwrap(); assert_eq!(2, unsafe { writes }); assert_eq!(0, unsafe { flushes }); diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 18532c3944364..daeba2365e6ec 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -2340,7 +2340,7 @@ mod tests { fn test_counter_from_iter() { let it = count(0, 5).take(10); let xs: ~[int] = FromIterator::from_iter(it); - assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]); + assert_eq!(xs, box [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]); } #[test] @@ -2370,7 +2370,7 @@ mod tests { fn test_filter_map() { let mut it = count(0u, 1u).take(10) .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None }); - assert_eq!(it.collect::<~[uint]>(), ~[0*0, 2*2, 4*4, 6*6, 8*8]); + assert_eq!(it.collect::<~[uint]>(), box [0*0, 2*2, 4*4, 6*6, 8*8]); } #[test] @@ -2384,7 +2384,7 @@ mod tests { #[test] fn test_iterator_peekable() { - let xs = ~[0u, 1, 2, 3, 4, 5]; + let xs = box [0u, 1, 2, 3, 4, 5]; let mut it = xs.iter().map(|&x|x).peekable(); assert_eq!(it.peek().unwrap(), &0); assert_eq!(it.next().unwrap(), 0); @@ -2627,14 +2627,14 @@ mod tests { #[test] fn test_collect() { - let a = ~[1, 2, 3, 4, 5]; + let a = box [1, 2, 3, 4, 5]; let b: ~[int] = a.iter().map(|&x| x).collect(); assert_eq!(a, b); } #[test] fn test_all() { - let v: ~&[int] = ~&[1, 2, 3, 4, 5]; + let v: ~&[int] = box &[1, 2, 3, 4, 5]; assert!(v.iter().all(|&x| x < 10)); assert!(!v.iter().all(|&x| x % 2 == 0)); assert!(!v.iter().all(|&x| x > 100)); @@ -2643,7 +2643,7 @@ mod tests { #[test] fn test_any() { - let v: ~&[int] = ~&[1, 2, 3, 4, 5]; + let v: ~&[int] = box &[1, 2, 3, 4, 5]; assert!(v.iter().any(|&x| x < 10)); assert!(v.iter().any(|&x| x % 2 == 0)); assert!(!v.iter().any(|&x| x > 100)); @@ -2701,7 +2701,7 @@ mod tests { let mut it = xs.iter(); it.next(); it.next(); - assert_eq!(it.rev().map(|&x| x).collect::<~[int]>(), ~[16, 14, 12, 10, 8, 6]); + assert_eq!(it.rev().map(|&x| x).collect::<~[int]>(), box [16, 14, 12, 10, 8, 6]); } #[test] @@ -2767,7 +2767,7 @@ mod tests { #[test] fn test_double_ended_chain() { let xs = [1, 2, 3, 4, 5]; - let ys = ~[7, 9, 11]; + let ys = box [7, 9, 11]; let mut it = xs.iter().chain(ys.iter()).rev(); assert_eq!(it.next().unwrap(), &11) assert_eq!(it.next().unwrap(), &9) @@ -2784,7 +2784,7 @@ mod tests { fn test_rposition() { fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' } fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } - let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; + let v = box [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; assert_eq!(v.iter().rposition(f), Some(3u)); assert!(v.iter().rposition(g).is_none()); @@ -2793,7 +2793,7 @@ mod tests { #[test] #[should_fail] fn test_rposition_fail() { - let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; + let v = [(box 0, @0), (box 0, @0), (box 0, @0), (box 0, @0)]; let mut i = 0; v.iter().rposition(|_elt| { if i == 2 { @@ -2845,7 +2845,7 @@ mod tests { #[test] fn test_random_access_chain() { let xs = [1, 2, 3, 4, 5]; - let ys = ~[7, 9, 11]; + let ys = box [7, 9, 11]; let mut it = xs.iter().chain(ys.iter()); assert_eq!(it.idx(0).unwrap(), &1); assert_eq!(it.idx(5).unwrap(), &7); @@ -2939,12 +2939,12 @@ mod tests { #[test] fn test_double_ended_range() { - assert_eq!(range(11i, 14).rev().collect::<~[int]>(), ~[13i, 12, 11]); + assert_eq!(range(11i, 14).rev().collect::<~[int]>(), box [13i, 12, 11]); for _ in range(10i, 0).rev() { fail!("unreachable"); } - assert_eq!(range(11u, 14).rev().collect::<~[uint]>(), ~[13u, 12, 11]); + assert_eq!(range(11u, 14).rev().collect::<~[uint]>(), box [13u, 12, 11]); for _ in range(10u, 0).rev() { fail!("unreachable"); } @@ -2996,13 +2996,13 @@ mod tests { } } - assert_eq!(range(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4]); - assert_eq!(range(-10i, -1).collect::<~[int]>(), ~[-10, -9, -8, -7, -6, -5, -4, -3, -2]); - assert_eq!(range(0i, 5).rev().collect::<~[int]>(), ~[4, 3, 2, 1, 0]); - assert_eq!(range(200, -5).collect::<~[int]>(), ~[]); - assert_eq!(range(200, -5).rev().collect::<~[int]>(), ~[]); - assert_eq!(range(200, 200).collect::<~[int]>(), ~[]); - assert_eq!(range(200, 200).rev().collect::<~[int]>(), ~[]); + assert_eq!(range(0i, 5).collect::<~[int]>(), box [0i, 1, 2, 3, 4]); + assert_eq!(range(-10i, -1).collect::<~[int]>(), box [-10, -9, -8, -7, -6, -5, -4, -3, -2]); + assert_eq!(range(0i, 5).rev().collect::<~[int]>(), box [4, 3, 2, 1, 0]); + assert_eq!(range(200, -5).collect::<~[int]>(), box []); + assert_eq!(range(200, -5).rev().collect::<~[int]>(), box []); + assert_eq!(range(200, 200).collect::<~[int]>(), box []); + assert_eq!(range(200, 200).rev().collect::<~[int]>(), box []); assert_eq!(range(0i, 100).size_hint(), (100, Some(100))); // this test is only meaningful when sizeof uint < sizeof u64 @@ -3013,32 +3013,32 @@ mod tests { #[test] fn test_range_inclusive() { - assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4, 5]); - assert_eq!(range_inclusive(0i, 5).rev().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]); - assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), ~[]); - assert_eq!(range_inclusive(200, -5).rev().collect::<~[int]>(), ~[]); - assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), ~[200]); - assert_eq!(range_inclusive(200, 200).rev().collect::<~[int]>(), ~[200]); + assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), box [0i, 1, 2, 3, 4, 5]); + assert_eq!(range_inclusive(0i, 5).rev().collect::<~[int]>(), box [5i, 4, 3, 2, 1, 0]); + assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), box []); + assert_eq!(range_inclusive(200, -5).rev().collect::<~[int]>(), box []); + assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), box [200]); + assert_eq!(range_inclusive(200, 200).rev().collect::<~[int]>(), box [200]); } #[test] fn test_range_step() { - assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15]); - assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]); - assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]); - assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]); - assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), ~[]); - assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), ~[]); + assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), box [0, 5, 10, 15]); + assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), box [20, 15, 10, 5]); + assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), box [20, 14, 8, 2]); + assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), box [200u8, 250]); + assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), box []); + assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), box []); } #[test] fn test_range_step_inclusive() { - assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15, 20]); - assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]); - assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]); - assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]); - assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), ~[]); - assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), ~[200]); + assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), box [0, 5, 10, 15, 20]); + assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), box [20, 15, 10, 5, 0]); + assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), box [20, 14, 8, 2]); + assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), box [200u8, 250]); + assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), box []); + assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), box [200]); } #[test] diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index a6199aa43ab4d..bc6e324a5f7b0 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -302,7 +302,7 @@ pub fn set(key: Key, data: T) { // everything to a trait (LocalData) which is then stored inside the map. // Upon destruction of the map, all the objects will be destroyed and the // traits have enough information about them to destroy themselves. - let data = ~data as ~LocalData:; + let data = box data as ~LocalData:; fn insertion_position(map: &mut Map, key: *u8) -> Option { @@ -486,7 +486,7 @@ mod tests { #[test] fn test_owned() { static key: Key<~int> = &Key; - set(key, ~1); + set(key, box 1); get(key, |v| { get(key, |v| { @@ -497,7 +497,7 @@ mod tests { }); assert_eq!(**v.unwrap(), 1); }); - set(key, ~2); + set(key, box 2); get(key, |v| { assert_eq!(**v.unwrap(), 2); }) diff --git a/src/libstd/option.rs b/src/libstd/option.rs index efbb1abacfaa9..eabaf4f2f9a14 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -619,7 +619,7 @@ mod tests { #[test] fn test_get_ptr() { unsafe { - let x = ~0; + let x = box 0; let addr_x: *int = ::cast::transmute(&*x); let opt = Some(x); let y = opt.unwrap(); @@ -862,11 +862,11 @@ mod tests { fn test_collect() { let v: Option<~[int]> = collect(range(0, 0) .map(|_| Some(0))); - assert_eq!(v, Some(~[])); + assert_eq!(v, Some(box [])); let v: Option<~[int]> = collect(range(0, 3) .map(|x| Some(x))); - assert_eq!(v, Some(~[0, 1, 2])); + assert_eq!(v, Some(box [0, 1, 2])); let v: Option<~[int]> = collect(range(0, 3) .map(|x| if x > 1 { None } else { Some(x) })); diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 004652d786fd8..071aae974db1e 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -225,7 +225,7 @@ pub fn env_as_bytes() -> ~[(~[u8],~[u8])] { for p in input.iter() { let vs: ~[&[u8]] = p.splitn(1, |b| *b == '=' as u8).collect(); let key = vs[0].to_owned(); - let val = if vs.len() < 2 { ~[] } else { vs[1].to_owned() }; + let val = if vs.len() < 2 { box [] } else { vs[1].to_owned() }; pairs.push((key, val)); } pairs @@ -419,7 +419,7 @@ pub fn self_exe_name() -> Option { unsafe { use libc::funcs::bsd44::*; use libc::consts::os::extra::*; - let mib = ~[CTL_KERN as c_int, + let mib = box [CTL_KERN as c_int, KERN_PROC as c_int, KERN_PROC_PATHNAME as c_int, -1 as c_int]; let mut sz: libc::size_t = 0; diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index ca7680413a02c..b4b5185c2216a 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -544,8 +544,8 @@ pub mod ptr_tests { assert_eq!(p.fst, 50); assert_eq!(p.snd, 60); - let v0 = ~[32000u16, 32001u16, 32002u16]; - let mut v1 = ~[0u16, 0u16, 0u16]; + let v0 = box [32000u16, 32001u16, 32002u16]; + let mut v1 = box [0u16, 0u16, 0u16]; copy_memory(v1.as_mut_ptr().offset(1), v0.as_ptr().offset(1), 1); @@ -579,7 +579,7 @@ pub mod ptr_tests { "hello".with_c_str(|p0| { "there".with_c_str(|p1| { "thing".with_c_str(|p2| { - let v = ~[p0, p1, p2, null()]; + let v = box [p0, p1, p2, null()]; unsafe { assert_eq!(buf_len(v.as_ptr()), 3u); } @@ -627,7 +627,7 @@ pub mod ptr_tests { #[test] fn test_ptr_addition() { unsafe { - let xs = ~[5, ..16]; + let xs = box [5, ..16]; let mut ptr = xs.as_ptr(); let end = ptr.offset(16); @@ -645,14 +645,14 @@ pub mod ptr_tests { m_ptr = m_ptr.offset(1); } - assert_eq!(xs_mut, ~[10, ..16]); + assert_eq!(xs_mut, box [10, ..16]); } } #[test] fn test_ptr_subtraction() { unsafe { - let xs = ~[0,1,2,3,4,5,6,7,8,9]; + let xs = box [0,1,2,3,4,5,6,7,8,9]; let mut idx = 9i8; let ptr = xs.as_ptr(); @@ -670,7 +670,7 @@ pub mod ptr_tests { m_ptr = m_ptr.offset(-1); } - assert_eq!(xs_mut, ~[0,2,4,6,8,10,12,14,16,18]); + assert_eq!(xs_mut, box [0,2,4,6,8,10,12,14,16,18]); } } @@ -680,7 +680,7 @@ pub mod ptr_tests { let one = "oneOne".to_c_str(); let two = "twoTwo".to_c_str(); let three = "threeThree".to_c_str(); - let arr = ~[ + let arr = box [ one.with_ref(|buf| buf), two.with_ref(|buf| buf), three.with_ref(|buf| buf), @@ -713,7 +713,7 @@ pub mod ptr_tests { let one = "oneOne".to_c_str(); let two = "twoTwo".to_c_str(); let three = "threeThree".to_c_str(); - let arr = ~[ + let arr = box [ one.with_ref(|buf| buf), two.with_ref(|buf| buf), three.with_ref(|buf| buf), diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 5673929d5a121..51ab885a85f61 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -58,7 +58,7 @@ impl Rc { // destructor never frees the allocation while the // strong destructor is running, even if the weak // pointer is stored inside the strong one. - ptr: transmute(~RcBox { + ptr: transmute(box RcBox { value: value, strong: Cell::new(1), weak: Cell::new(1) @@ -255,7 +255,7 @@ mod tests { #[test] fn test_destructor() { - let x = Rc::new(~5); + let x = Rc::new(box 5); assert_eq!(**x, 5); } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index fc0137d00b7f9..29d4f9e36d2e0 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -642,7 +642,7 @@ fn test_repr() { exact_test(&("he\u10f3llo".to_owned()), "~\"he\\u10f3llo\""); exact_test(&(@10), "@10"); - exact_test(&(~10), "~10"); + exact_test(&(box 10), "~10"); exact_test(&(&10), "&10"); let mut x = 10; exact_test(&(&mut x), "&mut 10"); @@ -651,7 +651,7 @@ fn test_repr() { exact_test(&(0 as *mut ()), "(0x0 as *mut ())"); exact_test(&(1,), "(1,)"); - exact_test(&(~["hi", "there"]), + exact_test(&(box ["hi", "there"]), "~[\"hi\", \"there\"]"); exact_test(&(&["hi", "there"]), "&[\"hi\", \"there\"]"); @@ -659,7 +659,7 @@ fn test_repr() { "repr::P{a: 10, b: 1.234f64}"); exact_test(&(@P{a:10, b:1.234}), "@repr::P{a: 10, b: 1.234f64}"); - exact_test(&(~P{a:10, b:1.234}), + exact_test(&(box P{a:10, b:1.234}), "~repr::P{a: 10, b: 1.234f64}"); exact_test(&(10u8, "hello".to_owned()), "(10u8, ~\"hello\")"); @@ -681,10 +681,10 @@ fn test_repr() { exact_test(&println, "fn(&str)"); exact_test(&swap::, "fn(&mut int, &mut int)"); exact_test(&is_alphabetic, "fn(char) -> bool"); - exact_test(&(~5 as ~ToStr), "~to_str::ToStr"); + exact_test(&(box 5 as ~ToStr), "~to_str::ToStr"); struct Foo; - exact_test(&(~[Foo, Foo]), "~[repr::test_repr::Foo, repr::test_repr::Foo]"); + exact_test(&(box [Foo, Foo]), "~[repr::test_repr::Foo, repr::test_repr::Foo]"); struct Bar(int, int); exact_test(&(Bar(2, 2)), "repr::test_repr::Bar(2, 2)"); diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 058548eb151a2..922d2cf3d3247 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -685,10 +685,10 @@ mod tests { #[test] fn test_collect() { let v: Result<~[int], ()> = collect(range(0, 0).map(|_| Ok::(0))); - assert_eq!(v, Ok(~[])); + assert_eq!(v, Ok(box [])); let v: Result<~[int], ()> = collect(range(0, 3).map(|x| Ok::(x))); - assert_eq!(v, Ok(~[0, 1, 2])); + assert_eq!(v, Ok(box [0, 1, 2])); let v: Result<~[int], int> = collect(range(0, 3) .map(|x| if x > 1 { Err(x) } else { Ok(x) })); diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 824d9e5ec9255..092efcad83154 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -99,7 +99,7 @@ mod imp { with_lock(|| unsafe { let ptr = get_global_ptr(); rtassert!((*ptr).is_none()); - (*ptr) = Some(~args.clone()); + (*ptr) = Some(box args.clone()); }) } @@ -147,7 +147,7 @@ mod imp { // Preserve the actual global state. let saved_value = take(); - let expected = ~[bytes!("happy").to_owned(), bytes!("today?").to_owned()]; + let expected = box [bytes!("happy").to_owned(), bytes!("today?").to_owned()]; put(expected.clone()); assert!(clone() == Some(expected.clone())); diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs index 67b8b40b47e6e..2c8e159aeb962 100644 --- a/src/libstd/rt/at_exit_imp.rs +++ b/src/libstd/rt/at_exit_imp.rs @@ -36,7 +36,7 @@ pub fn init() { unsafe { rtassert!(!RUNNING); rtassert!(QUEUE.is_null()); - let state: ~Queue = ~Exclusive::new(vec!()); + let state: ~Queue = box Exclusive::new(vec!()); QUEUE = cast::transmute(state); } } diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index b9c0a02d7d228..094bbd13889a0 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -125,14 +125,14 @@ mod bench { #[bench] fn alloc_owned_small(b: &mut Bencher) { b.iter(|| { - ~10 + box 10 }) } #[bench] fn alloc_owned_big(b: &mut Bencher) { b.iter(|| { - ~[10, ..1000] + box [10, ..1000] }) } } diff --git a/src/libstd/rt/local.rs b/src/libstd/rt/local.rs index 3cfa494d38293..828bbc118c10a 100644 --- a/src/libstd/rt/local.rs +++ b/src/libstd/rt/local.rs @@ -59,7 +59,7 @@ mod test { #[test] fn thread_local_task_smoke_test() { run_in_bare_thread(proc() { - let task = ~Task::new(); + let task = box Task::new(); Local::put(task); let task: ~Task = Local::take(); cleanup_task(task); @@ -69,11 +69,11 @@ mod test { #[test] fn thread_local_task_two_instances() { run_in_bare_thread(proc() { - let task = ~Task::new(); + let task = box Task::new(); Local::put(task); let task: ~Task = Local::take(); cleanup_task(task); - let task = ~Task::new(); + let task = box Task::new(); Local::put(task); let task: ~Task = Local::take(); cleanup_task(task); @@ -83,7 +83,7 @@ mod test { #[test] fn borrow_smoke_test() { run_in_bare_thread(proc() { - let task = ~Task::new(); + let task = box Task::new(); Local::put(task); unsafe { @@ -97,7 +97,7 @@ mod test { #[test] fn borrow_with_return() { run_in_bare_thread(proc() { - let task = ~Task::new(); + let task = box Task::new(); Local::put(task); { @@ -112,7 +112,7 @@ mod test { #[test] fn try_take() { run_in_bare_thread(proc() { - let task = ~Task::new(); + let task = box Task::new(); Local::put(task); let t: ~Task = Local::try_take().unwrap(); diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 2dab0e975da3c..ae5786604c7a1 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -353,7 +353,7 @@ impl BlockedTask { blocked_task_ptr } Shared(arc) => { - let blocked_task_ptr: uint = cast::transmute(~arc); + let blocked_task_ptr: uint = cast::transmute(box arc); rtassert!(blocked_task_ptr & 0x1 == 0); blocked_task_ptr | 0x1 } @@ -485,7 +485,7 @@ mod test { #[test] fn block_and_wake() { - let task = ~Task::new(); + let task = box Task::new(); let mut task = BlockedTask::block(task).wake().unwrap(); task.destroyed = true; } diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs index 9f5986e3dc6b2..a836958279b8e 100644 --- a/src/libstd/rt/thread.rs +++ b/src/libstd/rt/thread.rs @@ -80,12 +80,12 @@ impl Thread<()> { // We need the address of the packet to fill in to be stable so when // `main` fills it in it's still valid, so allocate an extra ~ box to do // so. - let packet = ~None; + let packet = box None; let packet2: *mut Option = unsafe { *cast::transmute::<&~Option, **mut Option>(&packet) }; let main = proc() unsafe { *packet2 = Some(main()); }; - let native = unsafe { imp::create(stack, ~main) }; + let native = unsafe { imp::create(stack, box main) }; Thread { native: native, @@ -108,7 +108,7 @@ impl Thread<()> { /// stack size for the new thread. pub fn spawn_stack(stack: uint, main: proc():Send) { unsafe { - let handle = imp::create(stack, ~main); + let handle = imp::create(stack, box main); imp::detach(handle); } } diff --git a/src/libstd/rt/thread_local_storage.rs b/src/libstd/rt/thread_local_storage.rs index 2f567e91b4cdb..fceff80e792aa 100644 --- a/src/libstd/rt/thread_local_storage.rs +++ b/src/libstd/rt/thread_local_storage.rs @@ -96,14 +96,14 @@ fn tls_smoke_test() { use cast::transmute; unsafe { let mut key = 0; - let value = ~20; + let value = box 20; create(&mut key); set(key, transmute(value)); let value: ~int = transmute(get(key)); - assert_eq!(value, ~20); - let value = ~30; + assert_eq!(value, box 20); + let value = box 30; set(key, transmute(value)); let value: ~int = transmute(get(key)); - assert_eq!(value, ~30); + assert_eq!(value, box 30); } } diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 4f84202f8f87e..98623c35b7899 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -141,7 +141,7 @@ impl Unwinder { #[no_mangle] fn rust_fail() -> ! { unsafe { - let exception = ~uw::_Unwind_Exception { + let exception = box uw::_Unwind_Exception { exception_class: rust_exception_class(), exception_cleanup: exception_cleanup, private: [0, ..uw::unwinder_private_data_size], @@ -346,7 +346,7 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file: &'static str, line: uint) -> // required with the current scheme, and (b) we don't handle // failure + OOM properly anyway (see comment in begin_unwind // below). - begin_unwind_inner(~fmt::format(msg), file, line) + begin_unwind_inner(box fmt::format(msg), file, line) } /// This is the entry point of unwinding for fail!() and assert!(). @@ -360,7 +360,7 @@ pub fn begin_unwind(msg: M, file: &'static str, line: uint) -> ! // failing. // see below for why we do the `Any` coercion here. - begin_unwind_inner(~msg, file, line) + begin_unwind_inner(box msg, file, line) } diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs index 64f6b59be24d2..cb8550d248eab 100644 --- a/src/libstd/slice.rs +++ b/src/libstd/slice.rs @@ -2042,7 +2042,7 @@ impl<'a, A> Default for &'a [A] { } impl Default for ~[A] { - fn default() -> ~[A] { ~[] } + fn default() -> ~[A] { box [] } } /// Immutable slice iterator @@ -2361,7 +2361,7 @@ mod tests { fn test_unsafe_ptrs() { unsafe { // Test on-stack copy-from-buf. - let a = ~[1, 2, 3]; + let a = box [1, 2, 3]; let mut ptr = a.as_ptr(); let b = from_buf(ptr, 3u); assert_eq!(b.len(), 3u); @@ -2370,7 +2370,7 @@ mod tests { assert_eq!(b[2], 3); // Test on-heap copy-from-buf. - let c = ~[1, 2, 3, 4, 5]; + let c = box [1, 2, 3, 4, 5]; ptr = c.as_ptr(); let d = from_buf(ptr, 5u); assert_eq!(d.len(), 5u); @@ -2452,91 +2452,91 @@ mod tests { #[test] fn test_get() { - let mut a = ~[11]; + let mut a = box [11]; assert_eq!(a.get(1), None); - a = ~[11, 12]; + a = box [11, 12]; assert_eq!(a.get(1).unwrap(), &12); - a = ~[11, 12, 13]; + a = box [11, 12, 13]; assert_eq!(a.get(1).unwrap(), &12); } #[test] fn test_head() { - let mut a = ~[]; + let mut a = box []; assert_eq!(a.head(), None); - a = ~[11]; + a = box [11]; assert_eq!(a.head().unwrap(), &11); - a = ~[11, 12]; + a = box [11, 12]; assert_eq!(a.head().unwrap(), &11); } #[test] fn test_tail() { - let mut a = ~[11]; + let mut a = box [11]; assert_eq!(a.tail(), &[]); - a = ~[11, 12]; + a = box [11, 12]; assert_eq!(a.tail(), &[12]); } #[test] #[should_fail] fn test_tail_empty() { - let a: ~[int] = ~[]; + let a: ~[int] = box []; a.tail(); } #[test] fn test_tailn() { - let mut a = ~[11, 12, 13]; + let mut a = box [11, 12, 13]; assert_eq!(a.tailn(0), &[11, 12, 13]); - a = ~[11, 12, 13]; + a = box [11, 12, 13]; assert_eq!(a.tailn(2), &[13]); } #[test] #[should_fail] fn test_tailn_empty() { - let a: ~[int] = ~[]; + let a: ~[int] = box []; a.tailn(2); } #[test] fn test_init() { - let mut a = ~[11]; + let mut a = box [11]; assert_eq!(a.init(), &[]); - a = ~[11, 12]; + a = box [11, 12]; assert_eq!(a.init(), &[11]); } #[test] #[should_fail] fn test_init_empty() { - let a: ~[int] = ~[]; + let a: ~[int] = box []; a.init(); } #[test] fn test_initn() { - let mut a = ~[11, 12, 13]; + let mut a = box [11, 12, 13]; assert_eq!(a.initn(0), &[11, 12, 13]); - a = ~[11, 12, 13]; + a = box [11, 12, 13]; assert_eq!(a.initn(2), &[11]); } #[test] #[should_fail] fn test_initn_empty() { - let a: ~[int] = ~[]; + let a: ~[int] = box []; a.initn(2); } #[test] fn test_last() { - let mut a = ~[]; + let mut a = box []; assert_eq!(a.last(), None); - a = ~[11]; + a = box [11]; assert_eq!(a.last().unwrap(), &11); - a = ~[11, 12]; + a = box [11, 12]; assert_eq!(a.last().unwrap(), &12); } @@ -2558,7 +2558,7 @@ mod tests { assert_eq!(v_b[1], 3); // Test on exchange heap. - let vec_unique = ~[1, 2, 3, 4, 5, 6]; + let vec_unique = box [1, 2, 3, 4, 5, 6]; let v_d = vec_unique.slice(1u, 6u).to_owned(); assert_eq!(v_d.len(), 5u); assert_eq!(v_d[0], 2); @@ -2692,7 +2692,7 @@ mod tests { #[test] fn test_truncate() { - let mut v = vec![~6,~5,~4]; + let mut v = vec![box 6,box 5,box 4]; v.truncate(1); let v = v.as_slice(); assert_eq!(v.len(), 1); @@ -2702,7 +2702,7 @@ mod tests { #[test] fn test_clear() { - let mut v = vec![~6,~5,~4]; + let mut v = vec![box 6,box 5,box 4]; v.clear(); assert_eq!(v.len(), 0); // If the unsafe block didn't drop things properly, we blow up here. @@ -2727,11 +2727,11 @@ mod tests { #[test] fn test_dedup_unique() { - let mut v0 = vec![~1, ~1, ~2, ~3]; + let mut v0 = vec![box 1, box 1, box 2, box 3]; v0.dedup(); - let mut v1 = vec![~1, ~2, ~2, ~3]; + let mut v1 = vec![box 1, box 2, box 2, box 3]; v1.dedup(); - let mut v2 = vec![~1, ~2, ~3, ~3]; + let mut v2 = vec![box 1, box 2, box 3, box 3]; v2.dedup(); /* * If the ~pointers were leaked or otherwise misused, valgrind and/or @@ -2741,11 +2741,11 @@ mod tests { #[test] fn test_dedup_shared() { - let mut v0 = vec![~1, ~1, ~2, ~3]; + let mut v0 = vec![box 1, box 1, box 2, box 3]; v0.dedup(); - let mut v1 = vec![~1, ~2, ~2, ~3]; + let mut v1 = vec![box 1, box 2, box 2, box 3]; v1.dedup(); - let mut v2 = vec![~1, ~2, ~3, ~3]; + let mut v2 = vec![box 1, box 2, box 3, box 3]; v2.dedup(); /* * If the pointers were leaked or otherwise misused, valgrind and/or @@ -2814,15 +2814,15 @@ mod tests { let (min_size, max_opt) = it.size_hint(); assert_eq!(min_size, 3*2); assert_eq!(max_opt.unwrap(), 3*2); - assert_eq!(it.next(), Some(~[1,2,3])); - assert_eq!(it.next(), Some(~[1,3,2])); - assert_eq!(it.next(), Some(~[3,1,2])); + assert_eq!(it.next(), Some(box [1,2,3])); + assert_eq!(it.next(), Some(box [1,3,2])); + assert_eq!(it.next(), Some(box [3,1,2])); let (min_size, max_opt) = it.size_hint(); assert_eq!(min_size, 3); assert_eq!(max_opt.unwrap(), 3); - assert_eq!(it.next(), Some(~[3,2,1])); - assert_eq!(it.next(), Some(~[2,3,1])); - assert_eq!(it.next(), Some(~[2,1,3])); + assert_eq!(it.next(), Some(box [3,2,1])); + assert_eq!(it.next(), Some(box [2,3,1])); + assert_eq!(it.next(), Some(box [2,1,3])); assert_eq!(it.next(), None); } { @@ -2845,7 +2845,7 @@ mod tests { fn test_position_elem() { assert!([].position_elem(&1).is_none()); - let v1 = ~[1, 2, 3, 3, 2, 5]; + let v1 = box [1, 2, 3, 3, 2, 5]; assert_eq!(v1.position_elem(&1), Some(0u)); assert_eq!(v1.position_elem(&2), Some(1u)); assert_eq!(v1.position_elem(&5), Some(5u)); @@ -2899,14 +2899,14 @@ mod tests { #[test] fn test_reverse() { - let mut v: ~[int] = ~[10, 20]; + let mut v: ~[int] = box [10, 20]; assert_eq!(v[0], 10); assert_eq!(v[1], 20); v.reverse(); assert_eq!(v[0], 20); assert_eq!(v[1], 10); - let mut v3: ~[int] = ~[]; + let mut v3: ~[int] = box []; v3.reverse(); assert!(v3.is_empty()); } @@ -2973,39 +2973,39 @@ mod tests { #[test] fn test_partition() { - assert_eq!((~[]).partition(|x: &int| *x < 3), (~[], ~[])); - assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 4), (~[1, 2, 3], ~[])); - assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 2), (~[1], ~[2, 3])); - assert_eq!((~[1, 2, 3]).partition(|x: &int| *x < 0), (~[], ~[1, 2, 3])); + assert_eq!((box []).partition(|x: &int| *x < 3), (box [], box [])); + assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 4), (box [1, 2, 3], box [])); + assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 2), (box [1], box [2, 3])); + assert_eq!((box [1, 2, 3]).partition(|x: &int| *x < 0), (box [], box [1, 2, 3])); } #[test] fn test_partitioned() { - assert_eq!(([]).partitioned(|x: &int| *x < 3), (~[], ~[])) - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (~[1, 2, 3], ~[])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (~[1], ~[2, 3])); - assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (~[], ~[1, 2, 3])); + assert_eq!(([]).partitioned(|x: &int| *x < 3), (box [], box [])) + assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 4), (box [1, 2, 3], box [])); + assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 2), (box [1], box [2, 3])); + assert_eq!(([1, 2, 3]).partitioned(|x: &int| *x < 0), (box [], box [1, 2, 3])); } #[test] fn test_concat() { let v: [~[int], ..0] = []; - assert_eq!(v.concat_vec(), ~[]); - assert_eq!([~[1], ~[2,3]].concat_vec(), ~[1, 2, 3]); + assert_eq!(v.concat_vec(), box []); + assert_eq!([box [1], box [2,3]].concat_vec(), box [1, 2, 3]); - assert_eq!([&[1], &[2,3]].concat_vec(), ~[1, 2, 3]); + assert_eq!([&[1], &[2,3]].concat_vec(), box [1, 2, 3]); } #[test] fn test_connect() { let v: [~[int], ..0] = []; - assert_eq!(v.connect_vec(&0), ~[]); - assert_eq!([~[1], ~[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]); - assert_eq!([~[1], ~[2], ~[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]); + assert_eq!(v.connect_vec(&0), box []); + assert_eq!([box [1], box [2, 3]].connect_vec(&0), box [1, 0, 2, 3]); + assert_eq!([box [1], box [2], box [3]].connect_vec(&0), box [1, 0, 2, 0, 3]); - assert_eq!(v.connect_vec(&0), ~[]); - assert_eq!([&[1], &[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]); - assert_eq!([&[1], &[2], &[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]); + assert_eq!(v.connect_vec(&0), box []); + assert_eq!([&[1], &[2, 3]].connect_vec(&0), box [1, 0, 2, 3]); + assert_eq!([&[1], &[2], &[3]].connect_vec(&0), box [1, 0, 2, 0, 3]); } #[test] @@ -3100,7 +3100,7 @@ mod tests { fn test_from_fn_fail() { Vec::from_fn(100, |v| { if v == 50 { fail!() } - ~0 + box 0 }); } @@ -3124,7 +3124,7 @@ mod tests { } } - let s = S { f: 0, boxes: (~0, Rc::new(0)) }; + let s = S { f: 0, boxes: (box 0, Rc::new(0)) }; let _ = Vec::from_elem(100, s); } @@ -3137,7 +3137,7 @@ mod tests { if i == 50 { fail!() } - (~0, Rc::new(0)) + (box 0, Rc::new(0)) }) } @@ -3145,7 +3145,8 @@ mod tests { #[should_fail] fn test_permute_fail() { use rc::Rc; - let v = [(~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0))]; + let v = [(box 0, Rc::new(0)), (box 0, Rc::new(0)), + (box 0, Rc::new(0)), (box 0, Rc::new(0))]; let mut i = 0; for _ in v.permutations() { if i == 2 { @@ -3288,14 +3289,14 @@ mod tests { #[test] fn test_move_iterator() { use iter::*; - let xs = ~[1u,2,3,4,5]; + let xs = box [1u,2,3,4,5]; assert_eq!(xs.move_iter().fold(0, |a: uint, b: uint| 10*a + b), 12345); } #[test] fn test_move_rev_iterator() { use iter::*; - let xs = ~[1u,2,3,4,5]; + let xs = box [1u,2,3,4,5]; assert_eq!(xs.move_iter().rev().fold(0, |a: uint, b: uint| 10*a + b), 54321); } @@ -3304,18 +3305,18 @@ mod tests { let xs = &[1i,2,3,4,5]; assert_eq!(xs.split(|x| *x % 2 == 0).collect::<~[&[int]]>(), - ~[&[1], &[3], &[5]]); + box [&[1], &[3], &[5]]); assert_eq!(xs.split(|x| *x == 1).collect::<~[&[int]]>(), - ~[&[], &[2,3,4,5]]); + box [&[], &[2,3,4,5]]); assert_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), - ~[&[1,2,3,4], &[]]); + box [&[1,2,3,4], &[]]); assert_eq!(xs.split(|x| *x == 10).collect::<~[&[int]]>(), - ~[&[1,2,3,4,5]]); + box [&[1,2,3,4,5]]); assert_eq!(xs.split(|_| true).collect::<~[&[int]]>(), - ~[&[], &[], &[], &[], &[], &[]]); + box [&[], &[], &[], &[], &[], &[]]); let xs: &[int] = &[]; - assert_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + assert_eq!(xs.split(|x| *x == 5).collect::<~[&[int]]>(), box [&[]]); } #[test] @@ -3323,14 +3324,14 @@ mod tests { let xs = &[1i,2,3,4,5]; assert_eq!(xs.splitn(0, |x| *x % 2 == 0).collect::<~[&[int]]>(), - ~[&[1,2,3,4,5]]); + box [&[1,2,3,4,5]]); assert_eq!(xs.splitn(1, |x| *x % 2 == 0).collect::<~[&[int]]>(), - ~[&[1], &[3,4,5]]); + box [&[1], &[3,4,5]]); assert_eq!(xs.splitn(3, |_| true).collect::<~[&[int]]>(), - ~[&[], &[], &[], &[4,5]]); + box [&[], &[], &[], &[4,5]]); let xs: &[int] = &[]; - assert_eq!(xs.splitn(1, |x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + assert_eq!(xs.splitn(1, |x| *x == 5).collect::<~[&[int]]>(), box [&[]]); } #[test] @@ -3338,16 +3339,16 @@ mod tests { let xs = &[1i,2,3,4,5]; assert_eq!(xs.split(|x| *x % 2 == 0).rev().collect::<~[&[int]]>(), - ~[&[5], &[3], &[1]]); + box [&[5], &[3], &[1]]); assert_eq!(xs.split(|x| *x == 1).rev().collect::<~[&[int]]>(), - ~[&[2,3,4,5], &[]]); + box [&[2,3,4,5], &[]]); assert_eq!(xs.split(|x| *x == 5).rev().collect::<~[&[int]]>(), - ~[&[], &[1,2,3,4]]); + box [&[], &[1,2,3,4]]); assert_eq!(xs.split(|x| *x == 10).rev().collect::<~[&[int]]>(), - ~[&[1,2,3,4,5]]); + box [&[1,2,3,4,5]]); let xs: &[int] = &[]; - assert_eq!(xs.split(|x| *x == 5).rev().collect::<~[&[int]]>(), ~[&[]]); + assert_eq!(xs.split(|x| *x == 5).rev().collect::<~[&[int]]>(), box [&[]]); } #[test] @@ -3355,22 +3356,22 @@ mod tests { let xs = &[1,2,3,4,5]; assert_eq!(xs.rsplitn(0, |x| *x % 2 == 0).collect::<~[&[int]]>(), - ~[&[1,2,3,4,5]]); + box [&[1,2,3,4,5]]); assert_eq!(xs.rsplitn(1, |x| *x % 2 == 0).collect::<~[&[int]]>(), - ~[&[5], &[1,2,3]]); + box [&[5], &[1,2,3]]); assert_eq!(xs.rsplitn(3, |_| true).collect::<~[&[int]]>(), - ~[&[], &[], &[], &[1,2]]); + box [&[], &[], &[], &[1,2]]); let xs: &[int] = &[]; - assert_eq!(xs.rsplitn(1, |x| *x == 5).collect::<~[&[int]]>(), ~[&[]]); + assert_eq!(xs.rsplitn(1, |x| *x == 5).collect::<~[&[int]]>(), box [&[]]); } #[test] fn test_windowsator() { let v = &[1i,2,3,4]; - assert_eq!(v.windows(2).collect::<~[&[int]]>(), ~[&[1,2], &[2,3], &[3,4]]); - assert_eq!(v.windows(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[2,3,4]]); + assert_eq!(v.windows(2).collect::<~[&[int]]>(), box [&[1,2], &[2,3], &[3,4]]); + assert_eq!(v.windows(3).collect::<~[&[int]]>(), box [&[1i,2,3], &[2,3,4]]); assert!(v.windows(6).next().is_none()); } @@ -3385,11 +3386,11 @@ mod tests { fn test_chunksator() { let v = &[1i,2,3,4,5]; - assert_eq!(v.chunks(2).collect::<~[&[int]]>(), ~[&[1i,2], &[3,4], &[5]]); - assert_eq!(v.chunks(3).collect::<~[&[int]]>(), ~[&[1i,2,3], &[4,5]]); - assert_eq!(v.chunks(6).collect::<~[&[int]]>(), ~[&[1i,2,3,4,5]]); + assert_eq!(v.chunks(2).collect::<~[&[int]]>(), box [&[1i,2], &[3,4], &[5]]); + assert_eq!(v.chunks(3).collect::<~[&[int]]>(), box [&[1i,2,3], &[4,5]]); + assert_eq!(v.chunks(6).collect::<~[&[int]]>(), box [&[1i,2,3,4,5]]); - assert_eq!(v.chunks(2).rev().collect::<~[&[int]]>(), ~[&[5i], &[3,4], &[1,2]]); + assert_eq!(v.chunks(2).rev().collect::<~[&[int]]>(), box [&[5i], &[3,4], &[1,2]]); let mut it = v.chunks(2); assert_eq!(it.indexable(), 3); assert_eq!(it.idx(0).unwrap(), &[1,2]); @@ -3408,19 +3409,19 @@ mod tests { #[test] fn test_move_from() { let mut a = [1,2,3,4,5]; - let b = ~[6,7,8]; + let b = box [6,7,8]; assert_eq!(a.move_from(b, 0, 3), 3); assert!(a == [6,7,8,4,5]); let mut a = [7,2,8,1]; - let b = ~[3,1,4,1,5,9]; + let b = box [3,1,4,1,5,9]; assert_eq!(a.move_from(b, 0, 6), 4); assert!(a == [3,1,4,1]); let mut a = [1,2,3,4]; - let b = ~[5,6,7,8,9,0]; + let b = box [5,6,7,8,9,0]; assert_eq!(a.move_from(b, 2, 3), 1); assert!(a == [7,2,3,4]); let mut a = [1,2,3,4,5]; - let b = ~[5,6,7,8,9,0]; + let b = box [5,6,7,8,9,0]; assert_eq!(a.mut_slice(2,4).move_from(b,1,6), 2); assert!(a == [1,2,6,7,5]); } @@ -3453,11 +3454,11 @@ mod tests { assert_eq!(format!("{}", x.as_slice()), x_str); }) ) - let empty: ~[int] = ~[]; + let empty: ~[int] = box []; test_show_vec!(empty, "[]".to_owned()); - test_show_vec!(~[1], "[1]".to_owned()); - test_show_vec!(~[1, 2, 3], "[1, 2, 3]".to_owned()); - test_show_vec!(~[~[], ~[1u], ~[1u, 1u]], "[[], [1], [1, 1]]".to_owned()); + test_show_vec!(box [1], "[1]".to_owned()); + test_show_vec!(box [1, 2, 3], "[1, 2, 3]".to_owned()); + test_show_vec!(box [box [], box [1u], box [1u, 1u]], "[[], [1], [1, 1]]".to_owned()); let empty_mut: &mut [int] = &mut[]; test_show_vec!(empty_mut, "[]".to_owned()); @@ -3890,7 +3891,7 @@ mod bench { #[bench] fn zero_1kb_fixed_repeat(b: &mut Bencher) { b.iter(|| { - ~[0u8, ..1024] + box [0u8, ..1024] }); } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index b105dd0ca5a78..430f63263271c 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -137,7 +137,7 @@ impl FromStr for ~str { /// Fails if invalid UTF-8 pub fn from_byte(b: u8) -> ~str { assert!(b < 128u8); - unsafe { ::cast::transmute(~[b]) } + unsafe { ::cast::transmute(box [b]) } } /// Convert a char to a string @@ -1387,7 +1387,7 @@ pub mod raw { } /// Converts a byte to a string. - pub unsafe fn from_byte(u: u8) -> ~str { from_utf8_owned(~[u]) } + pub unsafe fn from_byte(u: u8) -> ~str { from_utf8_owned(box [u]) } /// Form a slice from a C string. Unsafe because the caller must ensure the /// C string has the static lifetime, or else the return value may be @@ -1448,7 +1448,7 @@ pub mod raw { #[test] fn test_from_buf_len() { unsafe { - let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; + let a = box [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = a.as_ptr(); let c = from_buf_len(b, 3u); assert_eq!(c, "AAA".to_owned()); @@ -3342,7 +3342,7 @@ mod tests { #[test] fn test_raw_from_c_str() { unsafe { - let a = ~[65, 65, 65, 65, 65, 65, 65, 0]; + let a = box [65, 65, 65, 65, 65, 65, 65, 0]; let b = a.as_ptr(); let c = raw::from_c_str(b); assert_eq!(c, "AAAAAAA".to_owned()); @@ -3456,13 +3456,13 @@ mod tests { fn test_utf16() { let pairs = [("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n".to_owned(), - ~[0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16, + box [0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16, 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16, 0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf30_u16, 0x000a_u16]), ("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n".to_owned(), - ~[0xd801_u16, 0xdc12_u16, 0xd801_u16, + box [0xd801_u16, 0xdc12_u16, 0xd801_u16, 0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16, 0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4b_u16, 0x0020_u16, 0xd801_u16, 0xdc0f_u16, @@ -3470,7 +3470,7 @@ mod tests { 0x000a_u16]), ("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n".to_owned(), - ~[0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16, + box [0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16, 0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16, 0x00b7_u16, 0xd800_u16, 0xdf0c_u16, 0xd800_u16, @@ -3479,7 +3479,7 @@ mod tests { 0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]), ("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n".to_owned(), - ~[0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16, + box [0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16, 0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16, 0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16, 0x0020_u16, 0xd801_u16, 0xdc95_u16, 0xd801_u16, @@ -3492,7 +3492,7 @@ mod tests { 0x000a_u16 ]), // Issue #12318, even-numbered non-BMP planes ("\U00020000".to_owned(), - ~[0xD840, 0xDC00])]; + box [0xD840, 0xDC00])]; for p in pairs.iter() { let (s, u) = (*p).clone(); @@ -3558,7 +3558,7 @@ mod tests { #[test] fn test_char_at() { let s = "ศไทย中华Việt Nam".to_owned(); - let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; + let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; let mut pos = 0; for ch in v.iter() { assert!(s.char_at(pos) == *ch); @@ -3569,7 +3569,7 @@ mod tests { #[test] fn test_char_at_reverse() { let s = "ศไทย中华Việt Nam".to_owned(); - let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; + let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; let mut pos = s.len(); for ch in v.iter().rev() { assert!(s.char_at_reverse(pos) == *ch); @@ -3652,7 +3652,7 @@ mod tests { fn test_iterator() { use iter::*; let s = "ศไทย中华Việt Nam".to_owned(); - let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; + let v = box ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; let mut pos = 0; let mut it = s.chars(); @@ -3668,7 +3668,7 @@ mod tests { fn test_rev_iterator() { use iter::*; let s = "ศไทย中华Việt Nam".to_owned(); - let v = ~['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ']; + let v = box ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ']; let mut pos = 0; let mut it = s.chars().rev(); @@ -3761,33 +3761,33 @@ mod tests { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let split: ~[&str] = data.split(' ').collect(); - assert_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + assert_eq!( split, box ["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); let mut rsplit: ~[&str] = data.split(' ').rev().collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + assert_eq!(rsplit, box ["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); let split: ~[&str] = data.split(|c: char| c == ' ').collect(); - assert_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + assert_eq!( split, box ["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); let mut rsplit: ~[&str] = data.split(|c: char| c == ' ').rev().collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); + assert_eq!(rsplit, box ["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]); // Unicode let split: ~[&str] = data.split('ä').collect(); - assert_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + assert_eq!( split, box ["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); let mut rsplit: ~[&str] = data.split('ä').rev().collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + assert_eq!(rsplit, box ["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); let split: ~[&str] = data.split(|c: char| c == 'ä').collect(); - assert_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + assert_eq!( split, box ["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); let mut rsplit: ~[&str] = data.split(|c: char| c == 'ä').rev().collect(); rsplit.reverse(); - assert_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); + assert_eq!(rsplit, box ["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]); } #[test] @@ -3795,17 +3795,17 @@ mod tests { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let split: ~[&str] = data.splitn(' ', 3).collect(); - assert_eq!(split, ~["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); + assert_eq!(split, box ["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); let split: ~[&str] = data.splitn(|c: char| c == ' ', 3).collect(); - assert_eq!(split, ~["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); + assert_eq!(split, box ["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]); // Unicode let split: ~[&str] = data.splitn('ä', 3).collect(); - assert_eq!(split, ~["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); + assert_eq!(split, box ["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); let split: ~[&str] = data.splitn(|c: char| c == 'ä', 3).collect(); - assert_eq!(split, ~["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); + assert_eq!(split, box ["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]); } #[test] @@ -3814,20 +3814,20 @@ mod tests { let mut split: ~[&str] = data.rsplitn(' ', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); + assert_eq!(split, box ["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); let mut split: ~[&str] = data.rsplitn(|c: char| c == ' ', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); + assert_eq!(split, box ["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); // Unicode let mut split: ~[&str] = data.rsplitn('ä', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); + assert_eq!(split, box ["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); let mut split: ~[&str] = data.rsplitn(|c: char| c == 'ä', 3).collect(); split.reverse(); - assert_eq!(split, ~["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); + assert_eq!(split, box ["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); } #[test] @@ -3835,10 +3835,10 @@ mod tests { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; let split: ~[&str] = data.split('\n').collect(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb", ""]); + assert_eq!(split, box ["", "Märy häd ä little lämb", "Little lämb", ""]); let split: ~[&str] = data.split_terminator('\n').collect(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb"]); + assert_eq!(split, box ["", "Märy häd ä little lämb", "Little lämb"]); } #[test] @@ -3847,18 +3847,18 @@ mod tests { let mut split: ~[&str] = data.split('\n').rev().collect(); split.reverse(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb", ""]); + assert_eq!(split, box ["", "Märy häd ä little lämb", "Little lämb", ""]); let mut split: ~[&str] = data.split_terminator('\n').rev().collect(); split.reverse(); - assert_eq!(split, ~["", "Märy häd ä little lämb", "Little lämb"]); + assert_eq!(split, box ["", "Märy häd ä little lämb", "Little lämb"]); } #[test] fn test_words() { let data = "\n \tMäry häd\tä little lämb\nLittle lämb\n"; let words: ~[&str] = data.words().collect(); - assert_eq!(words, ~["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"]) + assert_eq!(words, box ["Märy", "häd", "ä", "little", "lämb", "Little", "lämb"]) } #[test] @@ -3893,11 +3893,11 @@ mod tests { fn test_lines() { let data = "\nMäry häd ä little lämb\n\nLittle lämb\n"; let lines: ~[&str] = data.lines().collect(); - assert_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]); + assert_eq!(lines, box ["", "Märy häd ä little lämb", "", "Little lämb"]); let data = "\nMäry häd ä little lämb\n\nLittle lämb"; // no trailing \n let lines: ~[&str] = data.lines().collect(); - assert_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]); + assert_eq!(lines, box ["", "Märy häd ä little lämb", "", "Little lämb"]); } #[test] @@ -3906,20 +3906,20 @@ mod tests { let v: ~[&str] = s.split_str(sep).collect(); assert_eq!(v, u); } - t("--1233345--", "12345", ~["--1233345--"]); - t("abc::hello::there", "::", ~["abc", "hello", "there"]); - t("::hello::there", "::", ~["", "hello", "there"]); - t("hello::there::", "::", ~["hello", "there", ""]); - t("::hello::there::", "::", ~["", "hello", "there", ""]); - t("ประเทศไทย中华Việt Nam", "中华", ~["ประเทศไทย", "Việt Nam"]); - t("zzXXXzzYYYzz", "zz", ~["", "XXX", "YYY", ""]); - t("zzXXXzYYYz", "XXX", ~["zz", "zYYYz"]); - t(".XXX.YYY.", ".", ~["", "XXX", "YYY", ""]); - t("", ".", ~[""]); - t("zz", "zz", ~["",""]); - t("ok", "z", ~["ok"]); - t("zzz", "zz", ~["","z"]); - t("zzzzz", "zz", ~["","","z"]); + t("--1233345--", "12345", box ["--1233345--"]); + t("abc::hello::there", "::", box ["abc", "hello", "there"]); + t("::hello::there", "::", box ["", "hello", "there"]); + t("hello::there::", "::", box ["hello", "there", ""]); + t("::hello::there::", "::", box ["", "hello", "there", ""]); + t("ประเทศไทย中华Việt Nam", "中华", box ["ประเทศไทย", "Việt Nam"]); + t("zzXXXzzYYYzz", "zz", box ["", "XXX", "YYY", ""]); + t("zzXXXzYYYz", "XXX", box ["zz", "zYYYz"]); + t(".XXX.YYY.", ".", box ["", "XXX", "YYY", ""]); + t("", ".", box [""]); + t("zz", "zz", box ["",""]); + t("ok", "z", box ["ok"]); + t("zzz", "zz", box ["","z"]); + t("zzzzz", "zz", box ["","","z"]); } #[test] diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs index 8d6d1c222cf55..0cf975a4c1c96 100644 --- a/src/libstd/sync/arc.rs +++ b/src/libstd/sync/arc.rs @@ -45,7 +45,7 @@ struct ArcData { } unsafe fn new_inner(data: T, refcount: uint) -> *mut ArcData { - let data = ~ArcData { + let data = box ArcData { count: AtomicUint::new(refcount), data: Unsafe::new(data) }; @@ -71,7 +71,7 @@ impl UnsafeArc { pub fn newN(data: T, num_handles: uint) -> ~[UnsafeArc] { unsafe { if num_handles == 0 { - ~[] // need to free data here + box [] // need to free data here } else { let ptr = new_inner(data, num_handles); let v = Vec::from_fn(num_handles, |_| UnsafeArc { data: ptr }); diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs index e6b71b502c21b..a3c1c33f77c53 100644 --- a/src/libstd/sync/atomics.rs +++ b/src/libstd/sync/atomics.rs @@ -894,36 +894,36 @@ mod test { #[test] fn option_swap() { - let p = AtomicOption::new(~1); - let a = ~2; + let p = AtomicOption::new(box 1); + let a = box 2; let b = p.swap(a, SeqCst); - assert_eq!(b, Some(~1)); - assert_eq!(p.take(SeqCst), Some(~2)); + assert_eq!(b, Some(box 1)); + assert_eq!(p.take(SeqCst), Some(box 2)); } #[test] fn option_take() { - let p = AtomicOption::new(~1); + let p = AtomicOption::new(box 1); - assert_eq!(p.take(SeqCst), Some(~1)); + assert_eq!(p.take(SeqCst), Some(box 1)); assert_eq!(p.take(SeqCst), None); - let p2 = ~2; + let p2 = box 2; p.swap(p2, SeqCst); - assert_eq!(p.take(SeqCst), Some(~2)); + assert_eq!(p.take(SeqCst), Some(box 2)); } #[test] fn option_fill() { - let p = AtomicOption::new(~1); - assert!(p.fill(~2, SeqCst).is_some()); // should fail; shouldn't leak! - assert_eq!(p.take(SeqCst), Some(~1)); + let p = AtomicOption::new(box 1); + assert!(p.fill(box 2, SeqCst).is_some()); // should fail; shouldn't leak! + assert_eq!(p.take(SeqCst), Some(box 1)); - assert!(p.fill(~2, SeqCst).is_none()); // shouldn't fail - assert_eq!(p.take(SeqCst), Some(~2)); + assert!(p.fill(box 2, SeqCst).is_none()); // shouldn't fail + assert_eq!(p.take(SeqCst), Some(box 2)); } #[test] diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs index 97239707d329a..22ed66b708b7e 100644 --- a/src/libstd/sync/deque.rs +++ b/src/libstd/sync/deque.rs @@ -159,7 +159,7 @@ impl BufferPool { self.pool.with(|pool| { match pool.iter().position(|x| x.size() >= (1 << bits)) { Some(i) => pool.remove(i).unwrap(), - None => ~Buffer::new(bits) + None => box Buffer::new(bits) } }) } @@ -314,7 +314,7 @@ impl Deque { // continue to be read after we flag this buffer for reclamation. unsafe fn swap_buffer(&mut self, b: int, old: *mut Buffer, buf: Buffer) -> *mut Buffer { - let newbuf: *mut Buffer = cast::transmute(~buf); + let newbuf: *mut Buffer = cast::transmute(box buf); self.array.store(newbuf, SeqCst); let ss = (*newbuf).size(); self.bottom.store(b + ss, SeqCst); @@ -474,7 +474,7 @@ mod tests { fn stampede(mut w: Worker<~int>, s: Stealer<~int>, nthreads: int, amt: uint) { for _ in range(0, amt) { - w.push(~20); + w.push(box 20); } let mut remaining = AtomicUint::new(amt); let unsafe_remaining: *mut AtomicUint = &mut remaining; @@ -603,7 +603,7 @@ mod tests { let (threads, hits) = slice::unzip(range(0, NTHREADS).map(|_| { let s = s.clone(); - let unique_box = ~AtomicUint::new(0); + let unique_box = box AtomicUint::new(0); let thread_box = unsafe { *cast::transmute::<&~AtomicUint,**mut AtomicUint>(&unique_box) }; diff --git a/src/libstd/sync/mpsc_queue.rs b/src/libstd/sync/mpsc_queue.rs index 142a6239df6da..315e412446d6b 100644 --- a/src/libstd/sync/mpsc_queue.rs +++ b/src/libstd/sync/mpsc_queue.rs @@ -73,7 +73,7 @@ pub struct Queue { impl Node { unsafe fn new(v: Option) -> *mut Node { - cast::transmute(~Node { + cast::transmute(box Node { next: AtomicPtr::new(0 as *mut Node), value: v, }) @@ -163,8 +163,8 @@ mod tests { #[test] fn test_full() { let mut q = Queue::new(); - q.push(~1); - q.push(~2); + q.push(box 1); + q.push(box 2); } #[test] diff --git a/src/libstd/sync/spsc_queue.rs b/src/libstd/sync/spsc_queue.rs index 4e043ecf17180..f155bdca44646 100644 --- a/src/libstd/sync/spsc_queue.rs +++ b/src/libstd/sync/spsc_queue.rs @@ -73,7 +73,7 @@ pub struct Queue { impl Node { fn new() -> *mut Node { unsafe { - cast::transmute(~Node { + cast::transmute(box Node { value: None, next: AtomicPtr::new(0 as *mut Node), }) @@ -247,8 +247,8 @@ mod test { #[test] fn drop_full() { let mut q = Queue::new(0); - q.push(~1); - q.push(~2); + q.push(box 1); + q.push(box 2); } #[test] diff --git a/src/libstd/task.rs b/src/libstd/task.rs index f8b3d25033c81..e9b01063f94c1 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -418,7 +418,7 @@ fn test_spawn_sched_childs_on_default_sched() { fn avoid_copying_the_body(spawnfn: |v: proc():Send|) { let (tx, rx) = channel::(); - let x = ~1; + let x = box 1; let x_in_parent = (&*x) as *int as uint; spawnfn(proc() { @@ -507,7 +507,7 @@ fn test_try_fail_message_owned_str() { #[test] fn test_try_fail_message_any() { match try(proc() { - fail!(~413u16 as ~Any:Send); + fail!(box 413u16 as ~Any:Send); }) { Err(e) => { type T = ~Any:Send; diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index d29b0b3b07cbb..bdeae0340e29e 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -51,11 +51,11 @@ mod tests { #[test] fn test_vectors() { - let x: ~[int] = ~[]; + let x: ~[int] = box []; assert_eq!(x.to_str(), "[]".to_owned()); - assert_eq!((~[1]).to_str(), "[1]".to_owned()); - assert_eq!((~[1, 2, 3]).to_str(), "[1, 2, 3]".to_owned()); - assert!((~[~[], ~[1], ~[1, 1]]).to_str() == + assert_eq!((box [1]).to_str(), "[1]".to_owned()); + assert_eq!((box [1, 2, 3]).to_str(), "[1, 2, 3]".to_owned()); + assert!((box [box [], box [1], box [1, 1]]).to_str() == "[[], [1], [1, 1]]".to_owned()); } } diff --git a/src/libstd/unstable/dynamic_lib.rs b/src/libstd/unstable/dynamic_lib.rs index 671cacbbb6f2f..68f0aaab05b1b 100644 --- a/src/libstd/unstable/dynamic_lib.rs +++ b/src/libstd/unstable/dynamic_lib.rs @@ -72,7 +72,7 @@ impl DynamicLibrary { } else { ("LD_LIBRARY_PATH", ':' as u8) }; - let newenv = os::getenv_as_bytes(envvar).unwrap_or(~[]); + let newenv = os::getenv_as_bytes(envvar).unwrap_or(box []); let newenv = newenv + &[sep] + path.as_vec(); os::setenv(envvar, str::from_utf8(newenv).unwrap()); } diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index f660d7ae97a99..372fcc396b13a 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -44,9 +44,9 @@ fn test_run_in_bare_thread() { #[test] fn test_run_in_bare_thread_exchange() { // Does the exchange heap work without the runtime? - let i = ~100; + let i = box 100; run_in_bare_thread(proc() { - assert!(i == ~100); + assert!(i == box 100); }); } diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index b7f6d730d12bc..5be10fc27dfe5 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -120,7 +120,7 @@ mod tests { let num_tasks = 10; let count = 10; - let total = Exclusive::new(~0); + let total = Exclusive::new(box 0); for _ in range(0u, num_tasks) { let total = total.clone(); diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index fa2f53fcf69a5..e264615578e42 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1585,8 +1585,8 @@ mod tests { #[test] fn test_clone_from() { let mut v = vec!(); - let three = vec!(~1, ~2, ~3); - let two = vec!(~4, ~5); + let three = vec!(box 1, box 2, box 3); + let two = vec!(box 4, box 5); // zero, long v.clone_from(&three); assert_eq!(v, three); diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index ecfeade2fb437..b5c660759522e 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -70,7 +70,7 @@ impl Arc { pub fn new(data: T) -> Arc { // 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 - let x = ~ArcInner { + let x = box ArcInner { strong: atomics::AtomicUint::new(1), weak: atomics::AtomicUint::new(1), data: data, diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index eb90797395edf..6ab833a19efbd 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -109,7 +109,7 @@ struct SemGuard<'a, Q> { impl Sem { fn new(count: int, q: Q) -> Sem { let inner = unsafe { - cast::transmute(~SemInner { + cast::transmute(box SemInner { waiters: WaitQueue::new(), count: count, blocked: q, @@ -726,7 +726,7 @@ mod tests { let (tx, rx) = channel(); let m = Arc::new(Mutex::new()); let m2 = m.clone(); - let mut sharedstate = ~0; + let mut sharedstate = box 0; { let ptr: *mut int = &mut *sharedstate; task::spawn(proc() { @@ -895,7 +895,7 @@ mod tests { // mutex mutual exclusion test, a ways above. let (tx, rx) = channel(); let x2 = x.clone(); - let mut sharedstate = ~0; + let mut sharedstate = box 0; { let ptr: *int = &*sharedstate; task::spawn(proc() { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 4d487689c6797..f09072e0bc605 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -177,7 +177,7 @@ pub fn mk_span_handler(handler: Handler, cm: codemap::CodeMap) -> SpanHandler { } pub fn default_handler() -> Handler { - mk_handler(~EmitterWriter::stderr()) + mk_handler(box EmitterWriter::stderr()) } pub fn mk_handler(e: ~Emitter:Send) -> Handler { @@ -262,11 +262,11 @@ impl EmitterWriter { if stderr.get_ref().isatty() { let dst = match term::Terminal::new(stderr.unwrap()) { Ok(t) => Terminal(t), - Err(..) => Raw(~io::stderr()), + Err(..) => Raw(box io::stderr()), }; EmitterWriter { dst: dst } } else { - EmitterWriter { dst: Raw(~stderr) } + EmitterWriter { dst: Raw(box stderr) } } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 34c4f77bc4382..cee6216b23fdd 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -131,7 +131,7 @@ pub struct MacExpr { } impl MacExpr { pub fn new(e: @ast::Expr) -> ~MacResult { - ~MacExpr { e: e } as ~MacResult + box MacExpr { e: e } as ~MacResult } } impl MacResult for MacExpr { @@ -145,7 +145,7 @@ pub struct MacItem { } impl MacItem { pub fn new(i: @ast::Item) -> ~MacResult { - ~MacItem { i: i } as ~MacResult + box MacItem { i: i } as ~MacResult } } impl MacResult for MacItem { @@ -174,7 +174,7 @@ impl DummyResult { /// Use this as a return value after hitting any errors and /// calling `span_err`. pub fn any(sp: Span) -> ~MacResult { - ~DummyResult { expr_only: false, span: sp } as ~MacResult + box DummyResult { expr_only: false, span: sp } as ~MacResult } /// Create a default MacResult that can only be an expression. @@ -183,7 +183,7 @@ impl DummyResult { /// if an error is encountered internally, the user will recieve /// an error that they also used it in the wrong place. pub fn expr(sp: Span) -> ~MacResult { - ~DummyResult { expr_only: true, span: sp } as ~MacResult + box DummyResult { expr_only: true, span: sp } as ~MacResult } /// A plain dummy expression. @@ -262,7 +262,7 @@ pub type RenameList = Vec<(ast::Ident, Name)>; pub fn syntax_expander_table() -> SyntaxEnv { // utility function to simplify creating NormalTT syntax extensions fn builtin_normal_expander(f: MacroExpanderFn) -> SyntaxExtension { - NormalTT(~BasicMacroExpander { + NormalTT(box BasicMacroExpander { expander: f, span: None, }, @@ -271,7 +271,7 @@ pub fn syntax_expander_table() -> SyntaxEnv { let mut syntax_expanders = SyntaxEnv::new(); syntax_expanders.insert(intern("macro_rules"), - IdentTT(~BasicIdentMacroExpander { + IdentTT(box BasicIdentMacroExpander { expander: ext::tt::macro_rules::add_new_extension, span: None, }, diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 062f198425b28..2447535f1f3d8 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -31,14 +31,14 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt, span: span, attributes: Vec::new(), path: Path::new_(vec!("serialize", "Decodable"), None, - vec!(~Literal(Path::new_local("__D")), - ~Literal(Path::new_local("__E"))), true), + vec!(box Literal(Path::new_local("__D")), + box Literal(Path::new_local("__E"))), true), additional_bounds: Vec::new(), generics: LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("__D", ast::StaticSize, vec!(Path::new_( vec!("serialize", "Decoder"), None, - vec!(~Literal(Path::new_local("__E"))), true))), + vec!(box Literal(Path::new_local("__E"))), true))), ("__E", ast::StaticSize, vec!())) }, methods: vec!( @@ -46,10 +46,11 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt, name: "decode", generics: LifetimeBounds::empty(), explicit_self: None, - args: vec!(Ptr(~Literal(Path::new_local("__D")), + args: vec!(Ptr(box Literal(Path::new_local("__D")), Borrowed(None, MutMutable))), ret_ty: Literal(Path::new_(vec!("std", "result", "Result"), None, - vec!(~Self, ~Literal(Path::new_local("__E"))), true)), + vec!(box Self, + box Literal(Path::new_local("__E"))), true)), attributes: Vec::new(), const_nonmatching: true, combine_substructure: combine_substructure(|a, b, c| { diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index ec3d4e0078bc6..75b051b2f1086 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -99,14 +99,14 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt, span: span, attributes: Vec::new(), path: Path::new_(vec!("serialize", "Encodable"), None, - vec!(~Literal(Path::new_local("__S")), - ~Literal(Path::new_local("__E"))), true), + vec!(box Literal(Path::new_local("__S")), + box Literal(Path::new_local("__E"))), true), additional_bounds: Vec::new(), generics: LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("__S", ast::StaticSize, vec!(Path::new_( vec!("serialize", "Encoder"), None, - vec!(~Literal(Path::new_local("__E"))), true))), + vec!(box Literal(Path::new_local("__E"))), true))), ("__E", ast::StaticSize, vec!())) }, methods: vec!( @@ -114,12 +114,12 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt, name: "encode", generics: LifetimeBounds::empty(), explicit_self: borrowed_explicit_self(), - args: vec!(Ptr(~Literal(Path::new_local("__S")), + args: vec!(Ptr(box Literal(Path::new_local("__S")), Borrowed(None, MutMutable))), ret_ty: Literal(Path::new_(vec!("std", "result", "Result"), None, - vec!(~Tuple(Vec::new()), - ~Literal(Path::new_local("__E"))), + vec!(box Tuple(Vec::new()), + box Literal(Path::new_local("__E"))), true)), attributes: Vec::new(), const_nonmatching: true, diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index d367ae61e0b8f..8ce98a04e287a 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -24,7 +24,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, let (path, generics, args) = if cx.ecfg.deriving_hash_type_parameter { (Path::new_(vec!("std", "hash", "Hash"), None, - vec!(~Literal(Path::new_local("__S"))), true), + vec!(box Literal(Path::new_local("__S"))), true), LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("__S", ast::StaticSize, vec!(Path::new(vec!("std", "io", "Writer"))))), @@ -48,7 +48,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, name: "hash", generics: LifetimeBounds::empty(), explicit_self: borrowed_explicit_self(), - args: vec!(Ptr(~Literal(args), Borrowed(None, MutMutable))), + args: vec!(Ptr(box Literal(args), Borrowed(None, MutMutable))), ret_ty: nil_ty(), attributes: attrs, const_nonmatching: false, diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 9978a2edce9c1..5066a395b415f 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -38,7 +38,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, Literal(Path::new(vec!("i64")))), ret_ty: Literal(Path::new_(vec!("std", "option", "Option"), None, - vec!(~Self), + vec!(box Self), true)), // #[inline] liable to cause code-bloat attributes: attrs.clone(), @@ -55,7 +55,7 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, Literal(Path::new(vec!("u64")))), ret_ty: Literal(Path::new_(vec!("std", "option", "Option"), None, - vec!(~Self), + vec!(box Self), true)), // #[inline] liable to cause code-bloat attributes: attrs, diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 23877dd29ea79..397b99925c8ec 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -37,7 +37,7 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt, }, explicit_self: None, args: vec!( - Ptr(~Literal(Path::new_local("R")), + Ptr(box Literal(Path::new_local("R")), Borrowed(None, ast::MutMutable)) ), ret_ty: Self, diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index b9725361538d1..aeaf53a193904 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -26,7 +26,7 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt, item: @Item, push: |@Item|) { // &mut ::std::fmt::Formatter - let fmtr = Ptr(~Literal(Path::new(vec!("std", "fmt", "Formatter"))), + let fmtr = Ptr(box Literal(Path::new(vec!("std", "fmt", "Formatter"))), Borrowed(None, ast::MutMutable)); let trait_def = TraitDef { diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 6e3327b40392e..769bbe2fc4e2f 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -101,7 +101,7 @@ pub fn borrowed_explicit_self<'r>() -> Option>> { } pub fn borrowed_self<'r>() -> Ty<'r> { - borrowed(~Self) + borrowed(box Self) } pub fn nil_ty() -> Ty<'static> { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 8143f2aceeb61..4c426bef12e5b 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -134,7 +134,7 @@ pub fn initial_matcher_pos(ms: Vec , sep: Option, lo: BytePos) } } let matches = Vec::from_fn(count_names(ms.as_slice()), |_i| Vec::new()); - ~MatcherPos { + box MatcherPos { elts: ms, sep: sep, idx: 0u, @@ -334,7 +334,7 @@ pub fn parse(sess: &ParseSess, let matches = Vec::from_elem(ei.matches.len(), Vec::new()); let ei_t = ei; - cur_eis.push(~MatcherPos { + cur_eis.push(box MatcherPos { elts: (*matchers).clone(), sep: (*sep).clone(), idx: 0u, @@ -396,7 +396,7 @@ pub fn parse(sess: &ParseSess, } rdr.next_token(); } else /* bb_eis.len() == 1 */ { - let mut rust_parser = Parser(sess, cfg.clone(), ~rdr.clone()); + let mut rust_parser = Parser(sess, cfg.clone(), box rdr.clone()); let mut ei = bb_eis.pop().unwrap(); match ei.elts.get(ei.idx).node { @@ -433,14 +433,14 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { "ty" => token::NtTy(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one "ident" => match p.token { - token::IDENT(sn,b) => { p.bump(); token::NtIdent(~sn,b) } + token::IDENT(sn,b) => { p.bump(); token::NtIdent(box sn,b) } _ => { let token_str = token::to_str(&p.token); p.fatal("expected ident, found ".to_owned() + token_str) } }, "path" => { - token::NtPath(~p.parse_path(LifetimeAndTypesWithoutColons).path) + token::NtPath(box p.parse_path(LifetimeAndTypesWithoutColons).path) } "meta" => token::NtMeta(p.parse_meta_item()), "tt" => { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 78ea37587f010..ab0266cedaae9 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -166,10 +166,10 @@ fn generic_extension(cx: &ExtCtxt, let trncbr = new_tt_reader(&cx.parse_sess().span_diagnostic, Some(named_matches), rhs); - let p = Parser(cx.parse_sess(), cx.cfg(), ~trncbr); + let p = Parser(cx.parse_sess(), cx.cfg(), box trncbr); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. - return ~ParserAnyMacro { + return box ParserAnyMacro { parser: RefCell::new(p), } as ~MacResult } @@ -239,13 +239,13 @@ pub fn add_new_extension(cx: &mut ExtCtxt, _ => cx.span_bug(sp, "wrong-structured rhs") }; - let exp = ~MacroRulesMacroExpander { + let exp = box MacroRulesMacroExpander { name: name, lhses: lhses, rhses: rhses, }; - ~MacroRulesDefiner { + box MacroRulesDefiner { def: RefCell::new(Some(MacroDef { name: token::get_ident(name).to_str(), ext: NormalTT(exp, Some(sp)) diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index c1f6e21f923c3..43535205601f1 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -1020,8 +1020,8 @@ mod test { use std::io::util; fn mk_sh() -> diagnostic::SpanHandler { - let emitter = diagnostic::EmitterWriter::new(~util::NullWriter); - let handler = diagnostic::mk_handler(~emitter); + let emitter = diagnostic::EmitterWriter::new(box util::NullWriter); + let handler = diagnostic::mk_handler(box emitter); diagnostic::mk_span_handler(handler, CodeMap::new()) } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 0d3ae3b5cb816..dec6e6dd3747b 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -247,7 +247,7 @@ pub fn filemap_to_tts(sess: &ParseSess, filemap: Rc) // parsing tt's probably shouldn't require a parser at all. let cfg = Vec::new(); let srdr = lexer::new_string_reader(&sess.span_diagnostic, filemap); - let mut p1 = Parser(sess, cfg, ~srdr); + let mut p1 = Parser(sess, cfg, box srdr); p1.parse_all_token_trees() } @@ -256,7 +256,7 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess, tts: Vec, cfg: ast::CrateConfig) -> Parser<'a> { let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, tts); - Parser(sess, cfg, ~trdr) + Parser(sess, cfg, box trdr) } // abort if necessary diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5d8443b64d5ef..6989ceb0d7992 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -751,7 +751,7 @@ impl<'a> Parser<'a> { self.last_span = self.span; // Stash token for error recovery (sometimes; clone is not necessarily cheap). self.last_token = if is_ident_or_path(&self.token) { - Some(~self.token.clone()) + Some(box self.token.clone()) } else { None }; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index afb66ab831750..f5fe92c3e6791 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -132,7 +132,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap, } pub fn to_str(f: |&mut State| -> IoResult<()>) -> ~str { - let mut s = rust_printer(~MemWriter::new()); + let mut s = rust_printer(box MemWriter::new()); f(&mut s).unwrap(); eof(&mut s.s).unwrap(); unsafe { diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index e27f4652305ad..538a1513d65a7 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -294,7 +294,12 @@ pub fn parse(file: &mut io::Reader, } // And that's all there is to it - Ok(~TermInfo {names: term_names, bools: bools_map, numbers: numbers_map, strings: string_map }) + Ok(box TermInfo { + names: term_names, + bools: bools_map, + numbers: numbers_map, + strings: string_map + }) } /// Create a dummy TermInfo struct for msys terminals @@ -304,7 +309,7 @@ pub fn msys_terminfo() -> ~TermInfo { strings.insert("bold".to_owned(), Vec::from_slice(bytes!("\x1b[1m"))); strings.insert("setaf".to_owned(), Vec::from_slice(bytes!("\x1b[3%p1%dm"))); strings.insert("setab".to_owned(), Vec::from_slice(bytes!("\x1b[4%p1%dm"))); - ~TermInfo { + box TermInfo { names: vec!("cygwin".to_owned()), // msys is a fork of an older cygwin version bools: HashMap::new(), numbers: HashMap::new(), diff --git a/src/libterm/terminfo/searcher.rs b/src/libterm/terminfo/searcher.rs index 12540f525812f..a491f7e863e96 100644 --- a/src/libterm/terminfo/searcher.rs +++ b/src/libterm/terminfo/searcher.rs @@ -62,13 +62,13 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> { let f = str::from_char(first_char); let newp = p.join_many([f.as_slice(), term]); if newp.exists() { - return Some(~newp); + return Some(box newp); } // on some installations the dir is named after the hex of the char (e.g. OS X) let f = format!("{:x}", first_char as uint); let newp = p.join_many([f.as_slice(), term]); if newp.exists() { - return Some(~newp); + return Some(box newp); } } } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 05d38b3d0c162..8c0abe32e3cb8 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1001,8 +1001,8 @@ pub fn run_test(opts: &TestOpts, if nocapture { drop((stdout, stderr)); } else { - task.opts.stdout = Some(~stdout as ~Writer:Send); - task.opts.stderr = Some(~stderr as ~Writer:Send); + task.opts.stdout = Some(box stdout as ~Writer:Send); + task.opts.stderr = Some(box stderr as ~Writer:Send); } let result_future = task.future_result(); task.spawn(testfn); @@ -1056,7 +1056,7 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult { impl ToJson for Metric { fn to_json(&self) -> json::Json { - let mut map = ~TreeMap::new(); + let mut map = box TreeMap::new(); map.insert("value".to_owned(), json::Number(self.value)); map.insert("noise".to_owned(), json::Number(self.noise)); json::Object(map)