about summary refs log tree commit diff
path: root/src/libstd/rt/local_ptr.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-05-05 18:56:44 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-05-06 23:12:54 -0700
commit090040bf4037a094e50b03d79e4baf5cd89c912b (patch)
tree27fa91d623889d59260d3db167abdfa8c4288849 /src/libstd/rt/local_ptr.rs
parent24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff)
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/rt/local_ptr.rs')
-rw-r--r--src/libstd/rt/local_ptr.rs33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/libstd/rt/local_ptr.rs b/src/libstd/rt/local_ptr.rs
index f60cfa23e81..39c0d9a5482 100644
--- a/src/libstd/rt/local_ptr.rs
+++ b/src/libstd/rt/local_ptr.rs
@@ -10,7 +10,7 @@
 
 //! Access to a single thread-local pointer.
 //!
-//! The runtime will use this for storing ~Task.
+//! The runtime will use this for storing Box<Task>.
 //!
 //! FIXME: Add runtime checks for usage of inconsistent pointer types.
 //! and for overwriting an existing pointer.
@@ -19,6 +19,7 @@
 
 use cast;
 use ops::{Drop, Deref, DerefMut};
+use owned::Box;
 use ptr::RawPtr;
 
 #[cfg(windows)]               // mingw-w32 doesn't like thread_local things
@@ -43,7 +44,7 @@ impl<T> Drop for Borrowed<T> {
             if self.val.is_null() {
                 rtabort!("Aiee, returning null borrowed object!");
             }
-            let val: ~T = cast::transmute(self.val);
+            let val: Box<T> = cast::transmute(self.val);
             put::<T>(val);
             rtassert!(exists());
         }
@@ -84,6 +85,7 @@ pub unsafe fn borrow<T>() -> Borrowed<T> {
 pub mod compiled {
     use cast;
     use option::{Option, Some, None};
+    use owned::Box;
     use ptr::RawPtr;
 
     #[cfg(test)]
@@ -154,7 +156,7 @@ pub mod compiled {
     ///
     /// Does not validate the pointer type.
     #[inline(never)] // see comments above
-    pub unsafe fn put<T>(sched: ~T) {
+    pub unsafe fn put<T>(sched: Box<T>) {
         RT_TLS_PTR = cast::transmute(sched)
     }
 
@@ -164,10 +166,10 @@ pub mod compiled {
     ///
     /// Does not validate the pointer type.
     #[inline(never)] // see comments above
-    pub unsafe fn take<T>() -> ~T {
+    pub unsafe fn take<T>() -> Box<T> {
         let ptr = RT_TLS_PTR;
         rtassert!(!ptr.is_null());
-        let ptr: ~T = cast::transmute(ptr);
+        let ptr: Box<T> = cast::transmute(ptr);
         // can't use `as`, due to type not matching with `cfg(test)`
         RT_TLS_PTR = cast::transmute(0);
         ptr
@@ -179,12 +181,12 @@ pub mod compiled {
     ///
     /// Does not validate the pointer type.
     #[inline(never)] // see comments above
-    pub unsafe fn try_take<T>() -> Option<~T> {
+    pub unsafe fn try_take<T>() -> Option<Box<T>> {
         let ptr = RT_TLS_PTR;
         if ptr.is_null() {
             None
         } else {
-            let ptr: ~T = cast::transmute(ptr);
+            let ptr: Box<T> = cast::transmute(ptr);
             // can't use `as`, due to type not matching with `cfg(test)`
             RT_TLS_PTR = cast::transmute(0);
             Some(ptr)
@@ -198,7 +200,7 @@ pub mod compiled {
     /// Does not validate the pointer type.
     /// Leaves the old pointer in TLS for speed.
     #[inline(never)] // see comments above
-    pub unsafe fn unsafe_take<T>() -> ~T {
+    pub unsafe fn unsafe_take<T>() -> Box<T> {
         cast::transmute(RT_TLS_PTR)
     }
 
@@ -234,6 +236,7 @@ pub mod compiled {
 pub mod native {
     use cast;
     use option::{Option, Some, None};
+    use owned::Box;
     use ptr;
     use ptr::RawPtr;
     use tls = rt::thread_local_storage;
@@ -259,7 +262,7 @@ pub mod native {
     ///
     /// Does not validate the pointer type.
     #[inline]
-    pub unsafe fn put<T>(sched: ~T) {
+    pub unsafe fn put<T>(sched: Box<T>) {
         let key = tls_key();
         let void_ptr: *mut u8 = cast::transmute(sched);
         tls::set(key, void_ptr);
@@ -271,13 +274,13 @@ pub mod native {
     ///
     /// Does not validate the pointer type.
     #[inline]
-    pub unsafe fn take<T>() -> ~T {
+    pub unsafe fn take<T>() -> Box<T> {
         let key = tls_key();
         let void_ptr: *mut u8 = tls::get(key);
         if void_ptr.is_null() {
             rtabort!("thread-local pointer is null. bogus!");
         }
-        let ptr: ~T = cast::transmute(void_ptr);
+        let ptr: Box<T> = cast::transmute(void_ptr);
         tls::set(key, ptr::mut_null());
         return ptr;
     }
@@ -288,14 +291,14 @@ pub mod native {
     ///
     /// Does not validate the pointer type.
     #[inline]
-    pub unsafe fn try_take<T>() -> Option<~T> {
+    pub unsafe fn try_take<T>() -> Option<Box<T>> {
         match maybe_tls_key() {
             Some(key) => {
                 let void_ptr: *mut u8 = tls::get(key);
                 if void_ptr.is_null() {
                     None
                 } else {
-                    let ptr: ~T = cast::transmute(void_ptr);
+                    let ptr: Box<T> = cast::transmute(void_ptr);
                     tls::set(key, ptr::mut_null());
                     Some(ptr)
                 }
@@ -311,13 +314,13 @@ pub mod native {
     /// Does not validate the pointer type.
     /// Leaves the old pointer in TLS for speed.
     #[inline]
-    pub unsafe fn unsafe_take<T>() -> ~T {
+    pub unsafe fn unsafe_take<T>() -> Box<T> {
         let key = tls_key();
         let void_ptr: *mut u8 = tls::get(key);
         if void_ptr.is_null() {
             rtabort!("thread-local pointer is null. bogus!");
         }
-        let ptr: ~T = cast::transmute(void_ptr);
+        let ptr: Box<T> = cast::transmute(void_ptr);
         return ptr;
     }