about summary refs log tree commit diff
path: root/src/libstd
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
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')
-rw-r--r--src/libstd/ascii.rs32
-rw-r--r--src/libstd/c_str.rs23
-rw-r--r--src/libstd/c_vec.rs6
-rw-r--r--src/libstd/comm/select.rs12
-rw-r--r--src/libstd/comm/sync.rs3
-rw-r--r--src/libstd/fmt/mod.rs22
-rw-r--r--src/libstd/hash/mod.rs6
-rw-r--r--src/libstd/io/extensions.rs4
-rw-r--r--src/libstd/io/mod.rs22
-rw-r--r--src/libstd/io/net/udp.rs1
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/libstd/local_data.rs8
-rw-r--r--src/libstd/num/f32.rs10
-rw-r--r--src/libstd/num/f64.rs8
-rw-r--r--src/libstd/path/windows.rs8
-rw-r--r--src/libstd/rc.rs2
-rw-r--r--src/libstd/repr.rs4
-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
-rw-r--r--src/libstd/slice.rs9
-rw-r--r--src/libstd/str.rs32
-rw-r--r--src/libstd/strbuf.rs6
-rw-r--r--src/libstd/sync/arc.rs6
-rw-r--r--src/libstd/sync/atomics.rs20
-rw-r--r--src/libstd/sync/deque.rs23
-rw-r--r--src/libstd/sync/mpsc_queue.rs8
-rw-r--r--src/libstd/sync/spsc_queue.rs8
-rw-r--r--src/libstd/unstable/dynamic_lib.rs4
-rw-r--r--src/libstd/vec.rs82
37 files changed, 258 insertions, 253 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index f45ec8a6742..e087b3d1774 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -10,18 +10,18 @@
 
 //! Operations on ASCII strings and characters
 
-use to_str::{IntoStr};
-use str;
-use str::Str;
-use str::{StrAllocating, StrSlice};
-use str::OwnedStr;
 use container::Container;
-use cast;
 use fmt;
 use iter::Iterator;
+use mem;
+use option::{Option, Some, None};
 use slice::{ImmutableVector, MutableVector, Vector};
+use str::OwnedStr;
+use str::Str;
+use str::{StrAllocating, StrSlice};
+use str;
+use to_str::{IntoStr};
 use vec::Vec;
-use option::{Option, Some, None};
 
 /// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.
 #[deriving(Clone, Eq, Ord, TotalOrd, TotalEq, Hash)]
@@ -162,7 +162,7 @@ pub trait AsciiCast<T> {
 impl<'a> AsciiCast<&'a[Ascii]> for &'a [u8] {
     #[inline]
     unsafe fn to_ascii_nocheck(&self) -> &'a[Ascii] {
-        cast::transmute(*self)
+        mem::transmute(*self)
     }
 
     #[inline]
@@ -177,7 +177,7 @@ impl<'a> AsciiCast<&'a[Ascii]> for &'a [u8] {
 impl<'a> AsciiCast<&'a [Ascii]> for &'a str {
     #[inline]
     unsafe fn to_ascii_nocheck(&self) -> &'a [Ascii] {
-        cast::transmute(*self)
+        mem::transmute(*self)
     }
 
     #[inline]
@@ -245,7 +245,7 @@ impl OwnedAsciiCast for ~[u8] {
 
     #[inline]
     unsafe fn into_ascii_nocheck(self) -> Vec<Ascii> {
-        cast::transmute(Vec::from_slice(self.as_slice()))
+        mem::transmute(Vec::from_slice(self.as_slice()))
     }
 }
 
@@ -257,7 +257,7 @@ impl OwnedAsciiCast for ~str {
 
     #[inline]
     unsafe fn into_ascii_nocheck(self) -> Vec<Ascii> {
-        let v: ~[u8] = cast::transmute(self);
+        let v: ~[u8] = mem::transmute(self);
         v.into_ascii_nocheck()
     }
 }
@@ -270,7 +270,7 @@ impl OwnedAsciiCast for Vec<u8> {
 
     #[inline]
     unsafe fn into_ascii_nocheck(self) -> Vec<Ascii> {
-        cast::transmute(self)
+        mem::transmute(self)
     }
 }
 
@@ -293,7 +293,7 @@ pub trait AsciiStr {
 impl<'a> AsciiStr for &'a [Ascii] {
     #[inline]
     fn as_str_ascii<'a>(&'a self) -> &'a str {
-        unsafe { cast::transmute(*self) }
+        unsafe { mem::transmute(*self) }
     }
 
     #[inline]
@@ -315,7 +315,7 @@ impl<'a> AsciiStr for &'a [Ascii] {
 impl IntoStr for ~[Ascii] {
     #[inline]
     fn into_str(self) -> ~str {
-        unsafe { cast::transmute(self) }
+        unsafe { mem::transmute(self) }
     }
 }
 
@@ -323,7 +323,7 @@ impl IntoStr for Vec<Ascii> {
     #[inline]
     fn into_str(self) -> ~str {
         unsafe {
-            let s: &str = cast::transmute(self.as_slice());
+            let s: &str = mem::transmute(self.as_slice());
             s.to_owned()
         }
     }
@@ -337,7 +337,7 @@ pub trait IntoBytes {
 
 impl IntoBytes for Vec<Ascii> {
     fn into_bytes(self) -> Vec<u8> {
-        unsafe { cast::transmute(self) }
+        unsafe { mem::transmute(self) }
     }
 }
 
diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs
index b33d211aa19..0885a7af00b 100644
--- a/src/libstd/c_str.rs
+++ b/src/libstd/c_str.rs
@@ -65,24 +65,23 @@ fn main() {
 
 */
 
-use cast;
+use clone::Clone;
+use cmp::Eq;
 use container::Container;
 use iter::{Iterator, range};
-use libc;
 use kinds::marker;
-use ops::Drop;
-use cmp::Eq;
-use clone::Clone;
+use libc;
 use mem;
+use ops::Drop;
 use option::{Option, Some, None};
 use ptr::RawPtr;
 use ptr;
-use str::StrSlice;
-use str;
+use raw::Slice;
+use rt::libc_heap::malloc_raw;
 use slice::{ImmutableVector, MutableVector};
 use slice;
-use rt::libc_heap::malloc_raw;
-use raw::Slice;
+use str::StrSlice;
+use str;
 
 /// The representation of a C String.
 ///
@@ -154,7 +153,7 @@ impl CString {
     /// Fails if the CString is null.
     pub fn with_mut_ref<T>(&mut self, f: |*mut libc::c_char| -> T) -> T {
         if self.buf.is_null() { fail!("CString is null!"); }
-        f(unsafe { cast::transmute_mut_unsafe(self.buf) })
+        f(self.buf as *mut libc::c_char)
     }
 
     /// Returns true if the CString is a null.
@@ -182,7 +181,7 @@ impl CString {
     pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
         if self.buf.is_null() { fail!("CString is null!"); }
         unsafe {
-            cast::transmute(Slice { data: self.buf, len: self.len() + 1 })
+            mem::transmute(Slice { data: self.buf, len: self.len() + 1 })
         }
     }
 
@@ -196,7 +195,7 @@ impl CString {
     pub fn as_bytes_no_nul<'a>(&'a self) -> &'a [u8] {
         if self.buf.is_null() { fail!("CString is null!"); }
         unsafe {
-            cast::transmute(Slice { data: self.buf, len: self.len() })
+            mem::transmute(Slice { data: self.buf, len: self.len() })
         }
     }
 
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs
index 8c2c4fd1f0b..817b54fb692 100644
--- a/src/libstd/c_vec.rs
+++ b/src/libstd/c_vec.rs
@@ -33,9 +33,9 @@
 //! handled correctly, i.e. that allocated memory is eventually freed
 //! if necessary.
 
-use cast;
 use container::Container;
 use kinds::Send;
+use mem;
 use ops::Drop;
 use option::{Option, Some, None};
 use ptr::RawPtr;
@@ -102,14 +102,14 @@ impl<T> CVec<T> {
     /// View the stored data as a slice.
     pub fn as_slice<'a>(&'a self) -> &'a [T] {
         unsafe {
-            cast::transmute(raw::Slice { data: self.base as *T, len: self.len })
+            mem::transmute(raw::Slice { data: self.base as *T, len: self.len })
         }
     }
 
     /// View the stored data as a mutable slice.
     pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
         unsafe {
-            cast::transmute(raw::Slice { data: self.base as *T, len: self.len })
+            mem::transmute(raw::Slice { data: self.base as *T, len: self.len })
         }
     }
 
diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs
index cebfeb5399e..ed884647fb6 100644
--- a/src/libstd/comm/select.rs
+++ b/src/libstd/comm/select.rs
@@ -45,11 +45,11 @@
 
 #![allow(dead_code)]
 
-use cast;
 use cell::Cell;
 use iter::Iterator;
-use kinds::marker;
 use kinds::Send;
+use kinds::marker;
+use mem;
 use ops::Drop;
 use option::{Some, None, Option};
 use owned::Box;
@@ -247,8 +247,8 @@ impl<'rx, T: Send> Handle<'rx, T> {
     /// while it is added to the `Select` set.
     pub unsafe fn add(&mut self) {
         if self.added { return }
-        let selector: &mut Select = cast::transmute(&*self.selector);
-        let me: *mut Handle<'static, ()> = cast::transmute(&*self);
+        let selector: &mut Select = mem::transmute(&*self.selector);
+        let me: *mut Handle<'static, ()> = mem::transmute(&*self);
 
         if selector.head.is_null() {
             selector.head = me;
@@ -268,8 +268,8 @@ impl<'rx, T: Send> Handle<'rx, T> {
     pub unsafe fn remove(&mut self) {
         if !self.added { return }
 
-        let selector: &mut Select = cast::transmute(&*self.selector);
-        let me: *mut Handle<'static, ()> = cast::transmute(&*self);
+        let selector: &mut Select = mem::transmute(&*self.selector);
+        let me: *mut Handle<'static, ()> = mem::transmute(&*self);
 
         if self.prev.is_null() {
             assert_eq!(selector.head, me);
diff --git a/src/libstd/comm/sync.rs b/src/libstd/comm/sync.rs
index db3f90cad5a..819e885526c 100644
--- a/src/libstd/comm/sync.rs
+++ b/src/libstd/comm/sync.rs
@@ -33,7 +33,6 @@
 /// of a synchronous channel. There are a few branches for the unbuffered case,
 /// but they're mostly just relevant to blocking senders.
 
-use cast;
 use container::Container;
 use iter::Iterator;
 use kinds::Send;
@@ -187,7 +186,7 @@ impl<T: Send> Packet<T> {
             NoneBlocked if state.cap == 0 => {
                 let mut canceled = false;
                 assert!(state.canceled.is_none());
-                state.canceled = Some(unsafe { cast::transmute(&mut canceled) });
+                state.canceled = Some(unsafe { mem::transmute(&mut canceled) });
                 wait(&mut state.blocker, BlockedSender, &self.lock);
                 if canceled {Err(state.buf.dequeue())} else {Ok(())}
             }
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index 7363593bacf..b4bb6236f08 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -484,26 +484,26 @@ will look like `"\\{"`.
 */
 
 use any;
-use cast;
 use cell::Cell;
 use char::Char;
 use cmp;
 use container::Container;
+use intrinsics::TypeId;
 use io::MemWriter;
 use io;
-use iter;
 use iter::{Iterator, range};
+use iter;
 use kinds::Copy;
+use mem;
 use num::Signed;
 use option::{Option, Some, None};
 use owned::Box;
 use repr;
 use result::{Ok, Err, ResultUnwrap};
-use str::{StrSlice, StrAllocating, UTF16Item, ScalarValue, LoneSurrogate};
-use str;
 use slice::{Vector, ImmutableVector};
 use slice;
-use intrinsics::TypeId;
+use str::{StrSlice, StrAllocating, UTF16Item, ScalarValue, LoneSurrogate};
+use str;
 
 pub use self::num::radix;
 pub use self::num::Radix;
@@ -552,7 +552,7 @@ impl<'a> Arguments<'a> {
     #[doc(hidden)] #[inline]
     pub unsafe fn new<'a>(fmt: &'static [rt::Piece<'static>],
                           args: &'a [Argument<'a>]) -> Arguments<'a> {
-        Arguments{ fmt: cast::transmute(fmt), args: args }
+        Arguments{ fmt: mem::transmute(fmt), args: args }
     }
 }
 
@@ -870,7 +870,7 @@ impl<'a> Formatter<'a> {
             rt::Plural(offset, ref selectors, ref default) => {
                 // This is validated at compile-time to be a pointer to a
                 // '&uint' value.
-                let value: &uint = unsafe { cast::transmute(arg.value) };
+                let value: &uint = unsafe { mem::transmute(arg.value) };
                 let value = *value;
 
                 // First, attempt to match against explicit values without the
@@ -913,7 +913,7 @@ impl<'a> Formatter<'a> {
             rt::Select(ref selectors, ref default) => {
                 // This is validated at compile-time to be a pointer to a
                 // string slice,
-                let value: & &str = unsafe { cast::transmute(arg.value) };
+                let value: & &str = unsafe { mem::transmute(arg.value) };
                 let value = *value;
 
                 for s in selectors.iter() {
@@ -1093,8 +1093,8 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
                        t: &'a T) -> Argument<'a> {
     unsafe {
         Argument {
-            formatter: cast::transmute(f),
-            value: cast::transmute(t)
+            formatter: mem::transmute(f),
+            value: mem::transmute(t)
         }
     }
 }
@@ -1141,7 +1141,7 @@ impl Char for char {
     fn fmt(&self, f: &mut Formatter) -> Result {
         let mut utf8 = [0u8, ..4];
         let amt = self.encode_utf8(utf8);
-        let s: &str = unsafe { cast::transmute(utf8.slice_to(amt)) };
+        let s: &str = unsafe { mem::transmute(utf8.slice_to(amt)) };
         secret_string(&s, f)
     }
 }
diff --git a/src/libstd/hash/mod.rs b/src/libstd/hash/mod.rs
index c8207a4c37c..a510aa90343 100644
--- a/src/libstd/hash/mod.rs
+++ b/src/libstd/hash/mod.rs
@@ -307,7 +307,7 @@ impl<S: Writer, T: Hash<S>, U: Hash<S>> Hash<S> for Result<T, U> {
 
 #[cfg(test)]
 mod tests {
-    use cast;
+    use mem;
     use io::{IoResult, Writer};
     use iter::{Iterator};
     use option::{Some, None};
@@ -367,12 +367,12 @@ mod tests {
         assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
 
         unsafe {
-            let ptr: *int = cast::transmute(5);
+            let ptr: *int = mem::transmute(5);
             assert_eq!(hasher.hash(&ptr), 5);
         }
 
         unsafe {
-            let ptr: *mut int = cast::transmute(5);
+            let ptr: *mut int = mem::transmute(5);
             assert_eq!(hasher.hash(&ptr), 5);
         }
     }
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs
index c2e8fbeeb78..bb4bd50815a 100644
--- a/src/libstd/io/extensions.rs
+++ b/src/libstd/io/extensions.rs
@@ -77,7 +77,7 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> {
 /// This function returns the value returned by the callback, for convenience.
 pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
     use mem::{to_le16, to_le32, to_le64};
-    use cast::transmute;
+    use mem::transmute;
 
     // LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
     assert!(size <= 8u);
@@ -117,7 +117,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
 /// This function returns the value returned by the callback, for convenience.
 pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
     use mem::{to_be16, to_be32, to_be64};
-    use cast::transmute;
+    use mem::transmute;
 
     // LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
     assert!(size <= 8u);
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 4a53a064610..37edab99915 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -217,24 +217,24 @@ responding to errors that may occur while attempting to read the numbers.
 
 #![deny(unused_must_use)]
 
-use cast;
 use char::Char;
 use container::Container;
 use fmt;
 use int;
 use iter::Iterator;
 use libc;
+use mem::transmute;
 use ops::{BitOr, BitAnd, Sub};
-use os;
 use option::{Option, Some, None};
+use os;
 use owned::Box;
 use path::Path;
 use result::{Ok, Err, Result};
+use slice::{Vector, MutableVector, ImmutableVector};
 use str::{StrSlice, StrAllocating};
 use str;
 use uint;
 use unstable::finally::try_finally;
-use slice::{Vector, MutableVector, ImmutableVector};
 use vec::Vec;
 
 // Reexports
@@ -729,7 +729,7 @@ pub trait Reader {
     /// `f64`s are 8 byte, IEEE754 double-precision floating point numbers.
     fn read_be_f64(&mut self) -> IoResult<f64> {
         self.read_be_u64().map(|i| unsafe {
-            cast::transmute::<u64, f64>(i)
+            transmute::<u64, f64>(i)
         })
     }
 
@@ -738,7 +738,7 @@ pub trait Reader {
     /// `f32`s are 4 byte, IEEE754 single-precision floating point numbers.
     fn read_be_f32(&mut self) -> IoResult<f32> {
         self.read_be_u32().map(|i| unsafe {
-            cast::transmute::<u32, f32>(i)
+            transmute::<u32, f32>(i)
         })
     }
 
@@ -789,7 +789,7 @@ pub trait Reader {
     /// `f64`s are 8 byte, IEEE754 double-precision floating point numbers.
     fn read_le_f64(&mut self) -> IoResult<f64> {
         self.read_le_u64().map(|i| unsafe {
-            cast::transmute::<u64, f64>(i)
+            transmute::<u64, f64>(i)
         })
     }
 
@@ -798,7 +798,7 @@ pub trait Reader {
     /// `f32`s are 4 byte, IEEE754 single-precision floating point numbers.
     fn read_le_f32(&mut self) -> IoResult<f32> {
         self.read_le_u32().map(|i| unsafe {
-            cast::transmute::<u32, f32>(i)
+            transmute::<u32, f32>(i)
         })
     }
 
@@ -995,14 +995,14 @@ pub trait Writer {
     /// Write a big-endian IEEE754 double-precision floating-point (8 bytes).
     fn write_be_f64(&mut self, f: f64) -> IoResult<()> {
         unsafe {
-            self.write_be_u64(cast::transmute(f))
+            self.write_be_u64(transmute(f))
         }
     }
 
     /// Write a big-endian IEEE754 single-precision floating-point (4 bytes).
     fn write_be_f32(&mut self, f: f32) -> IoResult<()> {
         unsafe {
-            self.write_be_u32(cast::transmute(f))
+            self.write_be_u32(transmute(f))
         }
     }
 
@@ -1040,7 +1040,7 @@ pub trait Writer {
     /// (8 bytes).
     fn write_le_f64(&mut self, f: f64) -> IoResult<()> {
         unsafe {
-            self.write_le_u64(cast::transmute(f))
+            self.write_le_u64(transmute(f))
         }
     }
 
@@ -1048,7 +1048,7 @@ pub trait Writer {
     /// (4 bytes).
     fn write_le_f32(&mut self, f: f32) -> IoResult<()> {
         unsafe {
-            self.write_le_u32(cast::transmute(f))
+            self.write_le_u32(transmute(f))
         }
     }
 
diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs
index e66b2107bb1..864a7010541 100644
--- a/src/libstd/io/net/udp.rs
+++ b/src/libstd/io/net/udp.rs
@@ -226,6 +226,7 @@ impl Writer for UdpStream {
 }
 
 #[cfg(test)]
+#[allow(experimental)]
 mod test {
     use super::*;
     use io::net::ip::{SocketAddr};
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 3f22a76c1f4..8f0c1e41309 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -143,7 +143,6 @@ extern crate core;
 
 pub use core::any;
 pub use core::bool;
-pub use core::cast;
 pub use core::cell;
 pub use core::char;
 pub use core::clone;
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs
index 5d18ca4141b..1a971594837 100644
--- a/src/libstd/local_data.rs
+++ b/src/libstd/local_data.rs
@@ -38,11 +38,11 @@ assert_eq!(*key_vector.get().unwrap(), ~[4]);
 // Casting 'Arcane Sight' reveals an overwhelming aura of Transmutation
 // magic.
 
-use cast;
 use iter::{Iterator};
 use kinds::Send;
 use kinds::marker;
 use mem::replace;
+use mem;
 use ops::{Drop, Deref};
 use option::{None, Option, Some};
 use owned::Box;
@@ -172,7 +172,7 @@ impl<T: 'static> KeyValue<T> {
         // anything.
         let newval = data.map(|d| {
             let d = box d as Box<LocalData>;
-            let d: Box<LocalData:Send> = unsafe { cast::transmute(d) };
+            let d: Box<LocalData:Send> = unsafe { mem::transmute(d) };
             (keyval, d, 0)
         });
 
@@ -188,8 +188,8 @@ impl<T: 'static> KeyValue<T> {
                 replace(map.get_mut(i), newval).map(|(_, data, _)| {
                     // Move `data` into transmute to get out the memory that it
                     // owns, we must free it manually later.
-                    let t: raw::TraitObject = unsafe { cast::transmute(data) };
-                    let alloc: Box<T> = unsafe { cast::transmute(t.data) };
+                    let t: raw::TraitObject = unsafe { mem::transmute(data) };
+                    let alloc: Box<T> = unsafe { mem::transmute(t.data) };
 
                     // Now that we own `alloc`, we can just move out of it as we
                     // would with any other data.
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index ea248b6d40d..29c206b32fc 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -15,13 +15,13 @@
 
 use prelude::*;
 
-use cast;
 use from_str::FromStr;
+use intrinsics;
 use libc::c_int;
-use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
+use mem;
 use num::strconv;
+use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
 use num;
-use intrinsics;
 
 pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE};
 pub use core::f32::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -111,7 +111,7 @@ impl Float for f32 {
         static EXP_MASK: u32 = 0x7f800000;
         static MAN_MASK: u32 = 0x007fffff;
 
-        let bits: u32 = unsafe { cast::transmute(self) };
+        let bits: u32 = unsafe { mem::transmute(self) };
         match (bits & MAN_MASK, bits & EXP_MASK) {
             (0, 0)        => FPZero,
             (_, 0)        => FPSubnormal,
@@ -168,7 +168,7 @@ impl Float for f32 {
 
     /// Returns the mantissa, exponent and sign as integers.
     fn integer_decode(self) -> (u64, i16, i8) {
-        let bits: u32 = unsafe { cast::transmute(self) };
+        let bits: u32 = unsafe { mem::transmute(self) };
         let sign: i8 = if bits >> 31 == 0 { 1 } else { -1 };
         let mut exponent: i16 = ((bits >> 23) & 0xff) as i16;
         let mantissa = if exponent == 0 {
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index 77171a00bef..c18ea5caba6 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -14,13 +14,13 @@
 
 use prelude::*;
 
-use cast;
 use from_str::FromStr;
+use intrinsics;
 use libc::{c_int};
+use mem;
 use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
 use num::{strconv};
 use num;
-use intrinsics;
 
 pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE};
 pub use core::f64::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP};
@@ -119,7 +119,7 @@ impl Float for f64 {
         static EXP_MASK: u64 = 0x7ff0000000000000;
         static MAN_MASK: u64 = 0x000fffffffffffff;
 
-        let bits: u64 = unsafe { cast::transmute(self) };
+        let bits: u64 = unsafe { mem::transmute(self) };
         match (bits & MAN_MASK, bits & EXP_MASK) {
             (0, 0)        => FPZero,
             (_, 0)        => FPSubnormal,
@@ -176,7 +176,7 @@ impl Float for f64 {
 
     /// Returns the mantissa, exponent and sign as integers.
     fn integer_decode(self) -> (u64, i16, i8) {
-        let bits: u64 = unsafe { cast::transmute(self) };
+        let bits: u64 = unsafe { mem::transmute(self) };
         let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
         let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
         let mantissa = if exponent == 0 {
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index f21fbe1b6e6..dfe7241d7af 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -12,13 +12,13 @@
 
 use ascii::AsciiCast;
 use c_str::{CString, ToCStr};
-use cast;
 use clone::Clone;
-use container::Container;
 use cmp::{Eq, TotalEq};
+use container::Container;
 use from_str::FromStr;
 use io::Writer;
 use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map};
+use mem;
 use option::{Option, Some, None};
 use slice::{Vector, OwnedVector, ImmutableVector};
 use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice};
@@ -389,13 +389,13 @@ impl GenericPath for Path {
     #[inline]
     fn filestem_str<'a>(&'a self) -> Option<&'a str> {
         // filestem() returns a byte vector that's guaranteed valid UTF-8
-        self.filestem().map(|t| unsafe { cast::transmute(t) })
+        self.filestem().map(|t| unsafe { mem::transmute(t) })
     }
 
     #[inline]
     fn extension_str<'a>(&'a self) -> Option<&'a str> {
         // extension() returns a byte vector that's guaranteed valid UTF-8
-        self.extension().map(|t| unsafe { cast::transmute(t) })
+        self.extension().map(|t| unsafe { mem::transmute(t) })
     }
 
     fn dir_path(&self) -> Path {
diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs
index e0fe75fd907..bc489bc399f 100644
--- a/src/libstd/rc.rs
+++ b/src/libstd/rc.rs
@@ -23,7 +23,7 @@ pointers, and then storing the parent pointers as `Weak` pointers.
 
 */
 
-use cast::transmute;
+use mem::transmute;
 use cell::Cell;
 use clone::Clone;
 use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs
index 6e47203b56c..6029f504d10 100644
--- a/src/libstd/repr.rs
+++ b/src/libstd/repr.rs
@@ -16,7 +16,7 @@ More runtime type reflection
 
 #![allow(missing_doc)]
 
-use cast::transmute;
+use mem::transmute;
 use char;
 use container::Container;
 use io;
@@ -157,7 +157,7 @@ impl<'a> ReprVisitor<'a> {
                 ptr: ptr,
                 ptr_stk: vec!(),
                 var_stk: vec!(),
-                writer: ::cast::transmute_copy(&self.writer),
+                writer: ::mem::transmute_copy(&self.writer),
                 last_err: None,
             };
             let mut v = reflect::MovePtrAdaptor(u);
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);
                 }
             }
         }
diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs
index b97c55ad701..b0868dd0daf 100644
--- a/src/libstd/slice.rs
+++ b/src/libstd/slice.rs
@@ -97,8 +97,7 @@ There are a number of free functions that create or take vectors, for example:
 
 */
 
-use cast::transmute;
-use cast;
+use mem::transmute;
 use clone::Clone;
 use cmp::{TotalOrd, Ordering, Less, Greater};
 use cmp;
@@ -333,7 +332,7 @@ impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
                     // FIXME: #13994 (should pass align and size here)
                     exchange_free(ret as *mut u8, 0, 8);
                 });
-            cast::transmute(ret)
+            mem::transmute(ret)
         }
     }
 
@@ -380,7 +379,7 @@ impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
                     // FIXME: #13994 (should pass align and size here)
                     exchange_free(ret as *mut u8, 0, 8);
                 });
-            cast::transmute(ret)
+            mem::transmute(ret)
         }
     }
 
@@ -531,7 +530,7 @@ fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
                 ptr::copy_nonoverlapping_memory(buf_v.offset(j),
                                                 &tmp as *T,
                                                 1);
-                cast::forget(tmp);
+                mem::forget(tmp);
             }
         }
     }
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index fb3dcc97287..24cf9681ca8 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -74,23 +74,23 @@ The actual representation of strings have direct mappings to vectors:
 
 */
 
-use cast;
-use cast::transmute;
-use char;
 use char::Char;
+use char;
 use clone::Clone;
 use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv, Ordering};
 use container::Container;
+use default::Default;
 use fmt;
+use from_str::FromStr;
 use io::Writer;
 use iter::{Iterator, range, AdditiveIterator};
+use mem::transmute;
+use mem;
 use option::{None, Option, Some};
-use from_str::FromStr;
-use slice::{ImmutableVector, MutableVector, CloneableVector};
 use slice::Vector;
-use vec::Vec;
-use default::Default;
+use slice::{ImmutableVector, MutableVector, CloneableVector};
 use strbuf::StrBuf;
+use vec::Vec;
 
 pub use core::str::{from_utf8, CharEq, Chars, CharOffsets, RevChars};
 pub use core::str::{RevCharOffsets, Bytes, RevBytes, CharSplits, RevCharSplits};
@@ -126,7 +126,7 @@ impl FromStr for ~str {
 /// Fails if invalid UTF-8
 pub fn from_byte(b: u8) -> ~str {
     assert!(b < 128u8);
-    unsafe { ::cast::transmute(box [b]) }
+    unsafe { ::mem::transmute(box [b]) }
 }
 
 /// Convert a char to a string
@@ -403,7 +403,7 @@ static TAG_CONT_U8: u8 = 128u8;
 /// ```
 pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
     if is_utf8(v) {
-        return Slice(unsafe { cast::transmute(v) })
+        return Slice(unsafe { mem::transmute(v) })
     }
 
     static REPLACEMENT: &'static [u8] = bytes!(0xEF, 0xBF, 0xBD); // U+FFFD in UTF-8
@@ -666,8 +666,8 @@ impl<'a> fmt::Show for MaybeOwned<'a> {
 
 /// Unsafe operations
 pub mod raw {
-    use cast;
     use libc;
+    use mem;
     use ptr::RawPtr;
     use raw::Slice;
     use slice::CloneableVector;
@@ -679,9 +679,9 @@ pub mod raw {
     /// Create a Rust string from a *u8 buffer of the given length
     pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str {
         let v = Slice { data: buf, len: len };
-        let bytes: &[u8] = ::cast::transmute(v);
+        let bytes: &[u8] = ::mem::transmute(v);
         assert!(is_utf8(bytes));
-        let s: &str = ::cast::transmute(bytes);
+        let s: &str = ::mem::transmute(bytes);
         s.to_owned()
     }
 
@@ -707,7 +707,7 @@ pub mod raw {
     /// that the utf-8-ness of the vector has already been validated
     #[inline]
     pub unsafe fn from_utf8_owned(v: ~[u8]) -> ~str {
-        cast::transmute(v)
+        mem::transmute(v)
     }
 
     /// Converts a byte to a string.
@@ -717,7 +717,7 @@ pub mod raw {
     /// The caller must preserve the valid UTF-8 property when modifying.
     #[inline]
     pub unsafe fn as_owned_vec<'a>(s: &'a mut ~str) -> &'a mut ~[u8] {
-        cast::transmute(s)
+        mem::transmute(s)
     }
 
     /// Sets the length of a string
@@ -823,7 +823,7 @@ pub trait StrAllocating: Str {
         use slice::Vector;
 
         unsafe {
-            ::cast::transmute(self.as_slice().as_bytes().to_owned())
+            ::mem::transmute(self.as_slice().as_bytes().to_owned())
         }
     }
 
@@ -933,7 +933,7 @@ pub trait OwnedStr {
 impl OwnedStr for ~str {
     #[inline]
     fn into_bytes(self) -> ~[u8] {
-        unsafe { cast::transmute(self) }
+        unsafe { mem::transmute(self) }
     }
 
     #[inline]
diff --git a/src/libstd/strbuf.rs b/src/libstd/strbuf.rs
index 8e05b2f527d..45ab690b0a2 100644
--- a/src/libstd/strbuf.rs
+++ b/src/libstd/strbuf.rs
@@ -11,12 +11,12 @@
 //! An owned, growable string that enforces that its contents are valid UTF-8.
 
 use c_vec::CVec;
-use cast;
 use char::Char;
 use container::Container;
 use fmt;
 use io::Writer;
 use iter::{Extendable, FromIterator, Iterator, range};
+use mem;
 use option::{None, Option, Some};
 use ptr::RawPtr;
 use slice::{OwnedVector, Vector, CloneableVector};
@@ -265,7 +265,7 @@ impl Str for StrBuf {
     #[inline]
     fn as_slice<'a>(&'a self) -> &'a str {
         unsafe {
-            cast::transmute(self.vec.as_slice())
+            mem::transmute(self.vec.as_slice())
         }
     }
 }
@@ -274,7 +274,7 @@ impl StrAllocating for StrBuf {
     #[inline]
     fn into_owned(self) -> ~str {
         unsafe {
-            cast::transmute(self.vec.as_slice().to_owned())
+            mem::transmute(self.vec.as_slice().to_owned())
         }
     }
 
diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs
index 676c836c459..7dcfe62ffb8 100644
--- a/src/libstd/sync/arc.rs
+++ b/src/libstd/sync/arc.rs
@@ -21,10 +21,10 @@
 //! the underlying data will remain valid (not free'd) so long as the reference
 //! count is greater than one.
 
-use cast;
 use clone::Clone;
 use iter::Iterator;
 use kinds::Send;
+use mem;
 use ops::Drop;
 use owned::Box;
 use ptr::RawPtr;
@@ -50,7 +50,7 @@ unsafe fn new_inner<T: Send>(data: T, refcount: uint) -> *mut ArcData<T> {
                     count: AtomicUint::new(refcount),
                     data: Unsafe::new(data)
                  };
-    cast::transmute(data)
+    mem::transmute(data)
 }
 
 impl<T: Send> UnsafeArc<T> {
@@ -158,7 +158,7 @@ impl<T> Drop for UnsafeArc<T>{
                 //  happened before), and an "acquire" operation before deleting the object.
                 // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
                 fence(Acquire);
-                let _: Box<ArcData<T>> = cast::transmute(self.data);
+                let _: Box<ArcData<T>> = mem::transmute(self.data);
             }
         }
     }
diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs
index 2fba59c3233..6ddae97e901 100644
--- a/src/libstd/sync/atomics.rs
+++ b/src/libstd/sync/atomics.rs
@@ -108,11 +108,11 @@
 #![allow(missing_doc)]
 
 use intrinsics;
-use cast;
-use std::kinds::marker;
-use option::{Option,Some,None};
+use mem;
 use ops::Drop;
+use option::{Option,Some,None};
 use owned::Box;
+use std::kinds::marker;
 use ty::Unsafe;
 
 /// An atomic boolean type.
@@ -665,7 +665,7 @@ impl<T> AtomicPtr<T> {
 impl<T> AtomicOption<T> {
     /// Create a new `AtomicOption`
     pub fn new(p: Box<T>) -> AtomicOption<T> {
-        unsafe { AtomicOption { p: Unsafe::new(cast::transmute(p)) } }
+        unsafe { AtomicOption { p: Unsafe::new(mem::transmute(p)) } }
     }
 
     /// Create a new `AtomicOption` that doesn't contain a value
@@ -675,13 +675,13 @@ impl<T> AtomicOption<T> {
     #[inline]
     pub fn swap(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
         unsafe {
-            let val = cast::transmute(val);
+            let val = mem::transmute(val);
 
             let p = atomic_swap(self.p.get(), val, order);
             if p as uint == 0 {
                 None
             } else {
-                Some(cast::transmute(p))
+                Some(mem::transmute(p))
             }
         }
     }
@@ -689,7 +689,7 @@ impl<T> AtomicOption<T> {
     /// Remove the value, leaving the `AtomicOption` empty.
     #[inline]
     pub fn take(&self, order: Ordering) -> Option<Box<T>> {
-        unsafe { self.swap(cast::transmute(0), order) }
+        unsafe { self.swap(mem::transmute(0), order) }
     }
 
     /// Replace an empty value with a non-empty value.
@@ -700,13 +700,13 @@ impl<T> AtomicOption<T> {
     #[inline]
     pub fn fill(&self, val: Box<T>, order: Ordering) -> Option<Box<T>> {
         unsafe {
-            let val = cast::transmute(val);
-            let expected = cast::transmute(0);
+            let val = mem::transmute(val);
+            let expected = mem::transmute(0);
             let oldval = atomic_compare_and_swap(self.p.get(), expected, val, order);
             if oldval == expected {
                 None
             } else {
-                Some(cast::transmute(val))
+                Some(mem::transmute(val))
             }
         }
     }
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() {
diff --git a/src/libstd/sync/mpsc_queue.rs b/src/libstd/sync/mpsc_queue.rs
index e05959e2591..4cdcd05e9b4 100644
--- a/src/libstd/sync/mpsc_queue.rs
+++ b/src/libstd/sync/mpsc_queue.rs
@@ -38,8 +38,8 @@
 // http://www.1024cores.net/home/lock-free-algorithms
 //                         /queues/non-intrusive-mpsc-node-based-queue
 
-use cast;
 use kinds::Send;
+use mem;
 use ops::Drop;
 use option::{Option, None, Some};
 use owned::Box;
@@ -74,7 +74,7 @@ pub struct Queue<T> {
 
 impl<T> Node<T> {
     unsafe fn new(v: Option<T>) -> *mut Node<T> {
-        cast::transmute(box Node {
+        mem::transmute(box Node {
             next: AtomicPtr::new(0 as *mut Node<T>),
             value: v,
         })
@@ -121,7 +121,7 @@ impl<T: Send> Queue<T> {
                 assert!((*tail).value.is_none());
                 assert!((*next).value.is_some());
                 let ret = (*next).value.take_unwrap();
-                let _: Box<Node<T>> = cast::transmute(tail);
+                let _: Box<Node<T>> = mem::transmute(tail);
                 return Data(ret);
             }
 
@@ -146,7 +146,7 @@ impl<T: Send> Drop for Queue<T> {
             let mut cur = self.tail;
             while !cur.is_null() {
                 let next = (*cur).next.load(Relaxed);
-                let _: Box<Node<T>> = cast::transmute(cur);
+                let _: Box<Node<T>> = mem::transmute(cur);
                 cur = next;
             }
         }
diff --git a/src/libstd/sync/spsc_queue.rs b/src/libstd/sync/spsc_queue.rs
index 7854a0e168e..ed6d690def0 100644
--- a/src/libstd/sync/spsc_queue.rs
+++ b/src/libstd/sync/spsc_queue.rs
@@ -33,8 +33,8 @@
 //! concurrently between two tasks. This data structure is safe to use and
 //! enforces the semantics that there is one pusher and one popper.
 
-use cast;
 use kinds::Send;
+use mem;
 use ops::Drop;
 use option::{Some, None, Option};
 use owned::Box;
@@ -74,7 +74,7 @@ pub struct Queue<T> {
 impl<T: Send> Node<T> {
     fn new() -> *mut Node<T> {
         unsafe {
-            cast::transmute(box Node {
+            mem::transmute(box Node {
                 value: None,
                 next: AtomicPtr::new(0 as *mut Node<T>),
             })
@@ -188,7 +188,7 @@ impl<T: Send> Queue<T> {
                     (*self.tail_prev.load(Relaxed)).next.store(next, Relaxed);
                     // We have successfully erased all references to 'tail', so
                     // now we can safely drop it.
-                    let _: Box<Node<T>> = cast::transmute(tail);
+                    let _: Box<Node<T>> = mem::transmute(tail);
                 }
             }
             return ret;
@@ -216,7 +216,7 @@ impl<T: Send> Drop for Queue<T> {
             let mut cur = self.first;
             while !cur.is_null() {
                 let next = (*cur).next.load(Relaxed);
-                let _n: Box<Node<T>> = cast::transmute(cur);
+                let _n: Box<Node<T>> = mem::transmute(cur);
                 cur = next;
             }
         }
diff --git a/src/libstd/unstable/dynamic_lib.rs b/src/libstd/unstable/dynamic_lib.rs
index e2a9f6a5c48..87d531cc627 100644
--- a/src/libstd/unstable/dynamic_lib.rs
+++ b/src/libstd/unstable/dynamic_lib.rs
@@ -17,8 +17,8 @@ A simple wrapper over the platform's dynamic library facilities
 */
 
 use c_str::ToCStr;
-use cast;
 use iter::Iterator;
+use mem;
 use ops::*;
 use option::*;
 use os;
@@ -97,7 +97,7 @@ impl DynamicLibrary {
         // the destructor does not run.
         match maybe_symbol_value {
             Err(err) => Err(err),
-            Ok(symbol_value) => Ok(cast::transmute(symbol_value))
+            Ok(symbol_value) => Ok(mem::transmute(symbol_value))
         }
     }
 }
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index aa10be1d1be..528ab72762a 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -10,23 +10,21 @@
 
 //! An owned, growable vector.
 
-use cast::{forget, transmute};
+use RawVec = raw::Vec;
 use clone::Clone;
 use cmp::{Ord, Eq, Ordering, TotalEq, TotalOrd, max};
 use container::{Container, Mutable};
 use default::Default;
 use fmt;
 use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator, range};
-use mem::{min_align_of, move_val_init, size_of};
 use mem;
-use num;
 use num::{CheckedMul, CheckedAdd};
+use num;
 use ops::{Add, Drop};
 use option::{None, Option, Some, Expect};
 use ptr::RawPtr;
 use ptr;
 use raw::Slice;
-use RawVec = raw::Vec;
 use rt::heap::{allocate, reallocate, deallocate};
 use slice::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector};
 use slice::{MutableTotalOrdVector, OwnedVector, Vector};
@@ -91,12 +89,14 @@ impl<T> Vec<T> {
     /// let vec: Vec<int> = Vec::with_capacity(10);
     /// ```
     pub fn with_capacity(capacity: uint) -> Vec<T> {
-        if size_of::<T>() == 0 { return Vec { len: 0, cap: ::uint::MAX, ptr: 0 as *mut T } }
-        if capacity == 0 {
+        if mem::size_of::<T>() == 0 {
+            Vec { len: 0, cap: ::uint::MAX, ptr: 0 as *mut T }
+        } else if capacity == 0 {
             Vec::new()
         } else {
-            let size = capacity.checked_mul(&size_of::<T>()).expect("capacity overflow");
-            let ptr = unsafe { allocate(size, min_align_of::<T>()) };
+            let size = capacity.checked_mul(&mem::size_of::<T>())
+                               .expect("capacity overflow");
+            let ptr = unsafe { allocate(size, mem::min_align_of::<T>()) };
             Vec { len: 0, cap: capacity, ptr: ptr as *mut T }
         }
     }
@@ -117,7 +117,8 @@ impl<T> Vec<T> {
         unsafe {
             let mut xs = Vec::with_capacity(length);
             while xs.len < length {
-                move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len), op(xs.len));
+                mem::move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len),
+                                   op(xs.len));
                 xs.len += 1;
             }
             xs
@@ -133,7 +134,8 @@ impl<T> Vec<T> {
     /// - there must be `length` valid instances of type `T` at the
     ///   beginning of that allocation
     /// - `ptr` must be allocated by the default `Vec` allocator
-    pub unsafe fn from_raw_parts(length: uint, capacity: uint, ptr: *mut T) -> Vec<T> {
+    pub unsafe fn from_raw_parts(length: uint, capacity: uint,
+                                 ptr: *mut T) -> Vec<T> {
         Vec { len: length, cap: capacity, ptr: ptr }
     }
 
@@ -212,7 +214,8 @@ impl<T: Clone> Vec<T> {
         unsafe {
             let mut xs = Vec::with_capacity(length);
             while xs.len < length {
-                move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len), value.clone());
+                mem::move_val_init(xs.as_mut_slice().unsafe_mut_ref(xs.len),
+                                   value.clone());
                 xs.len += 1;
             }
             xs
@@ -405,16 +408,19 @@ impl<T> Container for Vec<T> {
 #[inline(never)]
 unsafe fn alloc_or_realloc<T>(ptr: *mut T, size: uint, old_size: uint) -> *mut T {
     if old_size == 0 {
-        allocate(size, min_align_of::<T>()) as *mut T
+        allocate(size, mem::min_align_of::<T>()) as *mut T
     } else {
-        reallocate(ptr as *mut u8, size, min_align_of::<T>(), old_size) as *mut T
+        reallocate(ptr as *mut u8, size,
+                   mem::min_align_of::<T>(), old_size) as *mut T
     }
 }
 
 #[inline]
 unsafe fn dealloc<T>(ptr: *mut T, len: uint) {
-    if size_of::<T>() != 0 {
-        deallocate(ptr as *mut u8, len * size_of::<T>(), min_align_of::<T>())
+    if mem::size_of::<T>() != 0 {
+        deallocate(ptr as *mut u8,
+                   len * mem::size_of::<T>(),
+                   mem::min_align_of::<T>())
     }
 }
 
@@ -494,11 +500,14 @@ impl<T> Vec<T> {
     /// assert_eq!(vec.capacity(), 11);
     /// ```
     pub fn reserve_exact(&mut self, capacity: uint) {
-        if size_of::<T>() == 0 { return }
+        if mem::size_of::<T>() == 0 { return }
+
         if capacity > self.cap {
-            let size = capacity.checked_mul(&size_of::<T>()).expect("capacity overflow");
+            let size = capacity.checked_mul(&mem::size_of::<T>())
+                               .expect("capacity overflow");
             unsafe {
-                self.ptr = alloc_or_realloc(self.ptr, size, self.cap * size_of::<T>());
+                self.ptr = alloc_or_realloc(self.ptr, size,
+                                            self.cap * mem::size_of::<T>());
             }
             self.cap = capacity;
         }
@@ -513,7 +522,8 @@ impl<T> Vec<T> {
     /// vec.shrink_to_fit();
     /// ```
     pub fn shrink_to_fit(&mut self) {
-        if size_of::<T>() == 0 { return }
+        if mem::size_of::<T>() == 0 { return }
+
         if self.len == 0 {
             if self.cap != 0 {
                 unsafe {
@@ -523,9 +533,12 @@ impl<T> Vec<T> {
             }
         } else {
             unsafe {
-                // Overflow check is unnecessary as the vector is already at least this large.
-                self.ptr = reallocate(self.ptr as *mut u8, self.len * size_of::<T>(),
-                                      min_align_of::<T>(), self.cap * size_of::<T>()) as *mut T;
+                // Overflow check is unnecessary as the vector is already at
+                // least this large.
+                self.ptr = reallocate(self.ptr as *mut u8,
+                                      self.len * mem::size_of::<T>(),
+                                      mem::min_align_of::<T>(),
+                                      self.cap * mem::size_of::<T>()) as *mut T;
             }
             self.cap = self.len;
         }
@@ -568,25 +581,26 @@ impl<T> Vec<T> {
     /// ```
     #[inline]
     pub fn push(&mut self, value: T) {
-        if size_of::<T>() == 0 {
+        if mem::size_of::<T>() == 0 {
             // zero-size types consume no memory, so we can't rely on the address space running out
             self.len = self.len.checked_add(&1).expect("length overflow");
-            unsafe { forget(value); }
+            unsafe { mem::forget(value); }
             return
         }
         if self.len == self.cap {
-            let old_size = self.cap * size_of::<T>();
-            let size = max(old_size, 2 * size_of::<T>()) * 2;
+            let old_size = self.cap * mem::size_of::<T>();
+            let size = max(old_size, 2 * mem::size_of::<T>()) * 2;
             if old_size > size { fail!("capacity overflow") }
             unsafe {
-                self.ptr = alloc_or_realloc(self.ptr, size, self.cap * size_of::<T>());
+                self.ptr = alloc_or_realloc(self.ptr, size,
+                                            self.cap * mem::size_of::<T>());
             }
             self.cap = max(self.cap, 2) * 2;
         }
 
         unsafe {
             let end = (self.ptr as *T).offset(self.len as int) as *mut T;
-            move_val_init(&mut *end, value);
+            mem::move_val_init(&mut *end, value);
             self.len += 1;
         }
     }
@@ -644,7 +658,7 @@ impl<T> Vec<T> {
     #[inline]
     pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
         unsafe {
-            transmute(Slice { data: self.as_mut_ptr() as *T, len: self.len })
+            mem::transmute(Slice { data: self.as_mut_ptr() as *T, len: self.len })
         }
     }
 
@@ -664,10 +678,10 @@ impl<T> Vec<T> {
     #[inline]
     pub fn move_iter(self) -> MoveItems<T> {
         unsafe {
-            let iter = transmute(self.as_slice().iter());
+            let iter = mem::transmute(self.as_slice().iter());
             let ptr = self.ptr;
             let cap = self.cap;
-            forget(self);
+            mem::forget(self);
             MoveItems { allocation: ptr, cap: cap, iter: iter }
         }
     }
@@ -949,7 +963,7 @@ impl<T> Vec<T> {
                 ptr::copy_memory(p.offset(1), &*p, len - index);
                 // Write it in, overwriting the first copy of the `index`th
                 // element.
-                move_val_init(&mut *p, element);
+                mem::move_val_init(&mut *p, element);
             }
             self.set_len(len + 1);
         }
@@ -1395,7 +1409,7 @@ impl<T> Vector<T> for Vec<T> {
     /// ```
     #[inline]
     fn as_slice<'a>(&'a self) -> &'a [T] {
-        unsafe { transmute(Slice { data: self.as_ptr(), len: self.len }) }
+        unsafe { mem::transmute(Slice { data: self.as_ptr(), len: self.len }) }
     }
 }
 
@@ -1538,7 +1552,7 @@ impl<T> FromVec<T> for ~[T] {
             // as it still needs to free its own allocation.
             v.set_len(0);
 
-            transmute(ret)
+            mem::transmute(ret)
         }
     }
 }