about summary refs log tree commit diff
path: root/src/libstd/rt
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/rt
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/rt')
-rw-r--r--src/libstd/rt/args.rs11
-rw-r--r--src/libstd/rt/at_exit_imp.rs9
-rw-r--r--src/libstd/rt/backtrace.rs4
-rw-r--r--src/libstd/rt/local_heap.rs19
-rw-r--r--src/libstd/rt/local_ptr.rs34
-rw-r--r--src/libstd/rt/rtio.rs8
-rw-r--r--src/libstd/rt/task.rs22
-rw-r--r--src/libstd/rt/thread.rs21
-rw-r--r--src/libstd/rt/thread_local_storage.rs2
-rw-r--r--src/libstd/rt/unwind.rs11
10 files changed, 68 insertions, 73 deletions
diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs
index df0f1d8d449..95d0eabd336 100644
--- a/src/libstd/rt/args.rs
+++ b/src/libstd/rt/args.rs
@@ -40,7 +40,7 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
 #[cfg(not(test))] pub fn take() -> Option<Vec<~[u8]>> { imp::take() }
 #[cfg(test)]      pub fn take() -> Option<Vec<~[u8]>> {
     match realargs::take() {
-        realstd::option::Some(v) => Some(unsafe{ ::cast::transmute(v) }),
+        realstd::option::Some(v) => Some(unsafe{ ::mem::transmute(v) }),
         realstd::option::None => None,
     }
 }
@@ -49,13 +49,13 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
 ///
 /// It is an error if the arguments already exist.
 #[cfg(not(test))] pub fn put(args: Vec<~[u8]>) { imp::put(args) }
-#[cfg(test)]      pub fn put(args: Vec<~[u8]>) { realargs::put(unsafe { ::cast::transmute(args) }) }
+#[cfg(test)]      pub fn put(args: Vec<~[u8]>) { realargs::put(unsafe { ::mem::transmute(args) }) }
 
 /// Make a clone of the global arguments.
 #[cfg(not(test))] pub fn clone() -> Option<Vec<~[u8]>> { imp::clone() }
 #[cfg(test)]      pub fn clone() -> Option<Vec<~[u8]>> {
     match realargs::clone() {
-        realstd::option::Some(v) => Some(unsafe { ::cast::transmute(v) }),
+        realstd::option::Some(v) => Some(unsafe { ::mem::transmute(v) }),
         realstd::option::None => None,
     }
 }
@@ -64,10 +64,9 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
 #[cfg(target_os = "android")]
 #[cfg(target_os = "freebsd")]
 mod imp {
-    use cast;
     use clone::Clone;
-    use option::{Option, Some, None};
     use iter::Iterator;
+    use option::{Option, Some, None};
     use owned::Box;
     use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
     use mem;
@@ -120,7 +119,7 @@ mod imp {
     }
 
     fn get_global_ptr() -> *mut Option<Box<Vec<~[u8]>>> {
-        unsafe { cast::transmute(&global_args_ptr) }
+        unsafe { mem::transmute(&global_args_ptr) }
     }
 
     // Copied from `os`.
diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs
index 051bc494adc..c892a73d934 100644
--- a/src/libstd/rt/at_exit_imp.rs
+++ b/src/libstd/rt/at_exit_imp.rs
@@ -12,15 +12,14 @@
 //!
 //! Documentation can be found on the `rt::at_exit` function.
 
-use cast;
 use iter::Iterator;
 use kinds::Send;
 use mem;
 use option::{Some, None};
 use owned::Box;
 use ptr::RawPtr;
-use unstable::sync::Exclusive;
 use slice::OwnedVector;
+use unstable::sync::Exclusive;
 use vec::Vec;
 
 type Queue = Exclusive<Vec<proc():Send>>;
@@ -38,7 +37,7 @@ pub fn init() {
         rtassert!(!RUNNING);
         rtassert!(QUEUE.is_null());
         let state: Box<Queue> = box Exclusive::new(vec!());
-        QUEUE = cast::transmute(state);
+        QUEUE = mem::transmute(state);
     }
 }
 
@@ -46,7 +45,7 @@ pub fn push(f: proc():Send) {
     unsafe {
         rtassert!(!RUNNING);
         rtassert!(!QUEUE.is_null());
-        let state: &mut Queue = cast::transmute(QUEUE);
+        let state: &mut Queue = mem::transmute(QUEUE);
         let mut f = Some(f);
         state.with(|arr|  {
             arr.push(f.take_unwrap());
@@ -59,7 +58,7 @@ pub fn run() {
         rtassert!(!RUNNING);
         rtassert!(!QUEUE.is_null());
         RUNNING = true;
-        let state: Box<Queue> = cast::transmute(QUEUE);
+        let state: Box<Queue> = mem::transmute(QUEUE);
         QUEUE = 0 as *mut Queue;
         let mut vec = None;
         state.with(|arr| {
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index ee8041f6880..f4cb770544c 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -237,9 +237,9 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
 #[cfg(unix)]
 mod imp {
     use c_str::CString;
-    use cast;
     use io::{IoResult, IoError, Writer};
     use libc;
+    use mem;
     use option::{Some, None, Option};
     use result::{Ok, Err};
     use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
@@ -280,7 +280,7 @@ mod imp {
 
         extern fn trace_fn(ctx: *uw::_Unwind_Context,
                            arg: *libc::c_void) -> uw::_Unwind_Reason_Code {
-            let cx: &mut Context = unsafe { cast::transmute(arg) };
+            let cx: &mut Context = unsafe { mem::transmute(arg) };
             let ip = unsafe { uw::_Unwind_GetIP(ctx) as *libc::c_void };
             // dladdr() on osx gets whiny when we use FindEnclosingFunction, and
             // it appears to work fine without it, so we only use
diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs
index efc8072594b..5feec7fd9d2 100644
--- a/src/libstd/rt/local_heap.rs
+++ b/src/libstd/rt/local_heap.rs
@@ -10,18 +10,17 @@
 
 //! The local, garbage collected heap
 
-use cast;
 use iter::Iterator;
 use libc::{c_void, free};
 use mem;
 use ops::Drop;
 use option::{Option, None, Some};
-use ptr;
 use ptr::RawPtr;
+use ptr;
+use raw;
 use rt::libc_heap;
 use rt::local::Local;
 use rt::task::Task;
-use raw;
 use slice::{ImmutableVector, Vector};
 use vec::Vec;
 
@@ -63,7 +62,7 @@ impl LocalHeap {
         let alloc = self.memory_region.malloc(total_size);
         {
             // Make sure that we can't use `mybox` outside of this scope
-            let mybox: &mut Box = unsafe { cast::transmute(alloc) };
+            let mybox: &mut Box = unsafe { mem::transmute(alloc) };
             // Clear out this box, and move it to the front of the live
             // allocations list
             mybox.drop_glue = drop_glue;
@@ -85,7 +84,7 @@ impl LocalHeap {
         let new_box = self.memory_region.realloc(ptr, total_size);
         {
             // Fix links because we could have moved around
-            let mybox: &mut Box = unsafe { cast::transmute(new_box) };
+            let mybox: &mut Box = unsafe { mem::transmute(new_box) };
             if !mybox.prev.is_null() {
                 unsafe { (*mybox.prev).next = new_box; }
             }
@@ -103,7 +102,7 @@ impl LocalHeap {
     pub fn free(&mut self, alloc: *mut Box) {
         {
             // Make sure that we can't use `mybox` outside of this scope
-            let mybox: &mut Box = unsafe { cast::transmute(alloc) };
+            let mybox: &mut Box = unsafe { mem::transmute(alloc) };
 
             // Unlink it from the linked list
             if !mybox.prev.is_null() {
@@ -167,7 +166,7 @@ impl AllocHeader {
     fn update_size(&mut self, _size: u32) {}
 
     fn as_box(&mut self) -> *mut Box {
-        let myaddr: uint = unsafe { cast::transmute(self) };
+        let myaddr: uint = unsafe { mem::transmute(self) };
         (myaddr + AllocHeader::size()) as *mut Box
     }
 
@@ -191,7 +190,7 @@ impl MemoryRegion {
             libc_heap::malloc_raw(total_size) as *AllocHeader
         };
 
-        let alloc: &mut AllocHeader = unsafe { cast::transmute(alloc) };
+        let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) };
         alloc.init(size as u32);
         self.claim(alloc);
         self.live_allocations += 1;
@@ -210,7 +209,7 @@ impl MemoryRegion {
             libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *AllocHeader
         };
 
-        let alloc: &mut AllocHeader = unsafe { cast::transmute(alloc) };
+        let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) };
         alloc.assert_sane();
         alloc.update_size(size as u32);
         self.update(alloc, orig_alloc as *AllocHeader);
@@ -223,7 +222,7 @@ impl MemoryRegion {
         let alloc = AllocHeader::from(alloc);
         unsafe {
             (*alloc).assert_sane();
-            self.release(cast::transmute(alloc));
+            self.release(mem::transmute(alloc));
             rtassert!(self.live_allocations > 0);
             self.live_allocations -= 1;
             free(alloc as *mut c_void)
diff --git a/src/libstd/rt/local_ptr.rs b/src/libstd/rt/local_ptr.rs
index 39c0d9a5482..1197a4ccbe6 100644
--- a/src/libstd/rt/local_ptr.rs
+++ b/src/libstd/rt/local_ptr.rs
@@ -17,7 +17,7 @@
 
 #![allow(dead_code)]
 
-use cast;
+use mem;
 use ops::{Drop, Deref, DerefMut};
 use owned::Box;
 use ptr::RawPtr;
@@ -44,7 +44,7 @@ impl<T> Drop for Borrowed<T> {
             if self.val.is_null() {
                 rtabort!("Aiee, returning null borrowed object!");
             }
-            let val: Box<T> = cast::transmute(self.val);
+            let val: Box<T> = mem::transmute(self.val);
             put::<T>(val);
             rtassert!(exists());
         }
@@ -71,7 +71,7 @@ impl<T> DerefMut<T> for Borrowed<T> {
 /// Does not validate the pointer type.
 #[inline]
 pub unsafe fn borrow<T>() -> Borrowed<T> {
-    let val: *() = cast::transmute(take::<T>());
+    let val: *() = mem::transmute(take::<T>());
     Borrowed {
         val: val,
     }
@@ -83,7 +83,7 @@ pub unsafe fn borrow<T>() -> Borrowed<T> {
 /// it wherever possible.
 #[cfg(not(windows), not(target_os = "android"))]
 pub mod compiled {
-    use cast;
+    use mem;
     use option::{Option, Some, None};
     use owned::Box;
     use ptr::RawPtr;
@@ -157,7 +157,7 @@ pub mod compiled {
     /// Does not validate the pointer type.
     #[inline(never)] // see comments above
     pub unsafe fn put<T>(sched: Box<T>) {
-        RT_TLS_PTR = cast::transmute(sched)
+        RT_TLS_PTR = mem::transmute(sched)
     }
 
     /// Take ownership of a pointer from thread-local storage.
@@ -169,9 +169,9 @@ pub mod compiled {
     pub unsafe fn take<T>() -> Box<T> {
         let ptr = RT_TLS_PTR;
         rtassert!(!ptr.is_null());
-        let ptr: Box<T> = cast::transmute(ptr);
+        let ptr: Box<T> = mem::transmute(ptr);
         // can't use `as`, due to type not matching with `cfg(test)`
-        RT_TLS_PTR = cast::transmute(0);
+        RT_TLS_PTR = mem::transmute(0);
         ptr
     }
 
@@ -186,9 +186,9 @@ pub mod compiled {
         if ptr.is_null() {
             None
         } else {
-            let ptr: Box<T> = cast::transmute(ptr);
+            let ptr: Box<T> = mem::transmute(ptr);
             // can't use `as`, due to type not matching with `cfg(test)`
-            RT_TLS_PTR = cast::transmute(0);
+            RT_TLS_PTR = mem::transmute(0);
             Some(ptr)
         }
     }
@@ -201,7 +201,7 @@ pub mod compiled {
     /// Leaves the old pointer in TLS for speed.
     #[inline(never)] // see comments above
     pub unsafe fn unsafe_take<T>() -> Box<T> {
-        cast::transmute(RT_TLS_PTR)
+        mem::transmute(RT_TLS_PTR)
     }
 
     /// Check whether there is a thread-local pointer installed.
@@ -234,11 +234,11 @@ pub mod compiled {
 /// implementation uses the `thread_local_storage` module to provide a
 /// thread-local value.
 pub mod native {
-    use cast;
+    use mem;
     use option::{Option, Some, None};
     use owned::Box;
-    use ptr;
     use ptr::RawPtr;
+    use ptr;
     use tls = rt::thread_local_storage;
 
     static mut RT_TLS_KEY: tls::Key = -1;
@@ -264,7 +264,7 @@ pub mod native {
     #[inline]
     pub unsafe fn put<T>(sched: Box<T>) {
         let key = tls_key();
-        let void_ptr: *mut u8 = cast::transmute(sched);
+        let void_ptr: *mut u8 = mem::transmute(sched);
         tls::set(key, void_ptr);
     }
 
@@ -280,7 +280,7 @@ pub mod native {
         if void_ptr.is_null() {
             rtabort!("thread-local pointer is null. bogus!");
         }
-        let ptr: Box<T> = cast::transmute(void_ptr);
+        let ptr: Box<T> = mem::transmute(void_ptr);
         tls::set(key, ptr::mut_null());
         return ptr;
     }
@@ -298,7 +298,7 @@ pub mod native {
                 if void_ptr.is_null() {
                     None
                 } else {
-                    let ptr: Box<T> = cast::transmute(void_ptr);
+                    let ptr: Box<T> = mem::transmute(void_ptr);
                     tls::set(key, ptr::mut_null());
                     Some(ptr)
                 }
@@ -320,7 +320,7 @@ pub mod native {
         if void_ptr.is_null() {
             rtabort!("thread-local pointer is null. bogus!");
         }
-        let ptr: Box<T> = cast::transmute(void_ptr);
+        let ptr: Box<T> = mem::transmute(void_ptr);
         return ptr;
     }
 
@@ -398,7 +398,7 @@ pub mod native {
     pub fn maybe_tls_key() -> Option<tls::Key> {
         use realstd;
         unsafe {
-            cast::transmute(realstd::rt::shouldnt_be_public::maybe_tls_key())
+            mem::transmute(realstd::rt::shouldnt_be_public::maybe_tls_key())
         }
     }
 }
diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs
index ccde8d9c96a..bc3a483f30d 100644
--- a/src/libstd/rt/rtio.rs
+++ b/src/libstd/rt/rtio.rs
@@ -11,11 +11,11 @@
 //! The EventLoop and internal synchronous I/O interface.
 
 use c_str::CString;
-use cast;
 use comm::{Sender, Receiver};
+use kinds::Send;
 use libc::c_int;
 use libc;
-use kinds::Send;
+use mem;
 use ops::Drop;
 use option::{Option, Some, None};
 use owned::Box;
@@ -118,7 +118,7 @@ impl<'a> LocalIo<'a> {
         // in order to have what is likely a static lifetime (bad).
         let mut t: Box<Task> = Local::take();
         let ret = t.local_io().map(|t| {
-            unsafe { cast::transmute_copy(&t) }
+            unsafe { mem::transmute_copy(&t) }
         });
         Local::put(t);
         return ret;
@@ -143,7 +143,7 @@ impl<'a> LocalIo<'a> {
         // FIXME(pcwalton): I think this is actually sound? Could borrow check
         // allow this safely?
         unsafe {
-            cast::transmute_copy(&self.factory)
+            mem::transmute_copy(&self.factory)
         }
     }
 }
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index 77bcb7b9904..cd0445056b2 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -14,7 +14,6 @@
 //! to implement this.
 
 use any::AnyOwnExt;
-use cast;
 use cleanup;
 use clone::Clone;
 use comm::Sender;
@@ -22,6 +21,7 @@ use io::Writer;
 use iter::{Iterator, Take};
 use kinds::Send;
 use local_data;
+use mem;
 use ops::Drop;
 use option::{Option, Some, None};
 use owned::Box;
@@ -116,7 +116,7 @@ impl Task {
         // Unsafely get a handle to the task so we can continue to use it after
         // putting it in tls (so we can invoke the unwinder).
         let handle: *mut Task = unsafe {
-            *cast::transmute::<&Box<Task>, &*mut Task>(&self)
+            *mem::transmute::<&Box<Task>, &*mut Task>(&self)
         };
         Local::put(self);
 
@@ -222,13 +222,13 @@ impl Task {
         //      crops up.
         unsafe {
             let imp = self.imp.take_unwrap();
-            let &(vtable, _): &(uint, uint) = cast::transmute(&imp);
+            let &(vtable, _): &(uint, uint) = mem::transmute(&imp);
             match imp.wrap().move::<T>() {
                 Ok(t) => Some(t),
                 Err(t) => {
-                    let (_, obj): (uint, uint) = cast::transmute(t);
+                    let (_, obj): (uint, uint) = mem::transmute(t);
                     let obj: Box<Runtime:Send> =
-                        cast::transmute((vtable, obj));
+                        mem::transmute((vtable, obj));
                     self.put_runtime(obj);
                     None
                 }
@@ -317,7 +317,7 @@ impl BlockedTask {
             Shared(arc) => unsafe {
                 match (*arc.get()).swap(0, SeqCst) {
                     0 => None,
-                    n => Some(cast::transmute(n)),
+                    n => Some(mem::transmute(n)),
                 }
             }
         }
@@ -343,7 +343,7 @@ impl BlockedTask {
     pub fn make_selectable(self, num_handles: uint) -> Take<BlockedTasks> {
         let arc = match self {
             Owned(task) => {
-                let flag = unsafe { AtomicUint::new(cast::transmute(task)) };
+                let flag = unsafe { AtomicUint::new(mem::transmute(task)) };
                 UnsafeArc::new(flag)
             }
             Shared(arc) => arc.clone(),
@@ -357,12 +357,12 @@ impl BlockedTask {
     pub unsafe fn cast_to_uint(self) -> uint {
         match self {
             Owned(task) => {
-                let blocked_task_ptr: uint = cast::transmute(task);
+                let blocked_task_ptr: uint = mem::transmute(task);
                 rtassert!(blocked_task_ptr & 0x1 == 0);
                 blocked_task_ptr
             }
             Shared(arc) => {
-                let blocked_task_ptr: uint = cast::transmute(box arc);
+                let blocked_task_ptr: uint = mem::transmute(box arc);
                 rtassert!(blocked_task_ptr & 0x1 == 0);
                 blocked_task_ptr | 0x1
             }
@@ -374,10 +374,10 @@ impl BlockedTask {
     #[inline]
     pub unsafe fn cast_from_uint(blocked_task_ptr: uint) -> BlockedTask {
         if blocked_task_ptr & 0x1 == 0 {
-            Owned(cast::transmute(blocked_task_ptr))
+            Owned(mem::transmute(blocked_task_ptr))
         } else {
             let ptr: Box<UnsafeArc<AtomicUint>> =
-                cast::transmute(blocked_task_ptr & !1);
+                mem::transmute(blocked_task_ptr & !1);
             Shared(*ptr)
         }
     }
diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs
index 89d44473a94..4f0d7d35ce8 100644
--- a/src/libstd/rt/thread.rs
+++ b/src/libstd/rt/thread.rs
@@ -17,9 +17,9 @@
 #![allow(non_camel_case_types)]
 #![allow(unsigned_negate)]
 
-use cast;
 use kinds::Send;
 use libc;
+use mem;
 use ops::Drop;
 use option::{Option, Some, None};
 use owned::Box;
@@ -46,9 +46,9 @@ extern fn thread_start(main: *libc::c_void) -> imp::rust_thread_return {
     use rt::stack;
     unsafe {
         stack::record_stack_bounds(0, uint::MAX);
-        let f: Box<proc()> = cast::transmute(main);
+        let f: Box<proc()> = mem::transmute(main);
         (*f)();
-        cast::transmute(0 as imp::rust_thread_return)
+        mem::transmute(0 as imp::rust_thread_return)
     }
 }
 
@@ -83,7 +83,7 @@ impl Thread<()> {
         // so.
         let packet = box None;
         let packet2: *mut Option<T> = unsafe {
-            *cast::transmute::<&Box<Option<T>>, **mut Option<T>>(&packet)
+            *mem::transmute::<&Box<Option<T>>, **mut Option<T>>(&packet)
         };
         let main = proc() unsafe { *packet2 = Some(main()); };
         let native = unsafe { imp::create(stack, box main) };
@@ -146,7 +146,7 @@ impl<T: Send> Drop for Thread<T> {
 
 #[cfg(windows)]
 mod imp {
-    use cast;
+    use mem;
     use cmp;
     use kinds::Send;
     use libc;
@@ -161,7 +161,7 @@ mod imp {
     pub type rust_thread_return = DWORD;
 
     pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread {
-        let arg: *mut libc::c_void = cast::transmute(p);
+        let arg: *mut libc::c_void = mem::transmute(p);
         // FIXME On UNIX, we guard against stack sizes that are too small but
         // that's because pthreads enforces that stacks are at least
         // PTHREAD_STACK_MIN bytes big.  Windows has no such lower limit, it's
@@ -177,7 +177,7 @@ mod imp {
 
         if ret as uint == 0 {
             // be sure to not leak the closure
-            let _p: Box<proc():Send> = cast::transmute(arg);
+            let _p: Box<proc():Send> = mem::transmute(arg);
             fail!("failed to spawn native thread: {}", os::last_os_error());
         }
         return ret;
@@ -213,7 +213,6 @@ mod imp {
 
 #[cfg(unix)]
 mod imp {
-    use cast;
     use cmp;
     use kinds::Send;
     use libc::consts::os::posix01::{PTHREAD_CREATE_JOINABLE, PTHREAD_STACK_MIN};
@@ -254,13 +253,13 @@ mod imp {
             },
         };
 
-        let arg: *libc::c_void = cast::transmute(p);
+        let arg: *libc::c_void = mem::transmute(p);
         let ret = pthread_create(&mut native, &attr, super::thread_start, arg);
         assert_eq!(pthread_attr_destroy(&mut attr), 0);
 
         if ret != 0 {
             // be sure to not leak the closure
-            let _p: Box<proc():Send> = cast::transmute(arg);
+            let _p: Box<proc():Send> = mem::transmute(arg);
             fail!("failed to spawn native thread: {}", os::last_os_error());
         }
         native
@@ -302,7 +301,7 @@ mod imp {
         if __pthread_get_minstack.is_null() {
             PTHREAD_STACK_MIN
         } else {
-            unsafe { cast::transmute::<*(), F>(__pthread_get_minstack)(attr) }
+            unsafe { mem::transmute::<*(), F>(__pthread_get_minstack)(attr) }
         }
     }
 
diff --git a/src/libstd/rt/thread_local_storage.rs b/src/libstd/rt/thread_local_storage.rs
index 77062068636..2551c89972e 100644
--- a/src/libstd/rt/thread_local_storage.rs
+++ b/src/libstd/rt/thread_local_storage.rs
@@ -95,7 +95,7 @@ extern "system" {
 
 #[test]
 fn tls_smoke_test() {
-    use cast::transmute;
+    use mem::transmute;
     unsafe {
         let mut key = 0;
         let value = box 20;
diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs
index 5f3731eb819..e10e0716f67 100644
--- a/src/libstd/rt/unwind.rs
+++ b/src/libstd/rt/unwind.rs
@@ -58,8 +58,8 @@
 // Currently Rust uses unwind runtime provided by libgcc.
 
 use any::{Any, AnyRefExt};
-use cast;
 use fmt;
+use intrinsics;
 use kinds::Send;
 use mem;
 use option::{Some, None, Option};
@@ -72,7 +72,6 @@ use rt::local::Local;
 use rt::task::Task;
 use str::Str;
 use task::TaskResult;
-use intrinsics;
 
 use uw = rt::libunwind;
 
@@ -98,7 +97,7 @@ impl Unwinder {
         use libc::{c_void};
 
         unsafe {
-            let closure: Closure = cast::transmute(f);
+            let closure: Closure = mem::transmute(f);
             let ep = rust_try(try_fn, closure.code as *c_void,
                               closure.env as *c_void);
             if !ep.is_null() {
@@ -109,7 +108,7 @@ impl Unwinder {
 
         extern fn try_fn(code: *c_void, env: *c_void) {
             unsafe {
-                let closure: || = cast::transmute(Closure {
+                let closure: || = mem::transmute(Closure {
                     code: code as *(),
                     env: env as *(),
                 });
@@ -146,7 +145,7 @@ impl Unwinder {
                     exception_cleanup: exception_cleanup,
                     private: [0, ..uw::unwinder_private_data_size],
                 };
-                let error = uw::_Unwind_RaiseException(cast::transmute(exception));
+                let error = uw::_Unwind_RaiseException(mem::transmute(exception));
                 rtabort!("Could not unwind stack, error = {}", error as int)
             }
 
@@ -155,7 +154,7 @@ impl Unwinder {
                 rtdebug!("exception_cleanup()");
                 unsafe {
                     let _: Box<uw::_Unwind_Exception> =
-                        cast::transmute(exception);
+                        mem::transmute(exception);
                 }
             }
         }