From 270f0eef733a625bcee68019189f19dc119f8f24 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 17 Feb 2015 21:41:32 +0100 Subject: 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. --- src/libstd/sync/mpsc/mod.rs | 8 ++++---- src/libstd/sync/mpsc/mpsc_queue.rs | 2 +- src/libstd/sync/mpsc/spsc_queue.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libstd/sync') 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::>(); tx.send(box 1).unwrap(); } #[test] fn drop_full_shared() { - let (tx, _rx) = channel(); + let (tx, _rx) = channel::>(); 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::>(); 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::>(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> = 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> = Queue::new(0); q.push(box 1); q.push(box 2); } -- cgit 1.4.1-3-g733a5