about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2015-02-15 09:52:21 +0100
committerFelix S. Klock II <pnkfelix@pnkfx.org>2015-03-03 21:05:55 +0100
commit0d5bcb14adb71900a99f06b92485de7e019734c2 (patch)
tree37b9faace62c6658ff6ecf9d646e04c01be875fb /src/libstd
parentb03279aaa2b20f6033e66fc7aea29c0b43e71082 (diff)
downloadrust-0d5bcb14adb71900a99f06b92485de7e019734c2.tar.gz
rust-0d5bcb14adb71900a99f06b92485de7e019734c2.zip
Switched to Box::new in many places.
Many of the modifications putting in `Box::new` calls also include a
pointer to Issue 22405, which tracks going back to `box <expr>` if
possible in the future.

(Still tried to use `Box<_>` where it sufficed; thus some tests still
have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.)

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/old_io/stdio.rs6
-rw-r--r--src/libstd/old_io/timer.rs5
-rw-r--r--src/libstd/rt/unwind.rs6
-rw-r--r--src/libstd/thunk.rs2
4 files changed, 11 insertions, 8 deletions
diff --git a/src/libstd/old_io/stdio.rs b/src/libstd/old_io/stdio.rs
index a5df21749e2..85bf4908f83 100644
--- a/src/libstd/old_io/stdio.rs
+++ b/src/libstd/old_io/stdio.rs
@@ -547,8 +547,9 @@ mod tests {
 
         let (tx, rx) = channel();
         let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
+        // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
         let _t = thread::spawn(move|| {
-            set_stdout(box w);
+            set_stdout(Box::new(w));
             println!("hello!");
         });
         assert_eq!(r.read_to_string().unwrap(), "hello!\n");
@@ -560,8 +561,9 @@ mod tests {
 
         let (tx, rx) = channel();
         let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
+        // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
         let _t = thread::spawn(move || -> () {
-            set_stderr(box w);
+            set_stderr(Box::new(w));
             panic!("my special message");
         });
         let s = r.read_to_string().unwrap();
diff --git a/src/libstd/old_io/timer.rs b/src/libstd/old_io/timer.rs
index 1f2ef50fcae..de5f2141095 100644
--- a/src/libstd/old_io/timer.rs
+++ b/src/libstd/old_io/timer.rs
@@ -15,6 +15,7 @@
 
 // FIXME: These functions take Durations but only pass ms to the backend impls.
 
+use boxed::Box;
 use sync::mpsc::{Receiver, Sender, channel};
 use time::Duration;
 use old_io::IoResult;
@@ -143,7 +144,7 @@ impl Timer {
         let (tx, rx) = channel();
         // Short-circuit the timer backend for 0 duration
         if in_ms_u64(duration) != 0 {
-            self.inner.oneshot(in_ms_u64(duration), box TimerCallback { tx: tx });
+            self.inner.oneshot(in_ms_u64(duration), Box::new(TimerCallback { tx: tx }));
         } else {
             tx.send(()).unwrap();
         }
@@ -204,7 +205,7 @@ impl Timer {
         // not clear what use a 0ms period is anyway...
         let ms = if ms == 0 { 1 } else { ms };
         let (tx, rx) = channel();
-        self.inner.period(ms, box TimerCallback { tx: tx });
+        self.inner.period(ms, Box::new(TimerCallback { tx: tx }));
         return rx
     }
 }
diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs
index 4dda3ea8c99..ebb2a2e4827 100644
--- a/src/libstd/rt/unwind.rs
+++ b/src/libstd/rt/unwind.rs
@@ -166,7 +166,7 @@ fn rust_panic(cause: Box<Any + Send + 'static>) -> ! {
     rtdebug!("begin_unwind()");
 
     unsafe {
-        let exception = box Exception {
+        let exception: Box<_> = box Exception {
             uwe: uw::_Unwind_Exception {
                 exception_class: rust_exception_class(),
                 exception_cleanup: exception_cleanup,
@@ -506,7 +506,7 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, uint)) -
 
     let mut s = String::new();
     let _ = write!(&mut s, "{}", msg);
-    begin_unwind_inner(box s, file_line)
+    begin_unwind_inner(Box::new(s), file_line)
 }
 
 /// This is the entry point of unwinding for panic!() and assert!().
@@ -521,7 +521,7 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, uint)) ->
     // panicking.
 
     // see below for why we do the `Any` coercion here.
-    begin_unwind_inner(box msg, file_line)
+    begin_unwind_inner(Box::new(msg), file_line)
 }
 
 /// The core of the unwinding.
diff --git a/src/libstd/thunk.rs b/src/libstd/thunk.rs
index 5bede984f13..a9cb05b368f 100644
--- a/src/libstd/thunk.rs
+++ b/src/libstd/thunk.rs
@@ -33,7 +33,7 @@ impl<'a,A,R> Thunk<'a,A,R> {
         where F : FnOnce(A) -> R, F : Send + 'a
     {
         Thunk {
-            invoke: box func
+            invoke: Box::<F>::new(func)
         }
     }