diff options
| author | bors <bors@rust-lang.org> | 2015-03-03 20:17:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-03 20:17:08 +0000 |
| commit | fed12499e7d91f9cdfba5833e34d20e8fd19b898 (patch) | |
| tree | 2c5b377f6a53498f2555965e4903b77e4c8aad30 /src/libstd | |
| parent | 129173f1980e9ac03f7ef0fc0193c41235d07649 (diff) | |
| parent | cb1b0dd589c80c3edb94b8982ea33e000978f572 (diff) | |
| download | rust-fed12499e7d91f9cdfba5833e34d20e8fd19b898.tar.gz rust-fed12499e7d91f9cdfba5833e34d20e8fd19b898.zip | |
Auto merge of #23002 - pnkfelix:fsk-box-place-runway, r=nikomatsakis
Runway for RFC 809 (overloaded box/placement-in) by adding type annotations or explicit calls to `Box::new` where I found it necessary on PR #22086. I have broken this up into more than one PR because the entire commit chain (see PR #22086) is long, widespread and unwieldy to rebase frequently. To my knowledge this is not a breaking change. Also, there is in principle nothing stopping someone from reverting some/all of these annotations, since without the rest of the commit chain in #22086, the associated code would continue to compile. All I can do is ask: Try to discourage others from removing seemingly "unnecessary" uses of the `Box` type or the `Box::new()` function, until the rest of RFC 809 lands.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/old_io/net/ip.rs | 12 | ||||
| -rw-r--r-- | src/libstd/old_io/stdio.rs | 6 | ||||
| -rw-r--r-- | src/libstd/old_io/timer.rs | 5 | ||||
| -rw-r--r-- | src/libstd/rt/unwind.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/mpsc_queue.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sync/mpsc/spsc_queue.rs | 2 | ||||
| -rw-r--r-- | src/libstd/thread.rs | 2 | ||||
| -rw-r--r-- | src/libstd/thunk.rs | 2 |
9 files changed, 24 insertions, 21 deletions
diff --git a/src/libstd/old_io/net/ip.rs b/src/libstd/old_io/net/ip.rs index 9c89c943994..f1634cd4229 100644 --- a/src/libstd/old_io/net/ip.rs +++ b/src/libstd/old_io/net/ip.rs @@ -323,22 +323,22 @@ impl<'a> Parser<'a> { } fn read_ip_addr(&mut self) -> Option<IpAddr> { - let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr(); - let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr(); - self.read_or(&mut [box ipv4_addr, box ipv6_addr]) + let ipv4_addr: Box<_> = box |p: &mut Parser| p.read_ipv4_addr(); + let ipv6_addr: Box<_> = box |p: &mut Parser| p.read_ipv6_addr(); + self.read_or(&mut [ipv4_addr, ipv6_addr]) } fn read_socket_addr(&mut self) -> Option<SocketAddr> { let ip_addr = |p: &mut Parser| { - let ipv4_p = |p: &mut Parser| p.read_ip_addr(); - let ipv6_p = |p: &mut Parser| { + let ipv4_p: Box<_> = box |p: &mut Parser| p.read_ip_addr(); + let ipv6_p: Box<_> = box |p: &mut Parser| { let open_br = |p: &mut Parser| p.read_given_char('['); let ip_addr = |p: &mut Parser| p.read_ipv6_addr(); let clos_br = |p: &mut Parser| p.read_given_char(']'); p.read_seq_3::<char, IpAddr, char, _, _, _>(open_br, ip_addr, clos_br) .map(|t| match t { (_, ip, _) => ip }) }; - p.read_or(&mut [box ipv4_p, box ipv6_p]) + p.read_or(&mut [ipv4_p, ipv6_p]) }; let colon = |p: &mut Parser| p.read_given_char(':'); let port = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16); 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/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index ee8bef50d89..1a1e9e69e71 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1044,13 +1044,13 @@ mod test { #[test] fn drop_full() { - let (tx, _rx) = channel(); + let (tx, _rx) = channel::<Box<int>>(); tx.send(box 1).unwrap(); } #[test] fn drop_full_shared() { - let (tx, _rx) = channel(); + let (tx, _rx) = channel::<Box<int>>(); drop(tx.clone()); drop(tx.clone()); tx.send(box 1).unwrap(); @@ -1389,7 +1389,7 @@ mod test { #[test] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { - let (tx, rx) = channel(); + let (tx, rx) = channel::<Box<int>>(); let _t = thread::spawn(move|| { tx.send(box 10).unwrap(); }); @@ -1566,7 +1566,7 @@ mod sync_tests { #[test] fn drop_full() { - let (tx, _rx) = sync_channel(1); + let (tx, _rx) = sync_channel::<Box<int>>(1); tx.send(box 1).unwrap(); } diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 59fa2e6bc9a..14ed253d8e2 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -164,7 +164,7 @@ mod tests { #[test] fn test_full() { - let q = Queue::new(); + let q: Queue<Box<_>> = Queue::new(); q.push(box 1); q.push(box 2); } diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index ce40fa2672a..3fb13739aa7 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -289,7 +289,7 @@ mod test { #[test] fn drop_full() { unsafe { - let q = Queue::new(0); + let q: Queue<Box<_>> = Queue::new(0); q.push(box 1); q.push(box 2); } diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index e8330820906..9be77e78ed1 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -804,7 +804,7 @@ mod test { fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Thunk<'static>) { let (tx, rx) = channel(); - let x = box 1; + let x: Box<_> = box 1; let x_in_parent = (&*x) as *const i32 as usize; spawnfn(Thunk::new(move|| { 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) } } |
