about summary refs log tree commit diff
path: root/src/libstd/sync/deque.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-05-11 02:26:43 -0700
committerbors <bors@rust-lang.org>2014-05-11 02:26:43 -0700
commitfb569fd3986247ac3ce6a498e52a82bb4c535824 (patch)
tree97bea161eb7fff71a0e9a484aa9f190dbe037f58 /src/libstd/sync/deque.rs
parentadb8b0b230d5e5c79b4f873825b3d3cff8d1bc8f (diff)
parentf94d671bfae5d8e9a4a4add310b1c40af0ab62a6 (diff)
downloadrust-fb569fd3986247ac3ce6a498e52a82bb4c535824.tar.gz
rust-fb569fd3986247ac3ce6a498e52a82bb4c535824.zip
auto merge of #14069 : alexcrichton/rust/cast-module, r=brson
This commit revisits the `cast` module in libcore and libstd, and scrutinizes
all functions inside of it. The result was to remove the `cast` module entirely,
folding all functionality into the `mem` module. Specifically, this is the fate
of each function in the `cast` module.

* transmute - This function was moved to `mem`, but it is now marked as
              #[unstable]. This is due to planned changes to the `transmute`
              function and how it can be invoked (see the #[unstable] comment).
              For more information, see RFC 5 and #12898

* transmute_copy - This function was moved to `mem`, with clarification that is
                   is not an error to invoke it with T/U that are different
                   sizes, but rather that it is strongly discouraged. This
                   function is now #[stable]

* forget - This function was moved to `mem` and marked #[stable]

* bump_box_refcount - This function was removed due to the deprecation of
                      managed boxes as well as its questionable utility.

* transmute_mut - This function was previously deprecated, and removed as part
                  of this commit.

* transmute_mut_unsafe - This function doesn't serve much of a purpose when it
                         can be achieved with an `as` in safe code, so it was
                         removed.

* transmute_lifetime - This function was removed because it is likely a strong
                       indication that code is incorrect in the first place.

* transmute_mut_lifetime - This function was removed for the same reasons as
                           `transmute_lifetime`

* copy_lifetime - This function was moved to `mem`, but it is marked
                  `#[unstable]` now due to the likelihood of being removed in
                  the future if it is found to not be very useful.

* copy_mut_lifetime - This function was also moved to `mem`, but had the same
                      treatment as `copy_lifetime`.

* copy_lifetime_vec - This function was removed because it is not used today,
                      and its existence is not necessary with DST
                      (copy_lifetime will suffice).

In summary, the cast module was stripped down to these functions, and then the
functions were moved to the `mem` module.

    transmute - #[unstable]
    transmute_copy - #[stable]
    forget - #[stable]
    copy_lifetime - #[unstable]
    copy_mut_lifetime - #[unstable]
Diffstat (limited to 'src/libstd/sync/deque.rs')
-rw-r--r--src/libstd/sync/deque.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/libstd/sync/deque.rs b/src/libstd/sync/deque.rs
index 8dfd691e6ff..175bb03d262 100644
--- a/src/libstd/sync/deque.rs
+++ b/src/libstd/sync/deque.rs
@@ -48,7 +48,6 @@
 // FIXME: all atomic operations in this module use a SeqCst ordering. That is
 //      probably overkill
 
-use cast;
 use clone::Clone;
 use iter::{range, Iterator};
 use kinds::Send;
@@ -57,12 +56,12 @@ use mem;
 use ops::Drop;
 use option::{Option, Some, None};
 use owned::Box;
-use ptr;
 use ptr::RawPtr;
+use ptr;
+use slice::ImmutableVector;
 use sync::arc::UnsafeArc;
 use sync::atomics::{AtomicInt, AtomicPtr, SeqCst};
 use unstable::sync::Exclusive;
-use slice::ImmutableVector;
 use vec::Vec;
 
 // Once the queue is less than 1/K full, then it will be downsized. Note that
@@ -230,7 +229,7 @@ impl<T: Send> Deque<T> {
         Deque {
             bottom: AtomicInt::new(0),
             top: AtomicInt::new(0),
-            array: AtomicPtr::new(unsafe { cast::transmute(buf) }),
+            array: AtomicPtr::new(unsafe { mem::transmute(buf) }),
             pool: pool,
         }
     }
@@ -272,7 +271,7 @@ impl<T: Send> Deque<T> {
             return Some(data);
         } else {
             self.bottom.store(t + 1, SeqCst);
-            cast::forget(data); // someone else stole this value
+            mem::forget(data); // someone else stole this value
             return None;
         }
     }
@@ -294,7 +293,7 @@ impl<T: Send> Deque<T> {
         if self.top.compare_and_swap(t, t + 1, SeqCst) == t {
             Data(data)
         } else {
-            cast::forget(data); // someone else stole this value
+            mem::forget(data); // someone else stole this value
             Abort
         }
     }
@@ -315,7 +314,7 @@ impl<T: Send> Deque<T> {
     // continue to be read after we flag this buffer for reclamation.
     unsafe fn swap_buffer(&mut self, b: int, old: *mut Buffer<T>,
                           buf: Buffer<T>) -> *mut Buffer<T> {
-        let newbuf: *mut Buffer<T> = cast::transmute(box buf);
+        let newbuf: *mut Buffer<T> = mem::transmute(box buf);
         self.array.store(newbuf, SeqCst);
         let ss = (*newbuf).size();
         self.bottom.store(b + ss, SeqCst);
@@ -323,7 +322,7 @@ impl<T: Send> Deque<T> {
         if self.top.compare_and_swap(t, t + ss, SeqCst) != t {
             self.bottom.store(b, SeqCst);
         }
-        self.pool.free(cast::transmute(old));
+        self.pool.free(mem::transmute(old));
         return newbuf;
     }
 }
@@ -340,7 +339,7 @@ impl<T: Send> Drop for Deque<T> {
         for i in range(t, b) {
             let _: T = unsafe { (*a).get(i) };
         }
-        self.pool.free(unsafe { cast::transmute(a) });
+        self.pool.free(unsafe { mem::transmute(a) });
     }
 }
 
@@ -373,7 +372,7 @@ impl<T: Send> Buffer<T> {
     unsafe fn put(&mut self, i: int, t: T) {
         let ptr = self.storage.offset(i & self.mask());
         ptr::copy_nonoverlapping_memory(ptr as *mut T, &t as *T, 1);
-        cast::forget(t);
+        mem::forget(t);
     }
 
     // Again, unsafe because this has incredibly dubious ownership violations.
@@ -400,7 +399,7 @@ mod tests {
     use prelude::*;
     use super::{Data, BufferPool, Abort, Empty, Worker, Stealer};
 
-    use cast;
+    use mem;
     use owned::Box;
     use rt::thread::Thread;
     use rand;
@@ -607,7 +606,7 @@ mod tests {
             let s = s.clone();
             let unique_box = box AtomicUint::new(0);
             let thread_box = unsafe {
-                *cast::transmute::<&Box<AtomicUint>,
+                *mem::transmute::<&Box<AtomicUint>,
                                    **mut AtomicUint>(&unique_box)
             };
             (Thread::start(proc() {