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-17 21:41:32 +0100
committerFelix S. Klock II <pnkfelix@pnkfx.org>2015-03-03 20:29:01 +0100
commit270f0eef733a625bcee68019189f19dc119f8f24 (patch)
tree1b58f6d17a7ca5cb04f6124eaa93e0234ff3c906 /src/libstd
parent14f0942a49b77f81d0bedb3d8b5fb615ef521bb3 (diff)
downloadrust-270f0eef733a625bcee68019189f19dc119f8f24.tar.gz
rust-270f0eef733a625bcee68019189f19dc119f8f24.zip
Add `: Box<_>` or `::Box<_>` type annotations to various places.
This is the kind of change that one is expected to need to make to
accommodate overloaded-`box`.

----

Note that this is not *all* of the changes necessary to accommodate
Issue 22181.  It is merely the subset of those cases where there was
already a let-binding in place that made it easy to add the necesasry
type ascription.

(For unnamed intermediate `Box` values, one must go down a different
route; `Box::new` is the option that maximizes portability, but has
potential inefficiency depending on whether the call is inlined.)

----

There is one place worth note, `run-pass/coerce-match.rs`, where I
used an ugly form of `Box<_>` type ascription where I would have
preferred to use `Box::new` to accommodate overloaded-`box`.  I
deliberately did not use `Box::new` here, because that is already done
in coerce-match-calls.rs.

----

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/old_io/net/ip.rs12
-rw-r--r--src/libstd/sync/mpsc/mod.rs8
-rw-r--r--src/libstd/sync/mpsc/mpsc_queue.rs2
-rw-r--r--src/libstd/sync/mpsc/spsc_queue.rs2
-rw-r--r--src/libstd/thread.rs2
5 files changed, 13 insertions, 13 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/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|| {