diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-05 18:56:44 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-06 23:12:54 -0700 |
| commit | 090040bf4037a094e50b03d79e4baf5cd89c912b (patch) | |
| tree | 27fa91d623889d59260d3db167abdfa8c4288849 /src/libstd/comm | |
| parent | 24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff) | |
| download | rust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip | |
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
Diffstat (limited to 'src/libstd/comm')
| -rw-r--r-- | src/libstd/comm/mod.rs | 32 | ||||
| -rw-r--r-- | src/libstd/comm/oneshot.rs | 3 | ||||
| -rw-r--r-- | src/libstd/comm/select.rs | 3 | ||||
| -rw-r--r-- | src/libstd/comm/shared.rs | 3 | ||||
| -rw-r--r-- | src/libstd/comm/stream.rs | 3 | ||||
| -rw-r--r-- | src/libstd/comm/sync.rs | 5 |
6 files changed, 29 insertions, 20 deletions
diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index c7849892465..bd1def518f0 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -279,6 +279,7 @@ use kinds::marker; use mem; use ops::Drop; use option::{Some, None, Option}; +use owned::Box; use result::{Ok, Err, Result}; use rt::local::Local; use rt::task::{Task, BlockedTask}; @@ -297,6 +298,7 @@ macro_rules! test ( use prelude::*; use super::*; use super::super::*; + use owned::Box; use task; fn f() $b @@ -549,7 +551,7 @@ impl<T: Send> Sender<T> { let cnt = self.sends.get() + 1; self.sends.set(cnt); if cnt % (RESCHED_FREQ as uint) == 0 { - let task: Option<~Task> = Local::try_take(); + let task: Option<Box<Task>> = Local::try_take(); task.map(|t| t.maybe_yield()); } @@ -773,7 +775,7 @@ impl<T: Send> Receiver<T> { let cnt = self.receives.get() + 1; self.receives.set(cnt); if cnt % (RESCHED_FREQ as uint) == 0 { - let task: Option<~Task> = Local::try_take(); + let task: Option<Box<Task>> = Local::try_take(); task.map(|t| t.maybe_yield()); } @@ -979,6 +981,7 @@ mod test { use native; use os; + use owned::Box; use super::*; pub fn stress_factor() -> uint { @@ -1197,7 +1200,7 @@ mod test { test!(fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed - let (tx, rx) = channel::<~int>(); + let (tx, rx) = channel::<Box<int>>(); drop(rx); tx.send(box 0); } #[should_fail]) @@ -1214,7 +1217,7 @@ mod test { }) test!(fn oneshot_single_thread_send_then_recv() { - let (tx, rx) = channel::<~int>(); + let (tx, rx) = channel::<Box<int>>(); tx.send(box 10); assert!(rx.recv() == box 10); }) @@ -1263,7 +1266,7 @@ mod test { }) test!(fn oneshot_multi_task_recv_then_send() { - let (tx, rx) = channel::<~int>(); + let (tx, rx) = channel::<Box<int>>(); spawn(proc() { assert!(rx.recv() == box 10); }); @@ -1272,7 +1275,7 @@ mod test { }) test!(fn oneshot_multi_task_recv_then_close() { - let (tx, rx) = channel::<~int>(); + let (tx, rx) = channel::<Box<int>>(); spawn(proc() { drop(tx); }); @@ -1340,7 +1343,7 @@ mod test { send(tx, 0); recv(rx, 0); - fn send(tx: Sender<~int>, i: int) { + fn send(tx: Sender<Box<int>>, i: int) { if i == 10 { return } spawn(proc() { @@ -1349,7 +1352,7 @@ mod test { }); } - fn recv(rx: Receiver<~int>, i: int) { + fn recv(rx: Receiver<Box<int>>, i: int) { if i == 10 { return } spawn(proc() { @@ -1513,6 +1516,7 @@ mod test { mod sync_tests { use prelude::*; use os; + use owned::Box; pub fn stress_factor() -> uint { match os::getenv("RUST_TEST_STRESS") { @@ -1657,7 +1661,7 @@ mod sync_tests { test!(fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed - let (tx, rx) = sync_channel::<~int>(0); + let (tx, rx) = sync_channel::<Box<int>>(0); drop(rx); tx.send(box 0); } #[should_fail]) @@ -1674,7 +1678,7 @@ mod sync_tests { }) test!(fn oneshot_single_thread_send_then_recv() { - let (tx, rx) = sync_channel::<~int>(1); + let (tx, rx) = sync_channel::<Box<int>>(1); tx.send(box 10); assert!(rx.recv() == box 10); }) @@ -1728,7 +1732,7 @@ mod sync_tests { }) test!(fn oneshot_multi_task_recv_then_send() { - let (tx, rx) = sync_channel::<~int>(0); + let (tx, rx) = sync_channel::<Box<int>>(0); spawn(proc() { assert!(rx.recv() == box 10); }); @@ -1737,7 +1741,7 @@ mod sync_tests { }) test!(fn oneshot_multi_task_recv_then_close() { - let (tx, rx) = sync_channel::<~int>(0); + let (tx, rx) = sync_channel::<Box<int>>(0); spawn(proc() { drop(tx); }); @@ -1805,7 +1809,7 @@ mod sync_tests { send(tx, 0); recv(rx, 0); - fn send(tx: SyncSender<~int>, i: int) { + fn send(tx: SyncSender<Box<int>>, i: int) { if i == 10 { return } spawn(proc() { @@ -1814,7 +1818,7 @@ mod sync_tests { }); } - fn recv(rx: Receiver<~int>, i: int) { + fn recv(rx: Receiver<Box<int>>, i: int) { if i == 10 { return } spawn(proc() { diff --git a/src/libstd/comm/oneshot.rs b/src/libstd/comm/oneshot.rs index e92b5cb272a..a7124e50b66 100644 --- a/src/libstd/comm/oneshot.rs +++ b/src/libstd/comm/oneshot.rs @@ -37,6 +37,7 @@ use kinds::Send; use mem; use ops::Drop; use option::{Some, None, Option}; +use owned::Box; use result::{Result, Ok, Err}; use rt::local::Local; use rt::task::{Task, BlockedTask}; @@ -137,7 +138,7 @@ impl<T: Send> Packet<T> { // Attempt to not block the task (it's a little expensive). If it looks // like we're not empty, then immediately go through to `try_recv`. if self.state.load(atomics::SeqCst) == EMPTY { - let t: ~Task = Local::take(); + let t: Box<Task> = Local::take(); t.deschedule(1, |task| { let n = unsafe { task.cast_to_uint() }; match self.state.compare_and_swap(EMPTY, n, atomics::SeqCst) { diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index c286fd84849..cebfeb5399e 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -52,6 +52,7 @@ use kinds::marker; use kinds::Send; use ops::Drop; use option::{Some, None, Option}; +use owned::Box; use ptr::RawPtr; use result::{Ok, Err, Result}; use rt::local::Local; @@ -176,7 +177,7 @@ impl Select { // Acquire a number of blocking contexts, and block on each one // sequentially until one fails. If one fails, then abort // immediately so we can go unblock on all the other receivers. - let task: ~Task = Local::take(); + let task: Box<Task> = Local::take(); task.deschedule(amt, |task| { // Prepare for the block let (i, handle) = iter.next().unwrap(); diff --git a/src/libstd/comm/shared.rs b/src/libstd/comm/shared.rs index c0f1aeae26b..8aef2ec80a8 100644 --- a/src/libstd/comm/shared.rs +++ b/src/libstd/comm/shared.rs @@ -24,6 +24,7 @@ use iter::Iterator; use kinds::Send; use ops::Drop; use option::{Some, None, Option}; +use owned::Box; use result::{Ok, Err, Result}; use rt::local::Local; use rt::task::{Task, BlockedTask}; @@ -223,7 +224,7 @@ impl<T: Send> Packet<T> { data => return data, } - let task: ~Task = Local::take(); + let task: Box<Task> = Local::take(); task.deschedule(1, |task| { self.decrement(task) }); diff --git a/src/libstd/comm/stream.rs b/src/libstd/comm/stream.rs index 44070dc4460..9fb22ef4508 100644 --- a/src/libstd/comm/stream.rs +++ b/src/libstd/comm/stream.rs @@ -24,6 +24,7 @@ use iter::Iterator; use kinds::Send; use ops::Drop; use option::{Some, None}; +use owned::Box; use result::{Ok, Err, Result}; use rt::local::Local; use rt::task::{Task, BlockedTask}; @@ -181,7 +182,7 @@ impl<T: Send> Packet<T> { // Welp, our channel has no data. Deschedule the current task and // initiate the blocking protocol. - let task: ~Task = Local::take(); + let task: Box<Task> = Local::take(); task.deschedule(1, |task| { self.decrement(task) }); diff --git a/src/libstd/comm/sync.rs b/src/libstd/comm/sync.rs index 6228c4c682b..db3f90cad5a 100644 --- a/src/libstd/comm/sync.rs +++ b/src/libstd/comm/sync.rs @@ -40,6 +40,7 @@ use kinds::Send; use mem; use ops::Drop; use option::{Some, None, Option}; +use owned::Box; use ptr::RawPtr; use result::{Result, Ok, Err}; use rt::local::Local; @@ -111,7 +112,7 @@ pub enum Failure { /// in the meantime. This re-locks the mutex upon returning. fn wait(slot: &mut Blocker, f: fn(BlockedTask) -> Blocker, lock: &NativeMutex) { - let me: ~Task = Local::take(); + let me: Box<Task> = Local::take(); me.deschedule(1, |task| { match mem::replace(slot, f(task)) { NoneBlocked => {} @@ -445,7 +446,7 @@ impl<T> Buffer<T> { impl Queue { fn enqueue(&mut self, lock: &NativeMutex) { - let task: ~Task = Local::take(); + let task: Box<Task> = Local::take(); let mut node = Node { task: None, next: 0 as *mut Node, |
