]> git.lizzy.rs Git - rust.git/commitdiff
core: Remove the cast module
authorAlex Crichton <alex@alexcrichton.com>
Fri, 9 May 2014 17:34:51 +0000 (10:34 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 11 May 2014 08:13:02 +0000 (01:13 -0700)
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]

[breaking-change]

137 files changed:
src/doc/guide-unsafe.md
src/libarena/lib.rs
src/libcollections/dlist.rs
src/libcollections/enum_set.rs
src/libcollections/lru_cache.rs
src/libcore/any.rs
src/libcore/cast.rs [deleted file]
src/libcore/char.rs
src/libcore/kinds.rs
src/libcore/lib.rs
src/libcore/mem.rs
src/libcore/option.rs
src/libcore/ptr.rs
src/libcore/raw.rs
src/libcore/should_not_exist.rs
src/libcore/slice.rs
src/libcore/str.rs
src/libcore/ty.rs
src/libgreen/basic.rs
src/libgreen/context.rs
src/libgreen/sched.rs
src/libgreen/simple.rs
src/libgreen/task.rs
src/liblog/lib.rs
src/libnative/io/addrinfo.rs
src/libnative/io/file_win32.rs
src/libnative/io/net.rs
src/libnative/io/pipe_unix.rs
src/libnative/io/process.rs
src/libnative/io/timer_helper.rs
src/libnative/lib.rs
src/libnative/task.rs
src/librand/distributions/exponential.rs
src/librand/distributions/normal.rs
src/librand/lib.rs
src/librand/os.rs
src/librand/reader.rs
src/librustc/back/archive.rs
src/librustc/metadata/common.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/loader.rs
src/librustc/middle/astencode.rs
src/librustc/middle/liveness.rs
src/librustc/middle/trans/type_.rs
src/librustc/middle/ty.rs
src/librustuv/access.rs
src/librustuv/addrinfo.rs
src/librustuv/async.rs
src/librustuv/file.rs
src/librustuv/homing.rs
src/librustuv/idle.rs
src/librustuv/lib.rs
src/librustuv/net.rs
src/librustuv/pipe.rs
src/librustuv/queue.rs
src/librustuv/stream.rs
src/librustuv/timeout.rs
src/librustuv/uvio.rs
src/libserialize/ebml.rs
src/libstd/ascii.rs
src/libstd/c_str.rs
src/libstd/c_vec.rs
src/libstd/comm/select.rs
src/libstd/comm/sync.rs
src/libstd/fmt/mod.rs
src/libstd/hash/mod.rs
src/libstd/io/extensions.rs
src/libstd/io/mod.rs
src/libstd/io/net/udp.rs
src/libstd/lib.rs
src/libstd/local_data.rs
src/libstd/num/f32.rs
src/libstd/num/f64.rs
src/libstd/path/windows.rs
src/libstd/rc.rs
src/libstd/repr.rs
src/libstd/rt/args.rs
src/libstd/rt/at_exit_imp.rs
src/libstd/rt/backtrace.rs
src/libstd/rt/local_heap.rs
src/libstd/rt/local_ptr.rs
src/libstd/rt/rtio.rs
src/libstd/rt/task.rs
src/libstd/rt/thread.rs
src/libstd/rt/thread_local_storage.rs
src/libstd/rt/unwind.rs
src/libstd/slice.rs
src/libstd/str.rs
src/libstd/strbuf.rs
src/libstd/sync/arc.rs
src/libstd/sync/atomics.rs
src/libstd/sync/deque.rs
src/libstd/sync/mpsc_queue.rs
src/libstd/sync/spsc_queue.rs
src/libstd/unstable/dynamic_lib.rs
src/libstd/vec.rs
src/libsync/arc.rs
src/libsync/mpsc_intrusive.rs
src/libsync/raw.rs
src/libsyntax/ext/expand.rs
src/libsyntax/owned_slice.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pprust.rs
src/libsyntax/util/interner.rs
src/libuuid/lib.rs
src/test/auxiliary/issue_8401.rs
src/test/compile-fail/coerce-unsafe-to-closure.rs
src/test/compile-fail/issue-6458-3.rs
src/test/compile-fail/packed-struct-generic-transmute.rs
src/test/compile-fail/packed-struct-transmute.rs
src/test/debuginfo/nil-enum.rs
src/test/debuginfo/option-like-enum.rs
src/test/run-fail/unwind-box-res.rs
src/test/run-make/mixing-deps/dylib.rs
src/test/run-make/mixing-deps/prog.rs
src/test/run-pass/binops.rs
src/test/run-pass/closure-reform.rs
src/test/run-pass/enum-alignment.rs
src/test/run-pass/enum-clike-ffi-as-int.rs
src/test/run-pass/foreign-call-no-runtime.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/intrinsic-move-val.rs
src/test/run-pass/issue-2214.rs
src/test/run-pass/issue-2718.rs
src/test/run-pass/issue-4735.rs
src/test/run-pass/nullable-pointer-iotareduction.rs
src/test/run-pass/packed-struct-generic-layout.rs
src/test/run-pass/packed-struct-layout.rs
src/test/run-pass/packed-tuple-struct-layout.rs
src/test/run-pass/pub-extern-privacy.rs
src/test/run-pass/regions-mock-tcx.rs
src/test/run-pass/regions-mock-trans.rs
src/test/run-pass/tag-align-dyn-u64.rs
src/test/run-pass/tag-align-dyn-variants.rs
src/test/run-pass/tag-align-u64.rs
src/test/run-pass/transmute-non-immediate-to-immediate.rs
src/test/run-pass/unify-return-ty.rs

index fc6a12b495e2eb4ceb8d8368a365adcd8f463635..d78e2103daca1584d227aef27cdb4d8da57169cf 100644 (file)
@@ -66,11 +66,11 @@ restrictions is undefined behaviour. For example, the following
 creates two aliasing `&mut` pointers, and is invalid.
 
 ```
-use std::cast;
+use std::mem;
 let mut x: u8 = 1;
 
 let ref_1: &mut u8 = &mut x;
-let ref_2: &mut u8 = unsafe { cast::transmute_mut_lifetime(ref_1) };
+let ref_2: &mut u8 = unsafe { mem::transmute(&mut *ref_1) };
 
 // oops, ref_1 and ref_2 point to the same piece of data (x) and are
 // both usable
index 526b72e9b86acfd09aebd3ff04426bb4af876abe..af9ffd5a4b6bfddf9759774fd22791fa4883f4b0 100644 (file)
@@ -26,8 +26,6 @@
 
 extern crate collections;
 
-use std::cast::{transmute, transmute_mut_lifetime};
-use std::cast;
 use std::cell::{Cell, RefCell};
 use std::cmp;
 use std::intrinsics::{TyDesc, get_tydesc};
@@ -137,7 +135,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
     let fill = chunk.fill.get();
 
     while idx < fill {
-        let tydesc_data: *uint = transmute(buf.offset(idx as int));
+        let tydesc_data: *uint = mem::transmute(buf.offset(idx as int));
         let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
         let (size, align) = ((*tydesc).size, (*tydesc).align);
 
@@ -187,18 +185,17 @@ fn alloc_copy_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
     #[inline]
     fn alloc_copy_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
         unsafe {
-            let this = transmute_mut_lifetime(self);
-            let start = round_up(this.copy_head.fill.get(), align);
+            let start = round_up(self.copy_head.fill.get(), align);
             let end = start + n_bytes;
             if end > self.chunk_size() {
-                return this.alloc_copy_grow(n_bytes, align);
+                return self.alloc_copy_grow(n_bytes, align);
             }
-            this.copy_head.fill.set(end);
+            self.copy_head.fill.set(end);
 
             //debug!("idx = {}, size = {}, align = {}, fill = {}",
             //       start, n_bytes, align, head.fill.get());
 
-            this.copy_head.as_ptr().offset(start as int)
+            self.copy_head.as_ptr().offset(start as int)
         }
     }
 
@@ -206,9 +203,9 @@ fn alloc_copy_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
     fn alloc_copy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
         unsafe {
             let ptr = self.alloc_copy_inner(mem::size_of::<T>(), min_align_of::<T>());
-            let ptr: *mut T = transmute(ptr);
+            let ptr = ptr as *mut T;
             mem::move_val_init(&mut (*ptr), op());
-            return transmute(ptr);
+            return &*ptr;
         }
     }
 
@@ -228,26 +225,16 @@ fn alloc_noncopy_grow(&mut self, n_bytes: uint, align: uint)
     fn alloc_noncopy_inner(&mut self, n_bytes: uint, align: uint)
                           -> (*u8, *u8) {
         unsafe {
-            let start;
-            let end;
-            let tydesc_start;
-            let after_tydesc;
-
-            {
-                let head = transmute_mut_lifetime(&mut self.head);
-
-                tydesc_start = head.fill.get();
-                after_tydesc = head.fill.get() + mem::size_of::<*TyDesc>();
-                start = round_up(after_tydesc, align);
-                end = start + n_bytes;
-            }
+            let tydesc_start = self.head.fill.get();
+            let after_tydesc = self.head.fill.get() + mem::size_of::<*TyDesc>();
+            let start = round_up(after_tydesc, align);
+            let end = start + n_bytes;
 
             if end > self.head.capacity() {
                 return self.alloc_noncopy_grow(n_bytes, align);
             }
 
-            let head = transmute_mut_lifetime(&mut self.head);
-            head.fill.set(round_up(end, mem::pref_align_of::<*TyDesc>()));
+            self.head.fill.set(round_up(end, mem::pref_align_of::<*TyDesc>()));
 
             //debug!("idx = {}, size = {}, align = {}, fill = {}",
             //       start, n_bytes, align, head.fill);
@@ -263,18 +250,18 @@ fn alloc_noncopy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
             let tydesc = get_tydesc::<T>();
             let (ty_ptr, ptr) =
                 self.alloc_noncopy_inner(mem::size_of::<T>(), min_align_of::<T>());
-            let ty_ptr: *mut uint = transmute(ty_ptr);
-            let ptr: *mut T = transmute(ptr);
+            let ty_ptr = ty_ptr as *mut uint;
+            let ptr = ptr as *mut T;
             // Write in our tydesc along with a bit indicating that it
             // has *not* been initialized yet.
-            *ty_ptr = transmute(tydesc);
+            *ty_ptr = mem::transmute(tydesc);
             // Actually initialize it
             mem::move_val_init(&mut(*ptr), op());
             // Now that we are done, update the tydesc to indicate that
             // the object is there.
             *ty_ptr = bitpack_tydesc_ptr(tydesc, true);
 
-            return transmute(ptr);
+            return &*ptr;
         }
     }
 
@@ -283,7 +270,7 @@ fn alloc_noncopy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
     pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
         unsafe {
             // FIXME #13933: Remove/justify all `&T` to `&mut T` transmutes
-            let this: &mut Arena = transmute::<&_, &mut _>(self);
+            let this: &mut Arena = mem::transmute::<&_, &mut _>(self);
             if intrinsics::needs_drop::<T>() {
                 this.alloc_noncopy(op)
             } else {
@@ -366,7 +353,7 @@ fn new(next: Option<Box<TypedArenaChunk<T>>>, capacity: uint)
 
         let mut chunk = unsafe {
             let chunk = exchange_malloc(size);
-            let mut chunk: Box<TypedArenaChunk<T>> = cast::transmute(chunk);
+            let mut chunk: Box<TypedArenaChunk<T>> = mem::transmute(chunk);
             mem::move_val_init(&mut chunk.next, next);
             chunk
         };
@@ -387,7 +374,7 @@ fn new(next: Option<Box<TypedArenaChunk<T>>>, capacity: uint)
 
         let mut chunk = unsafe {
             let chunk = exchange_malloc(size, min_align_of::<TypedArenaChunk<T>>());
-            let mut chunk: Box<TypedArenaChunk<T>> = cast::transmute(chunk);
+            let mut chunk: Box<TypedArenaChunk<T>> = mem::transmute(chunk);
             mem::move_val_init(&mut chunk.next, next);
             chunk
         };
@@ -425,7 +412,7 @@ unsafe fn destroy(&mut self, len: uint) {
     fn start(&self) -> *u8 {
         let this: *TypedArenaChunk<T> = self;
         unsafe {
-            cast::transmute(round_up(this.offset(1) as uint, min_align_of::<T>()))
+            mem::transmute(round_up(this.offset(1) as uint, min_align_of::<T>()))
         }
     }
 
@@ -463,12 +450,12 @@ pub fn with_capacity(capacity: uint) -> TypedArena<T> {
     pub fn alloc<'a>(&'a self, object: T) -> &'a T {
         unsafe {
             // FIXME #13933: Remove/justify all `&T` to `&mut T` transmutes
-            let this: &mut TypedArena<T> = cast::transmute::<&_, &mut _>(self);
+            let this: &mut TypedArena<T> = mem::transmute::<&_, &mut _>(self);
             if this.ptr == this.end {
                 this.grow()
             }
 
-            let ptr: &'a mut T = cast::transmute(this.ptr);
+            let ptr: &'a mut T = mem::transmute(this.ptr);
             mem::move_val_init(ptr, object);
             this.ptr = this.ptr.offset(1);
             let ptr: &'a T = ptr;
index 6763b32afd03b31f73ea928142d967526f66da70..3a797cc935461ac91ab8236eb5a8374f910bf015 100644 (file)
 // Backlinks over DList::prev are raw pointers that form a full chain in
 // the reverse direction.
 
-use std::cast;
 use std::iter::Rev;
 use std::iter;
-use std::mem::{replace, swap};
+use std::mem;
 use std::ptr;
 
 use deque::Deque;
@@ -93,13 +92,13 @@ fn resolve(&mut self) -> Option<&mut T> {
         if self.p.is_null() {
             None
         } else {
-            Some(unsafe { cast::transmute(self.p) })
+            Some(unsafe { mem::transmute(self.p) })
         }
     }
 
     /// Return the `Rawlink` and replace with `Rawlink::none()`
     fn take(&mut self) -> Rawlink<T> {
-        replace(self, Rawlink::none())
+        mem::replace(self, Rawlink::none())
     }
 }
 
@@ -159,7 +158,7 @@ fn push_front_node(&mut self, mut new_head: Box<Node<T>>) {
             Some(ref mut head) => {
                 new_head.prev = Rawlink::none();
                 head.prev = Rawlink::some(new_head);
-                swap(head, &mut new_head);
+                mem::swap(head, &mut new_head);
                 head.next = Some(new_head);
             }
         }
@@ -317,7 +316,7 @@ pub fn append(&mut self, mut other: DList<T>) {
     /// O(1)
     #[inline]
     pub fn prepend(&mut self, mut other: DList<T>) {
-        swap(self, &mut other);
+        mem::swap(self, &mut other);
         self.append(other);
     }
 
index 8249faad19a0865624350929cee69c1cd605b25e..41501f2d261ec01d502fcb94c77a6502e8a261b5 100644 (file)
@@ -137,7 +137,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 #[cfg(test)]
 mod test {
 
-    use std::cast;
+    use std::mem;
 
     use enum_set::{EnumSet, CLike};
 
@@ -153,7 +153,7 @@ fn to_uint(&self) -> uint {
         }
 
         fn from_uint(v: uint) -> Foo {
-            unsafe { cast::transmute(v) }
+            unsafe { mem::transmute(v) }
         }
     }
 
index 13297df902a077c8e407d7245d35ad4c35b6377a..c062fc74c1d0e8f767dd90e7b945ac301f38363f 100644 (file)
@@ -37,7 +37,6 @@
 //! assert!(cache.get(&2).is_none());
 //! ```
 
-use std::cast;
 use std::container::Container;
 use std::hash::Hash;
 use std::fmt;
@@ -93,7 +92,7 @@ pub fn new(capacity: uint) -> LruCache<K, V> {
         let cache = LruCache {
             map: HashMap::new(),
             max_size: capacity,
-            head: unsafe{ cast::transmute(box mem::uninit::<LruEntry<K, V>>()) },
+            head: unsafe{ mem::transmute(box mem::uninit::<LruEntry<K, V>>()) },
         };
         unsafe {
             (*cache.head).next = cache.head;
@@ -241,11 +240,11 @@ fn clear(&mut self) {
 impl<K, V> Drop for LruCache<K, V> {
     fn drop(&mut self) {
         unsafe {
-            let node: Box<LruEntry<K, V>> = cast::transmute(self.head);
+            let node: Box<LruEntry<K, V>> = mem::transmute(self.head);
             // Prevent compiler from trying to drop the un-initialized field in the sigil node.
             let box LruEntry { key: k, value: v, .. } = node;
-            cast::forget(k);
-            cast::forget(v);
+            mem::forget(k);
+            mem::forget(v);
         }
     }
 }
index 459015445eb6ac0881b0a170a46e9199adcdbadf..b0227fd60bfebcd5a256d58de57518f812adbbea 100644 (file)
@@ -20,7 +20,7 @@
 //! value. `Box<Any>` adds the `move` method, which will unwrap a `Box<T>` from the object.  See
 //! the extension traits (`*Ext`) for the full details.
 
-use cast::{transmute, transmute_copy};
+use mem::{transmute, transmute_copy};
 use option::{Option, Some, None};
 use owned::Box;
 use raw::TraitObject;
diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs
deleted file mode 100644 (file)
index cf99fdb..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Unsafe casting functions
-
-use mem;
-use intrinsics;
-use ptr::copy_nonoverlapping_memory;
-
-/**
- * Transform a value of one type into a value of another type.
- * Both types must have the same size and alignment.
- *
- * # Example
- *
- * ```rust
- * use std::cast;
- *
- * let v: &[u8] = unsafe { cast::transmute("L") };
- * assert!(v == [76u8]);
- * ```
- */
-#[inline]
-pub unsafe fn transmute<T, U>(thing: T) -> U {
-    intrinsics::transmute(thing)
-}
-
-/**
- * Move a thing into the void
- *
- * The forget function will take ownership of the provided value but neglect
- * to run any required cleanup or memory-management operations on it.
- */
-#[inline]
-pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
-
-/// Casts the value at `src` to U. The two types must have the same length.
-#[inline]
-pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
-    let mut dest: U = mem::uninit();
-    let dest_ptr: *mut u8 = transmute(&mut dest);
-    let src_ptr: *u8 = transmute(src);
-    copy_nonoverlapping_memory(dest_ptr, src_ptr, mem::size_of::<U>());
-    dest
-}
-
-/// Coerce an immutable reference to be mutable.
-#[inline]
-#[deprecated="casting &T to &mut T is undefined behaviour: use Cell<T>, RefCell<T> or Unsafe<T>"]
-pub unsafe fn transmute_mut<'a,T>(ptr: &'a T) -> &'a mut T { transmute(ptr) }
-
-/// Coerce a reference to have an arbitrary associated lifetime.
-#[inline]
-pub unsafe fn transmute_lifetime<'a,'b,T>(ptr: &'a T) -> &'b T {
-    transmute(ptr)
-}
-
-/// Coerce an immutable reference to be mutable.
-#[inline]
-pub unsafe fn transmute_mut_unsafe<T>(ptr: *T) -> *mut T {
-    transmute(ptr)
-}
-
-/// Coerce a mutable reference to have an arbitrary associated lifetime.
-#[inline]
-pub unsafe fn transmute_mut_lifetime<'a,'b,T>(ptr: &'a mut T) -> &'b mut T {
-    transmute(ptr)
-}
-
-/// Transforms lifetime of the second pointer to match the first.
-#[inline]
-pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
-    transmute_lifetime(ptr)
-}
-
-/// Transforms lifetime of the second pointer to match the first.
-#[inline]
-pub unsafe fn copy_mut_lifetime<'a,S,T>(_ptr: &'a mut S, ptr: &mut T) -> &'a mut T {
-    transmute_mut_lifetime(ptr)
-}
-
-/// Transforms lifetime of the second pointer to match the first.
-#[inline]
-pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
-    transmute_lifetime(ptr)
-}
-
-
-/****************************************************************************
- * Tests
- ****************************************************************************/
-
-#[cfg(test)]
-mod tests {
-    use cast::transmute;
-    use raw;
-    use realstd::str::StrAllocating;
-
-    #[test]
-    fn test_transmute_copy() {
-        assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) });
-    }
-
-    #[test]
-    fn test_transmute() {
-        unsafe {
-            let x = @100u8;
-            let x: *raw::Box<u8> = transmute(x);
-            assert!((*x).data == 100);
-            let _x: @int = transmute(x);
-        }
-    }
-
-    #[test]
-    fn test_transmute2() {
-        unsafe {
-            assert_eq!(box [76u8], transmute("L".to_owned()));
-        }
-    }
-}
index 1e31486c63f1c0670c0f8df291fe2487d9fb6cd1..7f2deb81f8c90c2a43622a2464111fc7ed9245dc 100644 (file)
@@ -24,7 +24,7 @@
 //! and, as such, should be performed via the `from_u32` function..
 
 
-use cast::transmute;
+use mem::transmute;
 use option::{None, Option, Some};
 use iter::{Iterator, range_step};
 use unicode::{derived_property, property, general_category, decompose, conversions};
index 6ef71d3360a752b0cba79d22f38ab2e0d5402989..148b63dfbfeaeec1ec7fc06e6b38a5e8aad9aab1 100644 (file)
@@ -112,12 +112,12 @@ pub mod marker {
     /// but does not actually *reference* that type parameter:
     ///
     /// ```ignore
-    /// use std::cast;
+    /// use std::mem;
     ///
     /// struct S<T> { x: *() }
     /// fn get<T>(s: &S<T>) -> T {
     ///    unsafe {
-    ///        let x: *T = cast::transmute(s.x);
+    ///        let x: *T = mem::transmute(s.x);
     ///        *x
     ///    }
     /// }
@@ -153,12 +153,12 @@ pub mod marker {
     /// but does not actually *reference* that type parameter:
     ///
     /// ```
-    /// use std::cast;
+    /// use std::mem;
     ///
     /// struct S<T> { x: *() }
     /// fn get<T>(s: &S<T>, v: T) {
     ///    unsafe {
-    ///        let x: fn(T) = cast::transmute(s.x);
+    ///        let x: fn(T) = mem::transmute(s.x);
     ///        x(v)
     ///    }
     /// }
index 38bce7a4741bf9ae7c38c969e2288f85255b625c..41719d1354a1697be17bc919b7694f6325490c82 100644 (file)
@@ -63,7 +63,6 @@
 
 /* Core modules for ownership management */
 
-pub mod cast;
 pub mod intrinsics;
 pub mod mem;
 pub mod ptr;
index 0bac90064d6f43bf3fe8760952e8f7dbbffeb05a..feb66f569645bde60ecc6fa5e5b702ca16d6db32 100644 (file)
@@ -13,7 +13,6 @@
 //! This module contains functions for querying the size and alignment of
 //! types, initializing and manipulating memory.
 
-use cast;
 use ptr;
 use intrinsics;
 use intrinsics::{bswap16, bswap32, bswap64};
@@ -239,7 +238,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
 
         // y and t now point to the same thing, but we need to completely forget `t`
         // because it's no longer relevant.
-        cast::forget(t);
+        forget(t);
     }
 }
 
@@ -286,14 +285,103 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
 }
 
 /// Disposes of a value.
+///
+/// This function can be used to destroy any value by allowing `drop` to take
+/// ownership of its argument.
+///
+/// # Example
+///
+/// ```
+/// use std::cell::RefCell;
+///
+/// let x = RefCell::new(1);
+///
+/// let mut mutable_borrow = x.borrow_mut();
+/// *mutable_borrow = 1;
+/// drop(mutable_borrow); // relinquish the mutable borrow on this slot
+///
+/// let borrow = x.borrow();
+/// println!("{}", *borrow);
+/// ```
 #[inline]
 pub fn drop<T>(_x: T) { }
 
+/// Moves a thing into the void.
+///
+/// The forget function will take ownership of the provided value but neglect
+/// to run any required cleanup or memory management operations on it.
+///
+/// This function is the unsafe version of the `drop` function because it does
+/// not run any destructors.
+#[inline]
+#[stable]
+pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing) }
+
+/// Unsafely transforms a value of one type into a value of another type.
+///
+/// Both types must have the same size and alignment, and this guarantee is
+/// enforced at compile-time.
+///
+/// # Example
+///
+/// ```rust
+/// use std::mem;
+///
+/// let v: &[u8] = unsafe { mem::transmute("L") };
+/// assert!(v == [76u8]);
+/// ```
+#[inline]
+#[unstable = "this function will be modified to reject invocations of it which \
+              cannot statically prove that T and U are the same size. For \
+              example, this function, as written today, will be rejected in \
+              the future because the size of T and U cannot be statically \
+              known to be the same"]
+pub unsafe fn transmute<T, U>(thing: T) -> U {
+    intrinsics::transmute(thing)
+}
+
+/// Interprets `src` as `&U`, and then reads `src` without moving the contained
+/// value.
+///
+/// This function will unsafely assume the pointer `src` is valid for
+/// `sizeof(U)` bytes by transmuting `&T` to `&U` and then reading the `&U`. It
+/// will also unsafely create a copy of the contained value instead of moving
+/// out of `src`.
+///
+/// It is not a compile-time error if `T` and `U` have different sizes, but it
+/// is highly encouraged to only invoke this function where `T` and `U` have the
+/// same size. This function triggers undefined behavior if `U` is larger than
+/// `T`.
+#[inline]
+#[stable]
+pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
+    ptr::read(src as *T as *U)
+}
+
+/// Transforms lifetime of the second pointer to match the first.
+#[inline]
+#[unstable = "this function may be removed in the future due to its \
+              questionable utility"]
+pub unsafe fn copy_lifetime<'a, S, T>(_ptr: &'a S, ptr: &T) -> &'a T {
+    transmute(ptr)
+}
+
+/// Transforms lifetime of the second mutable pointer to match the first.
+#[inline]
+#[unstable = "this function may be removed in the future due to its \
+              questionable utility"]
+pub unsafe fn copy_mut_lifetime<'a, S, T>(_ptr: &'a mut S,
+                                          ptr: &mut T) -> &'a mut T {
+    transmute(ptr)
+}
+
 #[cfg(test)]
 mod tests {
     use mem::*;
     use option::{Some,None};
     use realstd::str::StrAllocating;
+    use owned::Box;
+    use raw;
 
     #[test]
     fn size_of_basic() {
@@ -389,6 +477,28 @@ fn test_replace() {
         assert!(x.is_none());
         assert!(y.is_some());
     }
+
+    #[test]
+    fn test_transmute_copy() {
+        assert_eq!(1u, unsafe { ::mem::transmute_copy(&1) });
+    }
+
+    #[test]
+    fn test_transmute() {
+        trait Foo {}
+        impl Foo for int {}
+
+        let a = box 100 as Box<Foo>;
+        unsafe {
+            let x: raw::TraitObject = transmute(a);
+            assert!(*(x.data as *int) == 100);
+            let _x: Box<Foo> = transmute(x);
+        }
+
+        unsafe {
+            assert_eq!(box [76u8], transmute("L".to_owned()));
+        }
+    }
 }
 
 // FIXME #13642 (these benchmarks should be in another place)
index 2f8457e93f671b31725370c3a520c308481ff724..fd6d174a7036e29edd2481ef3b01ad94691515d8 100644 (file)
@@ -604,10 +604,10 @@ mod tests {
     fn test_get_ptr() {
         unsafe {
             let x = box 0;
-            let addr_x: *int = ::cast::transmute(&*x);
+            let addr_x: *int = ::mem::transmute(&*x);
             let opt = Some(x);
             let y = opt.unwrap();
-            let addr_y: *int = ::cast::transmute(&*y);
+            let addr_y: *int = ::mem::transmute(&*y);
             assert_eq!(addr_x, addr_y);
         }
     }
index bb587c0e42d03cd186e70b82b7d4db1f5ae9e38d..438e18d999b6c77b5369b8b01aafa02b16e07688 100644 (file)
 //! though unsafely, transformed from one type to the other.
 //!
 //! ```
-//! use std::cast;
+//! use std::mem;
 //!
 //! unsafe {
 //!     let my_num: Box<int> = box 10;
-//!     let my_num: *int = cast::transmute(my_num);
+//!     let my_num: *int = mem::transmute(my_num);
 //!     let my_speed: Box<int> = box 88;
-//!     let my_speed: *mut int = cast::transmute(my_speed);
+//!     let my_speed: *mut int = mem::transmute(my_speed);
 //!
 //!     // By taking ownership of the original `Box<T>` though
 //!     // we are obligated to transmute it back later to be destroyed.
-//!     drop(cast::transmute::<_, Box<int>>(my_speed));
-//!     drop(cast::transmute::<_, Box<int>>(my_num));
+//!     drop(mem::transmute::<_, Box<int>>(my_speed));
+//!     drop(mem::transmute::<_, Box<int>>(my_num));
 //! }
 //! ```
 //!
 //! but C APIs hand out a lot of pointers generally, so are a common source
 //! of unsafe pointers in Rust.
 
-use cast;
+use mem;
 use clone::Clone;
 use intrinsics;
 use iter::{range, Iterator};
-use mem;
 use option::{Some, None, Option};
 
 #[cfg(not(test))] use cmp::{Eq, TotalEq, Ord, Equiv};
@@ -196,7 +195,6 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) {
 /// A safe swap function:
 ///
 /// ```
-/// use std::cast;
 /// use std::mem;
 /// use std::ptr;
 ///
@@ -212,7 +210,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) {
 ///
 ///         // y and t now point to the same thing, but we need to completely forget `tmp`
 ///         // because it's no longer relevant.
-///         cast::forget(t);
+///         mem::forget(t);
 ///     }
 /// }
 /// ```
@@ -256,14 +254,14 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
 
     // y and t now point to the same thing, but we need to completely forget `tmp`
     // because it's no longer relevant.
-    cast::forget(tmp);
+    mem::forget(tmp);
 }
 
 /// Replace the value at a mutable location with a new one, returning the old
 /// value, without deinitialising either.
 #[inline]
 pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
-    mem::swap(cast::transmute(dest), &mut src); // cannot overlap
+    mem::swap(mem::transmute(dest), &mut src); // cannot overlap
     src
 }
 
@@ -361,7 +359,7 @@ unsafe fn to_option(&self) -> Option<&T> {
         if self.is_null() {
             None
         } else {
-            Some(cast::transmute(*self))
+            Some(mem::transmute(*self))
         }
     }
 }
@@ -386,7 +384,7 @@ unsafe fn to_option(&self) -> Option<&T> {
         if self.is_null() {
             None
         } else {
-            Some(cast::transmute(*self))
+            Some(mem::transmute(*self))
         }
     }
 }
@@ -436,14 +434,14 @@ fn equiv(&self, other: &*T) -> bool {
 // Equality for extern "C" fn pointers
 #[cfg(not(test))]
 mod externfnpointers {
-    use cast;
+    use mem;
     use cmp::Eq;
 
     impl<_R> Eq for extern "C" fn() -> _R {
         #[inline]
         fn eq(&self, other: &extern "C" fn() -> _R) -> bool {
-            let self_: *() = unsafe { cast::transmute(*self) };
-            let other_: *() = unsafe { cast::transmute(*other) };
+            let self_: *() = unsafe { mem::transmute(*self) };
+            let other_: *() = unsafe { mem::transmute(*other) };
             self_ == other_
         }
     }
@@ -452,8 +450,8 @@ macro_rules! fnptreq(
             impl<_R,$($p),*> Eq for extern "C" fn($($p),*) -> _R {
                 #[inline]
                 fn eq(&self, other: &extern "C" fn($($p),*) -> _R) -> bool {
-                    let self_: *() = unsafe { cast::transmute(*self) };
-                    let other_: *() = unsafe { cast::transmute(*other) };
+                    let self_: *() = unsafe { mem::transmute(*self) };
+                    let other_: *() = unsafe { mem::transmute(*other) };
                     self_ == other_
                 }
             }
@@ -485,7 +483,7 @@ pub mod ptr_tests {
     use realstd::prelude::*;
 
     use realstd::c_str::ToCStr;
-    use cast;
+    use mem;
     use libc;
     use realstd::str;
     use slice::{ImmutableVector, MutableVector};
@@ -499,7 +497,7 @@ struct Pair {
             };
             let mut p = Pair {fst: 10, snd: 20};
             let pptr: *mut Pair = &mut p;
-            let iptr: *mut int = cast::transmute(pptr);
+            let iptr: *mut int = mem::transmute(pptr);
             assert_eq!(*iptr, 10);
             *iptr = 30;
             assert_eq!(*iptr, 30);
index d6caa145ae9c8abccd549dcb774cf5fe8da0df9a..25f40b358ab259fbb0df60d4fa9feac6a4b3b673 100644 (file)
@@ -18,7 +18,7 @@
 //!
 //! Their definition should always match the ABI defined in `rustc::back::abi`.
 
-use cast;
+use mem;
 
 /// The representation of a Rust managed box
 pub struct Box<T> {
@@ -74,7 +74,7 @@ pub trait Repr<T> {
     /// for the struct. This is a safe method because by default it does not
     /// enable write-access to the fields of the return value in safe code.
     #[inline]
-    fn repr(&self) -> T { unsafe { cast::transmute_copy(self) } }
+    fn repr(&self) -> T { unsafe { mem::transmute_copy(self) } }
 }
 
 impl<'a, T> Repr<Slice<T>> for &'a [T] {}
@@ -87,7 +87,7 @@ impl Repr<*String> for ~str {}
 mod tests {
     use super::*;
 
-    use cast;
+    use mem;
 
     #[test]
     fn synthesize_closure() {
@@ -97,7 +97,7 @@ fn synthesize_closure() {
 
             assert_eq!(f(20), 30);
 
-            let original_closure: Closure = cast::transmute(f);
+            let original_closure: Closure = mem::transmute(f);
 
             let actual_function_pointer = original_closure.code;
             let environment = original_closure.env;
@@ -107,7 +107,7 @@ fn synthesize_closure() {
                 env: environment
             };
 
-            let new_f: |int| -> int = cast::transmute(new_closure);
+            let new_f: |int| -> int = mem::transmute(new_closure);
             assert_eq!(new_f(20), 30);
         }
     }
index f199aa051d1663416c00d97c8f2be5944c98119e..d8df20218c5ad2def2e2afce6081f3927f69af43 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use cast;
 use char::Char;
 use clone::Clone;
 use container::Container;
@@ -73,7 +72,7 @@ fn default() -> ~str {
             (*ptr).fill = 0;
             (*ptr).alloc = 0;
 
-            cast::transmute(ptr)
+            mem::transmute(ptr)
         }
     }
 }
@@ -91,7 +90,7 @@ fn clone(&self) -> ~str {
             (*ptr).fill = len;
             (*ptr).alloc = len;
 
-            cast::transmute(ptr)
+            mem::transmute(ptr)
         }
     }
 }
@@ -106,7 +105,7 @@ fn from_iter<T: Iterator<char>>(mut iterator: T) -> ~str {
 
         unsafe {
             let mut ptr = alloc(cap) as *mut Vec<u8>;
-            let mut ret = cast::transmute(ptr);
+            let mut ret = mem::transmute(ptr);
             for ch in iterator {
                 let amt = ch.encode_utf8(tmp);
 
@@ -121,8 +120,8 @@ fn from_iter<T: Iterator<char>>(mut iterator: T) -> ~str {
                                                     len);
                     // FIXME: #13994: port to the sized deallocation API when available
                     rust_free(ptr as *u8, 0, 8);
-                    cast::forget(ret);
-                    ret = cast::transmute(ptr2);
+                    mem::forget(ret);
+                    ret = mem::transmute(ptr2);
                     ptr = ptr2;
                 }
 
@@ -155,7 +154,7 @@ fn add(&self, rhs: & &'a str) -> ~str {
                                             rhs.len());
             (*ptr).fill = amt;
             (*ptr).alloc = amt;
-            cast::transmute(ptr)
+            mem::transmute(ptr)
         }
     }
 }
@@ -192,7 +191,7 @@ fn clone(&self) -> ~[A] {
                     }
                     rust_free(ret as *u8, 0, 8);
                 });
-            cast::transmute(ret)
+            mem::transmute(ret)
         }
     }
 }
index b828ad3361effbab67a7201cee2476daea64f7d1..11309b44a6006ea65d5cc64b1e5692e3d7b06b5d 100644 (file)
@@ -12,8 +12,7 @@
 //!
 //! For more details `std::slice`.
 
-use cast;
-use cast::transmute;
+use mem::transmute;
 use clone::Clone;
 use container::Container;
 use cmp::{Eq, TotalOrd, Ordering, Less, Equal, Greater};
@@ -1012,7 +1011,7 @@ fn mut_slice_to(self, end: uint) -> &'a mut [T] {
     fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]) {
         unsafe {
             let len = self.len();
-            let self2: &'a mut [T] = cast::transmute_copy(&self);
+            let self2: &'a mut [T] = mem::transmute_copy(&self);
             (self.mut_slice(0, mid), self2.mut_slice(mid, len))
         }
     }
@@ -1162,7 +1161,7 @@ fn copy_from(self, src: &[T]) -> uint {
 
 /// Unsafe operations
 pub mod raw {
-    use cast::transmute;
+    use mem::transmute;
     use iter::Iterator;
     use ptr::RawPtr;
     use raw::Slice;
index 689f59b471c90402c7ec9298d15d8bc697f8e58d..e677c4880b58db0d5d12226ab6368845341f12e0 100644 (file)
@@ -12,8 +12,7 @@
 //!
 //! For more details, see std::str
 
-use cast::transmute;
-use cast;
+use mem;
 use char;
 use clone::Clone;
 use cmp::{Eq, TotalEq};
@@ -572,7 +571,7 @@ fn next(&mut self) -> Option<UTF16Item> {
 
         if u < 0xD800 || 0xDFFF < u {
             // not a surrogate
-            Some(ScalarValue(unsafe {cast::transmute(u as u32)}))
+            Some(ScalarValue(unsafe {mem::transmute(u as u32)}))
         } else if u >= 0xDC00 {
             // a trailing surrogate
             Some(LoneSurrogate(u))
@@ -594,7 +593,7 @@ fn next(&mut self) -> Option<UTF16Item> {
 
             // all ok, so lets decode it.
             let c = ((u - 0xD800) as u32 << 10 | (u2 - 0xDC00) as u32) + 0x1_0000;
-            Some(ScalarValue(unsafe {cast::transmute(c)}))
+            Some(ScalarValue(unsafe {mem::transmute(c)}))
         }
     }
 
@@ -710,7 +709,7 @@ macro_rules! utf8_acc_cont_byte(
 
 /// Unsafe operations
 pub mod raw {
-    use cast;
+    use mem;
     use container::Container;
     use iter::Iterator;
     use ptr::RawPtr;
@@ -721,7 +720,7 @@ pub mod raw {
     /// Converts a slice of bytes to a string slice without checking
     /// that the string contains valid UTF-8.
     pub unsafe fn from_utf8<'a>(v: &'a [u8]) -> &'a str {
-        cast::transmute(v)
+        mem::transmute(v)
     }
 
     /// Form a slice from a C string. Unsafe because the caller must ensure the
@@ -736,8 +735,8 @@ pub unsafe fn c_str_to_static_slice(s: *i8) -> &'static str {
             curr = s.offset(len as int);
         }
         let v = Slice { data: s, len: len };
-        assert!(is_utf8(::cast::transmute(v)));
-        ::cast::transmute(v)
+        assert!(is_utf8(::mem::transmute(v)));
+        ::mem::transmute(v)
     }
 
     /// Takes a bytewise (not UTF-8) slice from a string.
@@ -762,7 +761,7 @@ pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str {
     /// Caller must check slice boundaries!
     #[inline]
     pub unsafe fn slice_unchecked<'a>(s: &'a str, begin: uint, end: uint) -> &'a str {
-        cast::transmute(Slice {
+        mem::transmute(Slice {
                 data: s.as_ptr().offset(begin as int),
                 len: end - begin,
             })
@@ -1747,7 +1746,7 @@ fn multibyte_char_range_at(s: &str, i: uint) -> CharRange {
             if w > 2 { val = utf8_acc_cont_byte!(val, s[i + 2]); }
             if w > 3 { val = utf8_acc_cont_byte!(val, s[i + 3]); }
 
-            return CharRange {ch: unsafe { transmute(val) }, next: i + w};
+            return CharRange {ch: unsafe { mem::transmute(val) }, next: i + w};
         }
 
         return multibyte_char_range_at(*self, i);
@@ -1776,7 +1775,7 @@ fn multibyte_char_range_at_reverse(s: &str, mut i: uint) -> CharRange {
             if w > 2 { val = utf8_acc_cont_byte!(val, s[i + 2]); }
             if w > 3 { val = utf8_acc_cont_byte!(val, s[i + 3]); }
 
-            return CharRange {ch: unsafe { transmute(val) }, next: i};
+            return CharRange {ch: unsafe { mem::transmute(val) }, next: i};
         }
 
         return multibyte_char_range_at_reverse(*self, prev);
@@ -1794,7 +1793,7 @@ fn char_at_reverse(&self, i: uint) -> char {
 
     #[inline]
     fn as_bytes(&self) -> &'a [u8] {
-        unsafe { cast::transmute(*self) }
+        unsafe { mem::transmute(*self) }
     }
 
     fn find<C: CharEq>(&self, mut search: C) -> Option<uint> {
index 0c9f0b02fdf0a2a38152273816550965143bb84e..47a2005fef1e6e9f9ab979aa4cfcef26cf469aa8 100644 (file)
@@ -10,7 +10,6 @@
 
 //! Types dealing with unsafe actions.
 
-use cast;
 use kinds::marker;
 
 /// Unsafe type that wraps a type T and indicates unsafe interior operations on the
@@ -63,7 +62,7 @@ pub fn new(value: T) -> Unsafe<T> {
 
     /// Gets a mutable pointer to the wrapped value
     #[inline]
-    pub unsafe fn get(&self) -> *mut T { cast::transmute_mut_unsafe(&self.value) }
+    pub unsafe fn get(&self) -> *mut T { &self.value as *T as *mut T }
 
     /// Unwraps the value
     #[inline]
index eba15e6e6d5a8eaa568c916a8c4ab48c97361fcf..9e42e2f67c485042e725d277e2f47822f720e5cb 100644 (file)
@@ -15,8 +15,7 @@
 //! This implementation is also used as the fallback implementation of an event
 //! loop if no other one is provided (and M:N scheduling is desired).
 
-use std::cast;
-use std::mem::replace;
+use std::mem;
 use std::rt::rtio::{EventLoop, IoFactory, RemoteCallback};
 use std::rt::rtio::{PausableIdleCallback, Callback};
 use std::unstable::sync::Exclusive;
@@ -50,7 +49,7 @@ fn new() -> BasicLoop {
     /// Process everything in the work queue (continually)
     fn work(&mut self) {
         while self.work.len() > 0 {
-            for work in replace(&mut self.work, vec![]).move_iter() {
+            for work in mem::replace(&mut self.work, vec![]).move_iter() {
                 work();
             }
         }
@@ -60,7 +59,7 @@ fn remote_work(&mut self) {
         let messages = unsafe {
             self.messages.with(|messages| {
                 if messages.len() > 0 {
-                    Some(replace(messages, vec![]))
+                    Some(mem::replace(messages, vec![]))
                 } else {
                     None
                 }
@@ -145,7 +144,7 @@ fn pausable_idle_callback(&mut self, cb: Box<Callback:Send>)
         let callback = box BasicPausable::new(self, cb);
         rtassert!(self.idle.is_none());
         unsafe {
-            let cb_ptr: &*mut BasicPausable = cast::transmute(&callback);
+            let cb_ptr: &*mut BasicPausable = mem::transmute(&callback);
             self.idle = Some(*cb_ptr);
         }
         callback as Box<PausableIdleCallback:Send>
index e5dd9c92358f0df0c65bec1612a33add63317309..0a13ffa0b5e314b0fb0061d17753c32ce8c09f9d 100644 (file)
@@ -10,7 +10,7 @@
 
 use stack::Stack;
 use std::uint;
-use std::cast::{transmute, transmute_mut_unsafe};
+use std::mem::transmute;
 use std::rt::stack;
 use std::raw;
 
@@ -50,7 +50,7 @@ pub fn new(init: InitFn, arg: uint, start: proc():Send,
                stack: &mut Stack) -> Context {
 
         let sp: *uint = stack.end();
-        let sp: *mut uint = unsafe { transmute_mut_unsafe(sp) };
+        let sp: *mut uint = sp as *mut uint;
         // Save and then immediately load the current context,
         // which we will then modify to call the given function when restored
         let mut regs = new_regs();
index 301198a0676400caf2e61ca8a30310c877623611..8c294fa2928f0a5e35f31e37e6becb8d3069b89b 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
+use std::mem;
 use std::rt::local::Local;
 use std::rt::rtio::{RemoteCallback, PausableIdleCallback, Callback, EventLoop};
 use std::rt::task::BlockedTask;
@@ -633,7 +633,7 @@ pub fn change_task_context(mut ~self,
         unsafe {
 
             let sched: &mut Scheduler =
-                cast::transmute_mut_lifetime(*next_task.sched.get_mut_ref());
+                mem::transmute(&**next_task.sched.get_mut_ref());
 
             let current_task: &mut GreenTask = match sched.cleanup_job {
                 Some(CleanupJob { task: ref mut task, .. }) => &mut **task,
@@ -647,7 +647,7 @@ pub fn change_task_context(mut ~self,
             // works because due to transmute the borrow checker
             // believes that we have no internal pointers to
             // next_task.
-            cast::forget(next_task);
+            mem::forget(next_task);
 
             // The raw context swap operation. The next action taken
             // will be running the cleanup job from the context of the
@@ -659,7 +659,7 @@ pub fn change_task_context(mut ~self,
         // run the cleanup job, as expected by the previously called
         // swap_contexts function.
         let mut current_task: Box<GreenTask> = unsafe {
-            cast::transmute(current_task_dupe)
+            mem::transmute(current_task_dupe)
         };
         current_task.sched.get_mut_ref().run_cleanup_job();
 
@@ -677,15 +677,17 @@ pub fn change_task_context(mut ~self,
     // references to keep even when we don't own the tasks. It looks
     // kinda safe because we are doing transmutes before passing in
     // the arguments.
-    pub fn get_contexts<'a>(current_task: &mut GreenTask, next_task: &mut GreenTask) ->
-        (&'a mut Context, &'a mut Context) {
+    pub fn get_contexts<'a>(current_task: &mut GreenTask,
+                            next_task: &mut GreenTask)
+        -> (&'a mut Context, &'a mut Context)
+    {
         let current_task_context =
             &mut current_task.coroutine.get_mut_ref().saved_context;
         let next_task_context =
                 &mut next_task.coroutine.get_mut_ref().saved_context;
         unsafe {
-            (cast::transmute_mut_lifetime(current_task_context),
-             cast::transmute_mut_lifetime(next_task_context))
+            (mem::transmute(current_task_context),
+             mem::transmute(next_task_context))
         }
     }
 
@@ -961,10 +963,10 @@ trait ClosureConverter {
 }
 impl ClosureConverter for UnsafeTaskReceiver {
     fn from_fn(f: |&mut Scheduler, Box<GreenTask>|) -> UnsafeTaskReceiver {
-        unsafe { cast::transmute(f) }
+        unsafe { mem::transmute(f) }
     }
     fn to_fn(self) -> |&mut Scheduler, Box<GreenTask>| {
-        unsafe { cast::transmute(self) }
+        unsafe { mem::transmute(self) }
     }
 }
 
index 007084fa14d783c15a3ace318f286084482c7f5c..49aef15f93b61bd24d6a091fffc2d09106c3b38e 100644 (file)
@@ -12,7 +12,7 @@
 //! scheduler pool and then interacting with it.
 
 use std::any::Any;
-use std::cast;
+use std::mem;
 use std::rt::Runtime;
 use std::rt::local::Local;
 use std::rt::rtio;
@@ -48,10 +48,10 @@ fn deschedule(mut ~self, times: uint, mut cur_task: Box<Task>,
                         guard.wait();
                     }
                 }
-                Err(task) => { cast::forget(task.wake()); }
+                Err(task) => { mem::forget(task.wake()); }
             }
             drop(guard);
-            cur_task = cast::transmute(cur_dupe);
+            cur_task = mem::transmute(cur_dupe);
         }
         Local::put(cur_task);
     }
@@ -59,7 +59,7 @@ fn reawaken(mut ~self, mut to_wake: Box<Task>) {
         let me = &mut *self as *mut SimpleTask;
         to_wake.put_runtime(self);
         unsafe {
-            cast::forget(to_wake);
+            mem::forget(to_wake);
             let guard = (*me).lock.lock();
             (*me).awoken = true;
             guard.signal();
index bc7752e98ea5ef7e855b0e5dbc49b133ddd33f3f..f50f65af6f9ebe83a8b9fcbb1ddd3a1341df72dd 100644 (file)
@@ -19,7 +19,7 @@
 //! values.
 
 use std::any::Any;
-use std::cast;
+use std::mem;
 use std::raw;
 use std::rt::Runtime;
 use std::rt::env;
@@ -93,11 +93,11 @@ pub enum Home {
 extern fn bootstrap_green_task(task: uint, code: *(), env: *()) -> ! {
     // Acquire ownership of the `proc()`
     let start: proc() = unsafe {
-        cast::transmute(raw::Procedure { code: code, env: env })
+        mem::transmute(raw::Procedure { code: code, env: env })
     };
 
     // Acquire ownership of the `Box<GreenTask>`
-    let mut task: Box<GreenTask> = unsafe { cast::transmute(task) };
+    let mut task: Box<GreenTask> = unsafe { mem::transmute(task) };
 
     // First code after swap to this new context. Run our cleanup job
     task.pool_id = {
@@ -271,7 +271,7 @@ pub fn as_uint(&self) -> uint {
     }
 
     pub unsafe fn from_uint(val: uint) -> Box<GreenTask> {
-        cast::transmute(val)
+        mem::transmute(val)
     }
 
     // Runtime glue functions and helpers
index 09e9cd83f3d4fdbe20db7c14bfeb4a4cd7426231..dbff4150d7274bd30d2c53a69628eda163c84111 100644 (file)
@@ -118,10 +118,10 @@ fn main() {
 
 extern crate sync;
 
-use std::cast;
 use std::fmt;
 use std::io::LineBufferedWriter;
 use std::io;
+use std::mem;
 use std::os;
 use std::rt;
 use std::slice;
@@ -343,13 +343,13 @@ fn init() {
         LOG_LEVEL = max_level;
 
         assert!(DIRECTIVES.is_null());
-        DIRECTIVES = cast::transmute(box directives);
+        DIRECTIVES = mem::transmute(box directives);
 
         // Schedule the cleanup for this global for when the runtime exits.
         rt::at_exit(proc() {
             assert!(!DIRECTIVES.is_null());
             let _directives: Box<Vec<directive::LogDirective>> =
-                cast::transmute(DIRECTIVES);
+                mem::transmute(DIRECTIVES);
             DIRECTIVES = 0 as *Vec<directive::LogDirective>;
         });
     }
index 57b87f21521e8221844e230b806f2888fcf12f45..8ebae70f73c04c0e08120e2e620dc8fca7c5f300 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 use ai = std::io::net::addrinfo;
+use libc::{c_char, c_int};
+use libc;
 use std::c_str::CString;
-use std::cast;
 use std::io::IoError;
-use libc;
-use libc::{c_char, c_int};
+use std::mem;
 use std::ptr::{null, mut_null};
 
 use super::net::sockaddr_to_addr;
@@ -61,7 +61,7 @@ pub fn run(host: Option<&str>, servname: Option<&str>,
         let mut rp = res;
         while rp.is_not_null() {
             unsafe {
-                let addr = match sockaddr_to_addr(cast::transmute((*rp).ai_addr),
+                let addr = match sockaddr_to_addr(mem::transmute((*rp).ai_addr),
                                                   (*rp).ai_addrlen as uint) {
                     Ok(a) => a,
                     Err(e) => return Err(e)
index 5fc9e506cf2677c4fb49d65deb9cd54a7189481a..fc08a7f128fec54bf440ae7d3f195ce13cf97479 100644 (file)
@@ -11,7 +11,6 @@
 //! Blocking win32-based file I/O
 
 use std::c_str::CString;
-use std::cast;
 use std::io::IoError;
 use std::io;
 use libc::{c_int, c_void};
@@ -175,7 +174,7 @@ fn tell(&self) -> Result<u64, IoError> {
         // This transmute is fine because our seek implementation doesn't
         // actually use the mutable self at all.
         // FIXME #13933: Remove/justify all `&T` to `&mut T` transmutes
-        unsafe { cast::transmute::<&_, &mut FileDesc>(self).seek(0, io::SeekCur) }
+        unsafe { mem::transmute::<&_, &mut FileDesc>(self).seek(0, io::SeekCur) }
     }
 
     fn fsync(&mut self) -> Result<(), IoError> {
index 218f8a4ef4994ba4f3c6b6daa86e939f048dabb3..40b66cc526f2aa8968d3b086418fe3aac370cda7 100644 (file)
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 use libc;
-use std::cast;
 use std::io::net::ip;
 use std::io;
 use std::mem;
@@ -72,14 +71,14 @@ fn addr_to_sockaddr(addr: ip::SocketAddr) -> (libc::sockaddr_storage, uint) {
         let storage: libc::sockaddr_storage = mem::init();
         let len = match ip_to_inaddr(addr.ip) {
             InAddr(inaddr) => {
-                let storage: *mut libc::sockaddr_in = cast::transmute(&storage);
+                let storage: *mut libc::sockaddr_in = mem::transmute(&storage);
                 (*storage).sin_family = libc::AF_INET as libc::sa_family_t;
                 (*storage).sin_port = htons(addr.port);
                 (*storage).sin_addr = inaddr;
                 mem::size_of::<libc::sockaddr_in>()
             }
             In6Addr(inaddr) => {
-                let storage: *mut libc::sockaddr_in6 = cast::transmute(&storage);
+                let storage: *mut libc::sockaddr_in6 = mem::transmute(&storage);
                 (*storage).sin6_family = libc::AF_INET6 as libc::sa_family_t;
                 (*storage).sin6_port = htons(addr.port);
                 (*storage).sin6_addr = inaddr;
@@ -173,7 +172,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
         libc::AF_INET => {
             assert!(len as uint >= mem::size_of::<libc::sockaddr_in>());
             let storage: &libc::sockaddr_in = unsafe {
-                cast::transmute(storage)
+                mem::transmute(storage)
             };
             let addr = storage.sin_addr.s_addr as u32;
             let a = (addr >>  0) as u8;
@@ -188,7 +187,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
         libc::AF_INET6 => {
             assert!(len as uint >= mem::size_of::<libc::sockaddr_in6>());
             let storage: &libc::sockaddr_in6 = unsafe {
-                cast::transmute(storage)
+                mem::transmute(storage)
             };
             let a = ntohs(storage.sin6_addr.s6_addr[0]);
             let b = ntohs(storage.sin6_addr.s6_addr[1]);
index 36ae2ba06d52b562a14e4f9853bc776a1aabbf66..d66075f44190daef3a93c0b7d720e4fbacf251c4 100644 (file)
@@ -10,7 +10,6 @@
 
 use libc;
 use std::c_str::CString;
-use std::cast;
 use std::intrinsics;
 use std::io;
 use std::mem;
@@ -36,7 +35,7 @@ fn addr_to_sockaddr_un(addr: &CString) -> IoResult<(libc::sockaddr_storage, uint
     assert!(mem::size_of::<libc::sockaddr_storage>() >=
             mem::size_of::<libc::sockaddr_un>());
     let mut storage: libc::sockaddr_storage = unsafe { intrinsics::init() };
-    let s: &mut libc::sockaddr_un = unsafe { cast::transmute(&mut storage) };
+    let s: &mut libc::sockaddr_un = unsafe { mem::transmute(&mut storage) };
 
     let len = addr.len();
     if len > s.sun_path.len() - 1 {
index c83af20d1d84eac884ed7dd2b83372f2500f40a8..81c76bba7a0eb36522034f21c85a5743473fbb62 100644 (file)
@@ -19,7 +19,7 @@
 use super::IoResult;
 use super::file;
 
-#[cfg(windows)] use std::cast;
+#[cfg(windows)] use std::mem;
 #[cfg(windows)] use std::strbuf::StrBuf;
 #[cfg(not(windows))] use super::retry;
 
@@ -326,7 +326,7 @@ fn spawn_process_os(config: p::ProcessConfig,
         with_envp(env, |envp| {
             with_dirp(dir, |dirp| {
                 cmd.with_c_str(|cmdp| {
-                    let created = CreateProcessA(ptr::null(), cast::transmute(cmdp),
+                    let created = CreateProcessA(ptr::null(), mem::transmute(cmdp),
                                                  ptr::mut_null(), ptr::mut_null(), TRUE,
                                                  flags, envp, dirp, &mut si,
                                                  &mut pi);
@@ -714,7 +714,7 @@ fn with_dirp<T>(d: Option<&Path>, cb: |*libc::c_char| -> T) -> T {
 #[cfg(windows)]
 fn free_handle(handle: *()) {
     assert!(unsafe {
-        libc::CloseHandle(cast::transmute(handle)) != 0
+        libc::CloseHandle(mem::transmute(handle)) != 0
     })
 }
 
index 3bf967cb4263c0de9ac474f75902bf61743f68e6..95b2620f3c7987e1989bc03c0921bbbe21e6d870 100644 (file)
@@ -20,7 +20,7 @@
 //! can be created in the future and there must be no active timers at that
 //! time.
 
-use std::cast;
+use std::mem;
 use std::rt::bookkeeping;
 use std::rt;
 use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
@@ -48,7 +48,7 @@ pub fn boot(helper: fn(imp::signal, Receiver<Req>)) {
             let (tx, rx) = channel();
             // promote this to a shared channel
             drop(tx.clone());
-            HELPER_CHAN = cast::transmute(box tx);
+            HELPER_CHAN = mem::transmute(box tx);
             let (receive, send) = imp::new();
             HELPER_SIGNAL = send;
 
@@ -86,7 +86,7 @@ fn shutdown() {
     // Clean up after ther helper thread
     unsafe {
         imp::close(HELPER_SIGNAL);
-        let _chan: Box<Sender<Req>> = cast::transmute(HELPER_CHAN);
+        let _chan: Box<Sender<Req>> = mem::transmute(HELPER_CHAN);
         HELPER_CHAN = 0 as *mut Sender<Req>;
         HELPER_SIGNAL = 0 as imp::signal;
     }
index 4c0c4dcc18e9e187da643c2a72e6fb49aedde08d..0df45f7d5a0a92cbb7ab011e9ed23ef8b1f6d0cc 100644 (file)
@@ -73,9 +73,9 @@
 #[lang = "start"]
 #[cfg(not(test))]
 pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
-    use std::cast;
+    use std::mem;
     start(argc, argv, proc() {
-        let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
+        let main: extern "Rust" fn() = unsafe { mem::transmute(main) };
         main();
     })
 }
index d5b02dc007b901474b84b0338e441f0835438a26..4183dec19d02dfe1e074f13e8e50a6cded147ce3 100644 (file)
@@ -15,7 +15,7 @@
 //! in order to spawn new tasks and deschedule the current task.
 
 use std::any::Any;
-use std::cast;
+use std::mem;
 use std::rt::bookkeeping;
 use std::rt::env;
 use std::rt::local::Local;
@@ -169,7 +169,7 @@ fn can_block(&self) -> bool { true }
     // for both tasks because these operations are all done inside of a mutex.
     //
     // You'll also find that if blocking fails (the `f` function hands the
-    // BlockedTask back to us), we will `cast::forget` the handles. The
+    // BlockedTask back to us), we will `mem::forget` the handles. The
     // reasoning for this is the same logic as above in that the task silently
     // transfers ownership via the `uint`, not through normal compiler
     // semantics.
@@ -198,7 +198,7 @@ fn deschedule(mut ~self, times: uint, mut cur_task: Box<Task>,
                             guard.wait();
                         }
                     }
-                    Err(task) => { cast::forget(task.wake()); }
+                    Err(task) => { mem::forget(task.wake()); }
                 }
             } else {
                 let iter = task.make_selectable(times);
@@ -217,7 +217,7 @@ fn deschedule(mut ~self, times: uint, mut cur_task: Box<Task>,
                     Some(task) => {
                         match task.wake() {
                             Some(task) => {
-                                cast::forget(task);
+                                mem::forget(task);
                                 (*me).awoken = true;
                             }
                             None => {}
@@ -229,7 +229,7 @@ fn deschedule(mut ~self, times: uint, mut cur_task: Box<Task>,
                 }
             }
             // re-acquire ownership of the task
-            cur_task = cast::transmute(cur_task_dupe);
+            cur_task = mem::transmute(cur_task_dupe);
         }
 
         // put the task back in TLS, and everything is as it once was.
@@ -242,7 +242,7 @@ fn reawaken(mut ~self, mut to_wake: Box<Task>) {
         unsafe {
             let me = &mut *self as *mut Ops;
             to_wake.put_runtime(self);
-            cast::forget(to_wake);
+            mem::forget(to_wake);
             let guard = (*me).lock.lock();
             (*me).awoken = true;
             guard.signal();
index 05d0160cfe9dc3f119e7d78713a9bd01e594a9e6..03c87eb931d604428fead709072ffa1ba6d572b9 100644 (file)
@@ -18,7 +18,7 @@
 ///
 /// See `Exp` for the general exponential distribution.Note that this
  // has to be unwrapped before use as an `f64` (using either
-/// `*` or `cast::transmute` is safe).
+/// `*` or `mem::transmute` is safe).
 ///
 /// Implemented via the ZIGNOR variant[1] of the Ziggurat method. The
 /// exact description in the paper was adjusted to use tables for the
index 5755ad00223eb63b2ead076fd859f032e4f3e5ce..dea73945b4384058a5e23c4a0bdb91f147942dda 100644 (file)
@@ -19,7 +19,7 @@
 ///
 /// See `Normal` for the general normal distribution. That this has to
 /// be unwrapped before use as an `f64` (using either `*` or
-/// `cast::transmute` is safe).
+/// `mem::transmute` is safe).
 ///
 /// Implemented via the ZIGNOR variant[1] of the Ziggurat method.
 ///
index cb27f2f0ff82166eca0f770cb954272d48ace3f6..006c4d89e2f8523bbe8c2e937a7676739ec1f946 100644 (file)
@@ -76,9 +76,9 @@
 #[cfg(test)]
 #[phase(syntax, link)] extern crate log;
 
-use std::cast;
 use std::io::IoResult;
 use std::kinds::marker;
+use std::mem;
 use std::strbuf::StrBuf;
 
 pub use isaac::{IsaacRng, Isaac64Rng};
@@ -454,11 +454,11 @@ impl<'a> SeedableRng<&'a [uint]> for StdRng {
     fn reseed(&mut self, seed: &'a [uint]) {
         // the internal RNG can just be seeded from the above
         // randomness.
-        self.rng.reseed(unsafe {cast::transmute(seed)})
+        self.rng.reseed(unsafe {mem::transmute(seed)})
     }
 
     fn from_seed(seed: &'a [uint]) -> StdRng {
-        StdRng { rng: SeedableRng::from_seed(unsafe {cast::transmute(seed)}) }
+        StdRng { rng: SeedableRng::from_seed(unsafe {mem::transmute(seed)}) }
     }
 }
 
@@ -547,7 +547,7 @@ pub fn new() -> IoResult<XorShiftRng> {
                 break;
             }
         }
-        let s: [u32, ..4] = unsafe { cast::transmute(s) };
+        let s: [u32, ..4] = unsafe { mem::transmute(s) };
         Ok(SeedableRng::from_seed(s))
     }
 }
index ed4c7299dffb8d4614666d9b4eccd50339b45450..f41d7a628631cd88b66e4ca10633b2f2a37d02b2 100644 (file)
@@ -61,8 +61,8 @@ mod imp {
     extern crate libc;
 
     use Rng;
-    use std::cast;
     use std::io::{IoResult, IoError};
+    use std::mem;
     use std::os;
     use std::rt::stack;
     use self::libc::{c_ulong, DWORD, BYTE, LPCSTR, BOOL};
@@ -156,12 +156,12 @@ impl Rng for OSRng {
         fn next_u32(&mut self) -> u32 {
             let mut v = [0u8, .. 4];
             self.fill_bytes(v);
-            unsafe { cast::transmute(v) }
+            unsafe { mem::transmute(v) }
         }
         fn next_u64(&mut self) -> u64 {
             let mut v = [0u8, .. 8];
             self.fill_bytes(v);
-            unsafe { cast::transmute(v) }
+            unsafe { mem::transmute(v) }
         }
         fn fill_bytes(&mut self, v: &mut [u8]) {
             let ret = unsafe {
index d098c2cf0c1440547e3e8fc2f4e0dc066ffab12f..184146d9a29c809a443ed893d909d67accdf71be 100644 (file)
@@ -72,14 +72,14 @@ fn fill_bytes(&mut self, v: &mut [u8]) {
 mod test {
     use super::ReaderRng;
     use std::io::MemReader;
-    use std::cast;
+    use std::mem;
     use Rng;
 
     #[test]
     fn test_reader_rng_u64() {
         // transmute from the target to avoid endianness concerns.
         let v = box [1u64, 2u64, 3u64];
-        let bytes: ~[u8] = unsafe {cast::transmute(v)};
+        let bytes: ~[u8] = unsafe {mem::transmute(v)};
         let mut rng = ReaderRng::new(MemReader::new(bytes.move_iter().collect()));
 
         assert_eq!(rng.next_u64(), 1);
@@ -90,7 +90,7 @@ fn test_reader_rng_u64() {
     fn test_reader_rng_u32() {
         // transmute from the target to avoid endianness concerns.
         let v = box [1u32, 2u32, 3u32];
-        let bytes: ~[u8] = unsafe {cast::transmute(v)};
+        let bytes: ~[u8] = unsafe {mem::transmute(v)};
         let mut rng = ReaderRng::new(MemReader::new(bytes.move_iter().collect()));
 
         assert_eq!(rng.next_u32(), 1);
index 7ecea29db2ead761e7bf836eae1542daec53a2e7..a0b38700ecf0a0825758496e7d84bc8d187fcdf6 100644 (file)
 use metadata::filesearch;
 use lib::llvm::{ArchiveRef, llvm};
 
-use std::cast;
-use std::io;
-use std::io::{fs, TempDir};
 use libc;
-use std::os;
 use std::io::process::{ProcessConfig, Process, ProcessOutput};
-use std::str;
+use std::io::{fs, TempDir};
+use std::io;
+use std::mem;
+use std::os;
 use std::raw;
+use std::str;
 use syntax::abi;
 
 pub static METADATA_FILENAME: &'static str = "rust.metadata.bin";
@@ -230,7 +230,7 @@ pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
             if ptr.is_null() {
                 None
             } else {
-                Some(cast::transmute(raw::Slice {
+                Some(mem::transmute(raw::Slice {
                     data: ptr,
                     len: size as uint,
                 }))
index 26f5ead37bec83713fbf4d6c9f51f454c7187bae..518dc4b05ca20b27a43002725a1648c4da7096f7 100644 (file)
@@ -10,7 +10,7 @@
 
 #![allow(non_camel_case_types)]
 
-use std::cast;
+use std::mem;
 use syntax::crateid::CrateId;
 use back::svh::Svh;
 
@@ -147,7 +147,7 @@ impl astencode_tag {
     pub fn from_uint(value : uint) -> Option<astencode_tag> {
         let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;
         if !is_a_tag { None } else {
-            Some(unsafe { cast::transmute(value) })
+            Some(unsafe { mem::transmute(value) })
         }
     }
 }
index 5faae72791d7e784bd20c5027d90839d5258b987..70f740f7557e12235535bd4aa00c1c692718d3d3 100644 (file)
@@ -27,7 +27,7 @@
 use util::nodemap::{NodeMap, NodeSet};
 
 use serialize::Encodable;
-use std::cast;
+use std::mem;
 use std::cell::RefCell;
 use std::hash;
 use std::hash::Hash;
@@ -1247,7 +1247,7 @@ fn my_visit_item(i: &Item,
                  index: &mut Vec<entry<i64>>) {
     let mut ebml_w = unsafe { ebml_w.unsafe_clone() };
     // See above
-    let ecx: &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
+    let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) };
     ecx.tcx.map.with_path(i.id, |path| {
         encode_info_for_item(ecx, &mut ebml_w, i, index, path, i.vis);
     });
@@ -1258,7 +1258,7 @@ fn my_visit_foreign_item(ni: &ForeignItem,
                          ecx_ptr:*int,
                          index: &mut Vec<entry<i64>>) {
     // See above
-    let ecx: &EncodeContext = unsafe { cast::transmute(ecx_ptr) };
+    let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) };
     debug!("writing foreign item {}::{}",
             ecx.tcx.map.path_to_str(ni.id),
             token::get_ident(ni.ident));
@@ -1320,7 +1320,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
                         Public);
 
     // See comment in `encode_side_tables_for_ii` in astencode
-    let ecx_ptr: *int = unsafe { cast::transmute(ecx) };
+    let ecx_ptr: *int = unsafe { mem::transmute(ecx) };
     visit::walk_crate(&mut EncodeVisitor {
         index: &mut index,
         ecx_ptr: ecx_ptr,
index ebe3ce69dabe96ac1711969afa0066cc1fcc8d9f..c872df3deade9ba819f2e93169f5200579a11bfb 100644 (file)
@@ -25,9 +25,9 @@
 use util::fs;
 
 use std::c_str::ToCStr;
-use std::cast;
 use std::cmp;
 use std::io;
+use std::mem;
 use std::ptr;
 use std::slice;
 use std::str;
@@ -469,7 +469,7 @@ fn new(ar: ArchiveRO) -> Option<ArchiveMetadata> {
             // Hence, we're guaranteed that the buffer will never be used after
             // this object is dead, so this is a safe operation to transmute and
             // store the data as a static buffer.
-            unsafe { cast::transmute(data) }
+            unsafe { mem::transmute(data) }
         };
         Some(ArchiveMetadata {
             archive: ar,
@@ -532,7 +532,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
                 let cbuf = llvm::LLVMGetSectionContents(si.llsi);
                 let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
                 let mut found = Err(format!("metadata not found: '{}'", filename.display()));
-                let cvbuf: *u8 = cast::transmute(cbuf);
+                let cvbuf: *u8 = mem::transmute(cbuf);
                 let vlen = encoder::metadata_encoding_version.len();
                 debug!("checking {} bytes of metadata-version stamp",
                        vlen);
index 523e0042cce50b58e0ac9b402c61cd22b9176df1..ae1a12901049d2bc9fb06db7e17fa86e1113b15c 100644 (file)
@@ -34,9 +34,9 @@
 use syntax;
 
 use libc;
-use std::cast;
 use std::io::Seek;
 use std::io::MemWriter;
+use std::mem;
 use std::rc::Rc;
 use std::strbuf::StrBuf;
 
@@ -913,7 +913,7 @@ fn visit_id(&self, id: ast::NodeId) {
         };
         // See above
         let ecx: &e::EncodeContext = unsafe {
-            cast::transmute(self.ecx_ptr)
+            mem::transmute(self.ecx_ptr)
         };
         encode_side_tables_for_id(ecx, &mut new_ebml_w, id)
     }
@@ -932,7 +932,7 @@ fn encode_side_tables_for_ii(ecx: &e::EncodeContext,
     // tied to the CrateContext that lives throughout this entire section.
     ast_util::visit_ids_for_inlined_item(ii, &SideTableEncodingIdVisitor {
         ecx_ptr: unsafe {
-            cast::transmute(ecx)
+            mem::transmute(ecx)
         },
         new_ebml_w: &mut new_ebml_w,
     });
index 518dcff42bfea75b584c56b52549c5739276d5b9..0ca1a07e1a370c9ab9e848e6e49a9932afd39c6a 100644 (file)
 use middle::ty;
 use util::nodemap::NodeMap;
 
-use std::cast::transmute;
+use std::mem::transmute;
 use std::fmt;
 use std::io;
 use std::rc::Rc;
index e49e9539980f48ddb80e62ff7ca04c50ed6d1e96..a0744037dc0081650abd545b2a1cbee3fabbad0d 100644 (file)
@@ -19,7 +19,7 @@
 use syntax::abi::{X86, X86_64, Arm, Mips};
 
 use std::c_str::ToCStr;
-use std::cast;
+use std::mem;
 
 use libc::{c_uint};
 
@@ -140,19 +140,19 @@ pub fn float_from_ty(ccx: &CrateContext, t: ast::FloatTy) -> Type {
     }
 
     pub fn func(args: &[Type], ret: &Type) -> Type {
-        let vec : &[TypeRef] = unsafe { cast::transmute(args) };
+        let vec : &[TypeRef] = unsafe { mem::transmute(args) };
         ty!(llvm::LLVMFunctionType(ret.to_ref(), vec.as_ptr(),
                                    args.len() as c_uint, False))
     }
 
     pub fn variadic_func(args: &[Type], ret: &Type) -> Type {
-        let vec : &[TypeRef] = unsafe { cast::transmute(args) };
+        let vec : &[TypeRef] = unsafe { mem::transmute(args) };
         ty!(llvm::LLVMFunctionType(ret.to_ref(), vec.as_ptr(),
                                    args.len() as c_uint, True))
     }
 
     pub fn struct_(ccx: &CrateContext, els: &[Type], packed: bool) -> Type {
-        let els : &[TypeRef] = unsafe { cast::transmute(els) };
+        let els : &[TypeRef] = unsafe { mem::transmute(els) };
         ty!(llvm::LLVMStructTypeInContext(ccx.llcx, els.as_ptr(),
                                           els.len() as c_uint,
                                           packed as Bool))
@@ -245,7 +245,7 @@ pub fn kind(&self) -> TypeKind {
 
     pub fn set_struct_body(&mut self, els: &[Type], packed: bool) {
         unsafe {
-            let vec : &[TypeRef] = cast::transmute(els);
+            let vec : &[TypeRef] = mem::transmute(els);
             llvm::LLVMStructSetBody(self.to_ref(), vec.as_ptr(),
                                     els.len() as c_uint, packed as Bool)
         }
@@ -281,7 +281,7 @@ pub fn field_types(&self) -> Vec<Type> {
             }
             let mut elts = Vec::from_elem(n_elts, 0 as TypeRef);
             llvm::LLVMGetStructElementTypes(self.to_ref(), elts.get_mut(0));
-            cast::transmute(elts)
+            mem::transmute(elts)
         }
     }
 
@@ -294,7 +294,7 @@ pub fn func_params(&self) -> Vec<Type> {
             let n_args = llvm::LLVMCountParamTypes(self.to_ref()) as uint;
             let args = Vec::from_elem(n_args, 0 as TypeRef);
             llvm::LLVMGetParamTypes(self.to_ref(), args.as_ptr());
-            cast::transmute(args)
+            mem::transmute(args)
         }
     }
 
index e61961f999c8e241d9620c9af3adae34ff5d0a3a..f37a4ab0aaa4aafb2da24cd9dceb0048ba8d8885 100644 (file)
 use util::common::{indenter};
 use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet, FnvHashMap};
 
-use std::cast;
 use std::cell::{Cell, RefCell};
 use std::cmp;
 use std::fmt::Show;
 use std::fmt;
 use std::hash::{Hash, sip};
 use std::iter::AdditiveIterator;
+use std::mem;
 use std::ops;
 use std::rc::Rc;
 use collections::{HashMap, HashSet};
@@ -394,7 +394,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 pub fn get(t: t) -> t_box {
     unsafe {
-        let t2: t_box = cast::transmute(t);
+        let t2: t_box = mem::transmute(t);
         t2
     }
 }
@@ -854,7 +854,7 @@ fn to_uint(&self) -> uint {
         *self as uint
     }
     fn from_uint(v: uint) -> BuiltinBound {
-        unsafe { cast::transmute(v) }
+        unsafe { mem::transmute(v) }
     }
 }
 
@@ -1158,7 +1158,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
     let key = intern_key { sty: &st };
 
     match cx.interner.borrow().find(&key) {
-        Some(t) => unsafe { return cast::transmute(&t.sty); },
+        Some(t) => unsafe { return mem::transmute(&t.sty); },
         _ => ()
     }
 
@@ -1259,14 +1259,14 @@ fn sflags(substs: &substs) -> uint {
     cx.next_id.set(cx.next_id.get() + 1);
 
     unsafe {
-        cast::transmute::<*sty, t>(sty_ptr)
+        mem::transmute::<*sty, t>(sty_ptr)
     }
 }
 
 #[inline]
 pub fn mk_prim_t(primitive: &'static t_box_) -> t {
     unsafe {
-        cast::transmute::<&'static t_box_, t>(primitive)
+        mem::transmute::<&'static t_box_, t>(primitive)
     }
 }
 
index 433073b43c44a2e681fe77a02f24e308704c07df..81ddc9d32eb2c6b7543412704e6a58f24b7fbf91 100644 (file)
@@ -14,7 +14,7 @@
 /// It is assumed that all invocations of this struct happen on the same thread
 /// (the uv event loop).
 
-use std::cast;
+use std::mem;
 use std::rt::local::Local;
 use std::rt::task::{BlockedTask, Task};
 use std::sync::arc::UnsafeArc;
@@ -110,7 +110,7 @@ fn drop(&mut self) {
         // on the same I/O event loop, so this unsafety should be ok.
         assert!(self.missile.is_some());
         let inner: &mut Inner = unsafe {
-            cast::transmute(self.access.inner.get())
+            mem::transmute(self.access.inner.get())
         };
 
         match inner.queue.shift() {
index 4766630b0f421ecd05024a2377a398fa786c9c6a..1e18f2ea9ec2540153d67f55db017b750a844738 100644 (file)
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 use ai = std::io::net::addrinfo;
-use std::cast;
-use libc;
 use libc::c_int;
+use libc;
+use std::mem;
 use std::ptr::null;
 use std::rt::task::BlockedTask;
 
@@ -140,7 +140,7 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<ai::Info> {
 
         let mut addrs = Vec::new();
         loop {
-            let rustaddr = net::sockaddr_to_addr(cast::transmute((*addr).ai_addr),
+            let rustaddr = net::sockaddr_to_addr(mem::transmute((*addr).ai_addr),
                                                  (*addr).ai_addrlen as uint);
 
             let mut flags = 0;
index 155dee3cfa82c5b1a2bb683ac1b70f308811ce14..7a16baaa9f2a6bfc8e3713183d6495802e683f47 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
+use std::mem;
 use std::rt::rtio::{Callback, RemoteCallback};
 use std::unstable::sync::Exclusive;
 
@@ -39,7 +39,7 @@ pub fn new(loop_: &mut Loop, cb: Box<Callback:Send>) -> AsyncWatcher {
         let flag = Exclusive::new(false);
         let payload = box Payload { callback: cb, exit_flag: flag.clone() };
         unsafe {
-            let payload: *u8 = cast::transmute(payload);
+            let payload: *u8 = mem::transmute(payload);
             uvll::set_data_for_uv_handle(handle, payload);
         }
         return AsyncWatcher { handle: handle, exit_flag: flag, };
@@ -55,7 +55,7 @@ unsafe fn from_uv_handle<'a>(_: &'a *uvll::uv_async_t) -> &'a mut AsyncWatcher {
 
 extern fn async_cb(handle: *uvll::uv_async_t) {
     let payload: &mut Payload = unsafe {
-        cast::transmute(uvll::get_data_for_uv_handle(handle))
+        mem::transmute(uvll::get_data_for_uv_handle(handle))
     };
 
     // The synchronization logic here is subtle. To review,
@@ -94,7 +94,7 @@ unsafe fn from_uv_handle<'a>(_: &'a *uvll::uv_async_t) -> &'a mut AsyncWatcher {
 extern fn close_cb(handle: *uvll::uv_handle_t) {
     // drop the payload
     let _payload: Box<Payload> = unsafe {
-        cast::transmute(uvll::get_data_for_uv_handle(handle))
+        mem::transmute(uvll::get_data_for_uv_handle(handle))
     };
     // and then free the handle
     unsafe { uvll::free_handle(handle) }
index 0e69db1f1f308a161ca776635a58b8897c116a73..cd56e76aff667d1d224e16742d3e4f7693c60367 100644 (file)
@@ -8,16 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::c_str::CString;
-use std::c_str;
-use std::cast::transmute;
-use std::cast;
 use libc::{c_int, c_char, c_void, ssize_t};
 use libc;
-use std::rt::task::BlockedTask;
+use std::c_str::CString;
+use std::c_str;
 use std::io::{FileStat, IoError};
 use std::io;
+use std::mem;
 use std::rt::rtio;
+use std::rt::task::BlockedTask;
 
 use homing::{HomingIO, HomeHandle};
 use super::{Loop, UvError, uv_error_to_io_error, wait_until_woken_after, wakeup};
@@ -341,7 +340,7 @@ fn execute(f: |*uvll::uv_fs_t, uvll::uv_fs_cb| -> c_int)
 
     extern fn fs_cb(req: *uvll::uv_fs_t) {
         let slot: &mut Option<BlockedTask> = unsafe {
-            cast::transmute(uvll::get_data_for_req(req))
+            mem::transmute(uvll::get_data_for_req(req))
         };
         wakeup(slot);
     }
@@ -448,7 +447,7 @@ fn tell(&self) -> Result<u64, IoError> {
         use libc::SEEK_CUR;
         // this is temporary
         // FIXME #13933: Remove/justify all `&T` to `&mut T` transmutes
-        let self_ = unsafe { cast::transmute::<&_, &mut FileWatcher>(self) };
+        let self_ = unsafe { mem::transmute::<&_, &mut FileWatcher>(self) };
         self_.seek_common(0, SEEK_CUR)
     }
     fn fsync(&mut self) -> Result<(), IoError> {
index 50825bab493b3b70dce96fc2cb85aaf330a3a847..b9025397b8d22ea54c2bbea6264c48b1be16217f 100644 (file)
@@ -33,7 +33,7 @@
 
 #![allow(dead_code)]
 
-use std::cast;
+use std::mem;
 use std::rt::local::Local;
 use std::rt::rtio::LocalIo;
 use std::rt::task::{Task, BlockedTask};
@@ -77,7 +77,7 @@ pub fn local_id() -> uint {
     };
     let io = io.get();
     unsafe {
-        let (_vtable, ptr): (uint, uint) = cast::transmute(io);
+        let (_vtable, ptr): (uint, uint) = mem::transmute(io);
         return ptr;
     }
 }
index ba72e5db2731977256c634aefe024a0fded1031b..f5cde39bc8343405cde618df3f69e4a8824fbe0b 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
 use libc::c_void;
+use std::mem;
 
 use uvll;
 use super::{Loop, UvHandle};
@@ -41,7 +41,7 @@ pub fn onetime(loop_: &mut Loop, f: proc()) {
         let handle = UvHandle::alloc(None::<IdleWatcher>, uvll::UV_IDLE);
         unsafe {
             assert_eq!(uvll::uv_idle_init(loop_.handle, handle), 0);
-            let data: *c_void = cast::transmute(box f);
+            let data: *c_void = mem::transmute(box f);
             uvll::set_data_for_uv_handle(handle, data);
             assert_eq!(uvll::uv_idle_start(handle, onetime_cb), 0)
         }
@@ -49,7 +49,7 @@ pub fn onetime(loop_: &mut Loop, f: proc()) {
         extern fn onetime_cb(handle: *uvll::uv_idle_t) {
             unsafe {
                 let data = uvll::get_data_for_uv_handle(handle);
-                let f: Box<proc()> = cast::transmute(data);
+                let f: Box<proc()> = mem::transmute(data);
                 (*f)();
                 assert_eq!(uvll::uv_idle_stop(handle), 0);
                 uvll::uv_close(handle, close_cb);
@@ -95,7 +95,7 @@ fn drop(&mut self) {
 
 #[cfg(test)]
 mod test {
-    use std::cast;
+    use std::mem;
     use std::cell::RefCell;
     use std::rc::Rc;
     use std::rt::rtio::{Callback, PausableIdleCallback};
@@ -130,7 +130,7 @@ fn mk(v: uint) -> (Box<IdleWatcher>, Chan) {
         let rc = Rc::new(RefCell::new((None, 0)));
         let cb = box MyCallback(rc.clone(), v);
         let cb = cb as Box<Callback:>;
-        let cb = unsafe { cast::transmute(cb) };
+        let cb = unsafe { mem::transmute(cb) };
         (IdleWatcher::new(&mut local_loop().loop_, cb), rc)
     }
 
index 968029a6edc8cebbe765e866044d5bcb9b0463bd..6568254237620052c2d3add23fa0431aedbac44d 100644 (file)
 extern crate libc;
 
 use libc::{c_int, c_void};
-use std::cast;
 use std::fmt;
 use std::io::IoError;
 use std::io;
+use std::mem;
 use std::ptr::null;
 use std::ptr;
 use std::rt::local::Local;
@@ -147,12 +147,12 @@ fn alloc(_: Option<Self>, ty: uvll::uv_handle_type) -> *T {
     }
 
     unsafe fn from_uv_handle<'a>(h: &'a *T) -> &'a mut Self {
-        cast::transmute(uvll::get_data_for_uv_handle(*h))
+        mem::transmute(uvll::get_data_for_uv_handle(*h))
     }
 
     fn install(~self) -> Box<Self> {
         unsafe {
-            let myptr = cast::transmute::<&Box<Self>, &*u8>(&self);
+            let myptr = mem::transmute::<&Box<Self>, &*u8>(&self);
             uvll::set_data_for_uv_handle(self.uv_handle(), *myptr);
         }
         self
@@ -188,7 +188,7 @@ fn close(&mut self) {
                 let data = uvll::get_data_for_uv_handle(handle);
                 uvll::free_handle(handle);
                 if data == ptr::null() { return }
-                let slot: &mut Option<BlockedTask> = cast::transmute(data);
+                let slot: &mut Option<BlockedTask> = mem::transmute(data);
                 wakeup(slot);
             }
         }
@@ -284,7 +284,7 @@ pub fn set_data<T>(&self, t: *T) {
     pub unsafe fn get_data<T>(&self) -> &'static mut T {
         let data = uvll::get_data_for_req(self.handle);
         assert!(data != null());
-        cast::transmute(data)
+        mem::transmute(data)
     }
 
     // This function should be used when the request handle has been given to an
@@ -459,11 +459,11 @@ pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
 #[cfg(test)]
 fn local_loop() -> &'static mut uvio::UvIoFactory {
     unsafe {
-        cast::transmute({
+        mem::transmute({
             let mut task = Local::borrow(None::<Task>);
             let mut io = task.local_io().unwrap();
             let (_vtable, uvio): (uint, &'static mut uvio::UvIoFactory) =
-                cast::transmute(io.get());
+                mem::transmute(io.get());
             uvio
         })
     }
@@ -471,7 +471,7 @@ fn local_loop() -> &'static mut uvio::UvIoFactory {
 
 #[cfg(test)]
 mod test {
-    use std::cast::transmute;
+    use std::mem::transmute;
     use std::unstable::run_in_bare_thread;
 
     use super::{slice_to_uv_buf, Loop};
index 999da1cfda718f7fa3a1c456a30f6797e6a12db2..798c9ac3cab169140936377eac56d78b037bed01 100644 (file)
@@ -10,7 +10,6 @@
 
 use libc::{size_t, ssize_t, c_int, c_void, c_uint};
 use libc;
-use std::cast;
 use std::io;
 use std::io::IoError;
 use std::io::net::ip;
@@ -42,7 +41,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
         libc::AF_INET => {
             assert!(len as uint >= mem::size_of::<libc::sockaddr_in>());
             let storage: &libc::sockaddr_in = unsafe {
-                cast::transmute(storage)
+                mem::transmute(storage)
             };
             let addr = storage.sin_addr.s_addr as u32;
             let a = (addr >>  0) as u8;
@@ -57,7 +56,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
         libc::AF_INET6 => {
             assert!(len as uint >= mem::size_of::<libc::sockaddr_in6>());
             let storage: &libc::sockaddr_in6 = unsafe {
-                cast::transmute(storage)
+                mem::transmute(storage)
             };
             let a = ntohs(storage.sin6_addr.s6_addr[0]);
             let b = ntohs(storage.sin6_addr.s6_addr[1]);
@@ -84,7 +83,7 @@ fn addr_to_sockaddr(addr: ip::SocketAddr) -> (libc::sockaddr_storage, uint) {
         let len = match addr.ip {
             ip::Ipv4Addr(a, b, c, d) => {
                 let storage: &mut libc::sockaddr_in =
-                    cast::transmute(&mut storage);
+                    mem::transmute(&mut storage);
                 (*storage).sin_family = libc::AF_INET as libc::sa_family_t;
                 (*storage).sin_port = htons(addr.port);
                 (*storage).sin_addr = libc::in_addr {
@@ -97,7 +96,7 @@ fn addr_to_sockaddr(addr: ip::SocketAddr) -> (libc::sockaddr_storage, uint) {
             }
             ip::Ipv6Addr(a, b, c, d, e, f, g, h) => {
                 let storage: &mut libc::sockaddr_in6 =
-                    cast::transmute(&mut storage);
+                    mem::transmute(&mut storage);
                 storage.sin6_family = libc::AF_INET6 as libc::sa_family_t;
                 storage.sin6_port = htons(addr.port);
                 storage.sin6_addr = libc::in6_addr {
@@ -316,7 +315,7 @@ fn set_read_timeout(&mut self, ms: Option<u64>) {
                                      &self.stream as *_ as uint);
 
         fn cancel_read(stream: uint) -> Option<BlockedTask> {
-            let stream: &mut StreamWatcher = unsafe { cast::transmute(stream) };
+            let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
             stream.cancel_read(uvll::ECANCELED as ssize_t)
         }
     }
@@ -328,7 +327,7 @@ fn set_write_timeout(&mut self, ms: Option<u64>) {
                                       &self.stream as *_ as uint);
 
         fn cancel_write(stream: uint) -> Option<BlockedTask> {
-            let stream: &mut StreamWatcher = unsafe { cast::transmute(stream) };
+            let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
             stream.cancel_write()
         }
     }
@@ -602,7 +601,7 @@ fn recvfrom(&mut self, buf: &mut [u8])
                 None
             } else {
                 let len = mem::size_of::<libc::sockaddr_storage>();
-                Some(sockaddr_to_addr(unsafe { cast::transmute(addr) }, len))
+                Some(sockaddr_to_addr(unsafe { mem::transmute(addr) }, len))
             };
             cx.result = Some((nread, addr));
             wakeup(&mut cx.task);
@@ -652,7 +651,7 @@ fn sendto(&mut self, buf: &[u8], dst: ip::SocketAddr) -> Result<(), IoError> {
                 };
                 unsafe {
                     req.set_data(&*new_cx);
-                    cast::forget(new_cx);
+                    mem::forget(new_cx);
                 }
                 Err(uv_error_to_io_error(UvError(cx.result)))
             }
@@ -670,7 +669,7 @@ fn sendto(&mut self, buf: &[u8], dst: ip::SocketAddr) -> Result<(), IoError> {
                 let udp: &mut UdpWatcher = unsafe { &mut *cx.udp };
                 wakeup(&mut udp.blocked_sender);
             } else {
-                let _cx: Box<UdpSendCtx> = unsafe { cast::transmute(cx) };
+                let _cx: Box<UdpSendCtx> = unsafe { mem::transmute(cx) };
             }
         }
     }
@@ -789,7 +788,7 @@ fn set_write_timeout(&mut self, ms: Option<u64>) {
                                       self as *mut _ as uint);
 
         fn cancel_write(stream: uint) -> Option<BlockedTask> {
-            let stream: &mut UdpWatcher = unsafe { cast::transmute(stream) };
+            let stream: &mut UdpWatcher = unsafe { mem::transmute(stream) };
             stream.blocked_sender.take()
         }
     }
index 76bf92bd5557ca8e08788bac0621161f98917457..ba39f8a7f5f32fbbf5d4f10b7832169e05024631 100644 (file)
@@ -10,9 +10,9 @@
 
 use libc;
 use std::c_str::CString;
-use std::cast;
 use std::io::IoError;
 use std::io;
+use std::mem;
 use std::rt::rtio::{RtioPipe, RtioUnixListener, RtioUnixAcceptor};
 use std::rt::task::BlockedTask;
 
@@ -185,7 +185,7 @@ fn set_read_timeout(&mut self, ms: Option<u64>) {
                                      &self.stream as *_ as uint);
 
         fn cancel_read(stream: uint) -> Option<BlockedTask> {
-            let stream: &mut StreamWatcher = unsafe { cast::transmute(stream) };
+            let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
             stream.cancel_read(uvll::ECANCELED as libc::ssize_t)
         }
     }
@@ -197,7 +197,7 @@ fn set_write_timeout(&mut self, ms: Option<u64>) {
                                       &self.stream as *_ as uint);
 
         fn cancel_write(stream: uint) -> Option<BlockedTask> {
-            let stream: &mut StreamWatcher = unsafe { cast::transmute(stream) };
+            let stream: &mut StreamWatcher = unsafe { mem::transmute(stream) };
             stream.cancel_write()
         }
     }
index 561c1f6f95f5c40f22d5ce9ec23072af2fe7e8be..57b5e7105b20e3afff5acd0f00ef6736e5b1f8dd 100644 (file)
 #![allow(dead_code)]
 
 use libc::c_void;
-use std::cast;
+use std::mem;
 use std::rt::task::BlockedTask;
-use std::unstable::mutex::NativeMutex;
 use std::sync::arc::UnsafeArc;
+use std::unstable::mutex::NativeMutex;
 use mpsc = std::sync::mpsc_queue;
 
 use async::AsyncWatcher;
@@ -57,9 +57,9 @@ pub struct Queue {
 
 extern fn async_cb(handle: *uvll::uv_async_t) {
     let pool: &mut QueuePool = unsafe {
-        cast::transmute(uvll::get_data_for_uv_handle(handle))
+        mem::transmute(uvll::get_data_for_uv_handle(handle))
     };
-    let state: &mut State = unsafe { cast::transmute(pool.queue.get()) };
+    let state: &mut State = unsafe { mem::transmute(pool.queue.get()) };
 
     // Remember that there is no guarantee about how many times an async
     // callback is called with relation to the number of sends, so process the
@@ -183,7 +183,7 @@ fn drop(&mut self) {
 impl Drop for State {
     fn drop(&mut self) {
         unsafe {
-            uvll::uv_close(self.handle, cast::transmute(0));
+            uvll::uv_close(self.handle, mem::transmute(0));
             // Note that this does *not* free the handle, that is the
             // responsibility of the caller because the uv loop must be closed
             // before we deallocate this uv handle.
index 36b6ed09ca5668033c1e9bdf35adc48b3ea4fea1..8ce985eb76d658e778a19f90e33ff40d67cd1166 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
 use libc::{c_int, size_t, ssize_t};
+use std::mem;
 use std::ptr;
 use std::rt::task::BlockedTask;
 
@@ -212,7 +212,7 @@ pub fn write(&mut self, buf: &[u8], may_timeout: bool) -> Result<(), UvError> {
                 };
                 unsafe {
                     req.set_data(&*new_wcx);
-                    cast::forget(new_wcx);
+                    mem::forget(new_wcx);
                 }
                 Err(UvError(wcx.result))
             }
@@ -232,7 +232,7 @@ pub fn cancel_write(&mut self) -> Option<BlockedTask> {
     uvdebug!("alloc_cb");
     unsafe {
         let rcx: &mut ReadContext =
-            cast::transmute(uvll::get_data_for_uv_handle(stream));
+            mem::transmute(uvll::get_data_for_uv_handle(stream));
         *buf = rcx.buf.take().expect("stream alloc_cb called more than once");
     }
 }
@@ -243,7 +243,7 @@ pub fn cancel_write(&mut self) -> Option<BlockedTask> {
     uvdebug!("read_cb {}", nread);
     assert!(nread != uvll::ECANCELED as ssize_t);
     let rcx: &mut ReadContext = unsafe {
-        cast::transmute(uvll::get_data_for_uv_handle(handle))
+        mem::transmute(uvll::get_data_for_uv_handle(handle))
     };
     // Stop reading so that no read callbacks are
     // triggered before the user calls `read` again.
@@ -272,6 +272,6 @@ pub fn cancel_write(&mut self) -> Option<BlockedTask> {
         let stream: &mut StreamWatcher = unsafe { &mut *wcx.stream };
         wakeup(&mut stream.blocked_writer);
     } else {
-        let _wcx: Box<WriteContext> = unsafe { cast::transmute(wcx) };
+        let _wcx: Box<WriteContext> = unsafe { mem::transmute(wcx) };
     }
 }
index 3dbb34bb17a871f1290d874f92c7033fca022fcb..99b568b12605c7203057c9a69f9ebb00c29e64f8 100644 (file)
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 use libc::c_int;
-use std::cast;
 use std::io::IoResult;
 use std::mem;
 use std::rt::task::BlockedTask;
@@ -127,7 +126,7 @@ pub fn set_timeout(&mut self, ms: Option<u64>,
             };
             unsafe {
                 timer.set_data(&*cx);
-                cast::forget(cx);
+                mem::forget(cx);
             }
             self.timer = Some(timer);
         }
@@ -199,7 +198,7 @@ fn drop(&mut self) {
         match self.timer {
             Some(ref timer) => unsafe {
                 let data = uvll::get_data_for_uv_handle(timer.handle);
-                let _data: Box<TimerContext> = cast::transmute(data);
+                let _data: Box<TimerContext> = mem::transmute(data);
             },
             None => {}
         }
index 50258c2583c65c33d169e4e31c36e4df8ff62071..c42b17cc3256e92787060891e4a1792f02c51146 100644 (file)
@@ -11,7 +11,6 @@
 //! The implementation of `rtio` for libuv
 
 use std::c_str::CString;
-use std::cast;
 use std::io::IoError;
 use std::io::net::ip::SocketAddr;
 use std::io::process::ProcessConfig;
@@ -19,6 +18,7 @@
 use std::io::{FileMode, FileAccess, Open, Append, Truncate, Read, Write,
               ReadWrite, FileStat};
 use std::io;
+use std::mem;
 use libc::c_int;
 use libc::{O_CREAT, O_APPEND, O_TRUNC, O_RDWR, O_RDONLY, O_WRONLY, S_IRUSR,
                 S_IWUSR};
@@ -140,7 +140,7 @@ pub fn uv_loop<'a>(&mut self) -> *uvll::uv_loop_t { self.loop_.handle }
     pub fn make_handle(&mut self) -> HomeHandle {
         // It's understood by the homing code that the "local id" is just the
         // pointer of the local I/O factory cast to a uint.
-        let id: uint = unsafe { cast::transmute_copy(&self) };
+        let id: uint = unsafe { mem::transmute_copy(&self) };
         HomeHandle::new(id, &mut **self.handle_pool.get_mut_ref())
     }
 }
index 486150f1741f6f9386fc0673f2ff6450c62f906b..ea506931d76eef7350f22cf0f06b8d7ab4c6be08 100644 (file)
@@ -88,7 +88,7 @@ pub enum Error {
 pub mod reader {
     use std::char;
 
-    use std::cast::transmute;
+    use std::mem::transmute;
     use std::int;
     use std::option::{None, Option, Some};
     use std::io::extensions::u64_from_be_bytes;
@@ -617,11 +617,11 @@ fn read_map_elt_val<T>(&mut self, idx: uint, f: |&mut Decoder<'doc>| -> DecodeRe
 }
 
 pub mod writer {
-    use std::cast;
     use std::clone::Clone;
-    use std::io;
-    use std::io::{Writer, Seek};
     use std::io::extensions::u64_to_be_bytes;
+    use std::io::{Writer, Seek};
+    use std::io;
+    use std::mem;
 
     use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
         EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
@@ -679,7 +679,7 @@ impl<'a, W: Writer + Seek> Encoder<'a, W> {
         /// FIXME(pcwalton): Workaround for badness in trans. DO NOT USE ME.
         pub unsafe fn unsafe_clone(&self) -> Encoder<'a, W> {
             Encoder {
-                writer: cast::transmute_copy(&self.writer),
+                writer: mem::transmute_copy(&self.writer),
                 size_positions: self.size_positions.clone(),
             }
         }
@@ -853,11 +853,11 @@ fn emit_bool(&mut self, v: bool) -> EncodeResult {
         }
 
         fn emit_f64(&mut self, v: f64) -> EncodeResult {
-            let bits = unsafe { cast::transmute(v) };
+            let bits = unsafe { mem::transmute(v) };
             self.wr_tagged_u64(EsF64 as uint, bits)
         }
         fn emit_f32(&mut self, v: f32) -> EncodeResult {
-            let bits = unsafe { cast::transmute(v) };
+            let bits = unsafe { mem::transmute(v) };
             self.wr_tagged_u32(EsF32 as uint, bits)
         }
         fn emit_char(&mut self, v: char) -> EncodeResult {
index f45ec8a6742a23585695e0f4c21b4d7fba6b0b63..e087b3d1774995f5486beac433064bf4fcb9231a 100644 (file)
 
 //! 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 @@ fn to_ascii_opt(&self) -> Option<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 @@ fn is_ascii(&self) -> bool {
 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 @@ fn is_ascii(&self) -> bool {
 
     #[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 @@ fn is_ascii(&self) -> bool {
 
     #[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 @@ fn is_ascii(&self) -> bool {
 
     #[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 @@ fn eq_ignore_case(self, other: &[Ascii]) -> bool {
 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) }
     }
 }
 
index b33d211aa192849bf258182bb3bab41239e51bc7..0885a7af00b4d4d2be1be96780e5aed75e979cf1 100644 (file)
@@ -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 @@ pub fn with_ref<T>(&self, f: |*libc::c_char| -> T) -> T {
     /// 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 @@ pub fn owns_buffer(&self) -> bool {
     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 @@ pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
     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() })
         }
     }
 
index 8c2c4fd1f0be7e416f3eba768798574609fd988e..817b54fb692f20b8e5838d53671de59ae7c2b38d 100644 (file)
@@ -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 @@ pub unsafe fn new_with_dtor(base: *mut T, len: uint,
     /// 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 })
         }
     }
 
index cebfeb5399e9d9f503696d4dee3b3bf3b424ea7d..ed884647fb6ffd6112c76e71e2011edb07003605 100644 (file)
 
 #![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 @@ pub fn recv_opt(&mut self) -> Result<T, ()> { self.rx.recv_opt() }
     /// 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 @@ pub unsafe fn add(&mut self) {
     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);
index db3f90cad5a04bd04433d8d2ddcabcd4262e11c6..819e885526cbf5f31852a6a15bec0ac9c470797b 100644 (file)
@@ -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 @@ pub fn send(&self, t: T) -> Result<(), 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(())}
             }
index 7363593bacf07ef66044944f0467d18a96f649c0..b4bb6236f08ab1543180589aed9d551dcbb35c75 100644 (file)
@@ -484,26 +484,26 @@ fn my_fmt_fn(args: &fmt::Arguments) {
 */
 
 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 @@ fn execute(&mut self, method: &rt::Method, arg: Argument) -> Result {
             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 @@ fn execute(&mut self, method: &rt::Method, arg: Argument) -> Result {
             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)
     }
 }
index c8207a4c37ccefe5deb55cfa26340d2a7f538b9d..a510aa90343e5bec8a61409e87d07ad88ada0523 100644 (file)
@@ -307,7 +307,7 @@ fn hash(&self, state: &mut S) {
 
 #[cfg(test)]
 mod tests {
-    use cast;
+    use mem;
     use io::{IoResult, Writer};
     use iter::{Iterator};
     use option::{Some, None};
@@ -367,12 +367,12 @@ fn test_writer_hasher() {
         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);
         }
     }
index c2e8fbeeb784ebceb9d6a2f93ceff3f67a870caf..bb4bd50815a90928679d1bad4634e8aa074d6949 100644 (file)
@@ -77,7 +77,7 @@ fn next(&mut self) -> Option<IoResult<u8>> {
 /// 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);
index 4a53a064610cb0e5b8661a283d39cb2d06fb1823..37edab9991598ab69494efc8eb1fcadc2659b75d 100644 (file)
@@ -217,24 +217,24 @@ fn file_product(p: &Path) -> IoResult<u32> {
 
 #![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 @@ fn read_be_i16(&mut self) -> IoResult<i16> {
     /// `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 @@ fn read_be_f64(&mut self) -> IoResult<f64> {
     /// `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 @@ fn read_le_i16(&mut self) -> IoResult<i16> {
     /// `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 @@ fn read_le_f64(&mut self) -> IoResult<f64> {
     /// `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 @@ fn write_be_i16(&mut self, n: i16) -> IoResult<()> {
     /// 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 @@ fn write_le_i16(&mut self, n: i16) -> IoResult<()> {
     /// (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 @@ fn write_le_f64(&mut self, f: f64) -> IoResult<()> {
     /// (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))
         }
     }
 
index e66b2107bb107ce2d1bd4263cf639008a6bbee47..864a70105412ab30c2e75c6cb531ce751344a06f 100644 (file)
@@ -226,6 +226,7 @@ fn write(&mut self, buf: &[u8]) -> IoResult<()> {
 }
 
 #[cfg(test)]
+#[allow(experimental)]
 mod test {
     use super::*;
     use io::net::ip::{SocketAddr};
index 3f22a76c1f4e78ec9243f372c58099e882eaf568..8f0c1e413097137e6bd891421881d124e21d40d4 100644 (file)
 
 pub use core::any;
 pub use core::bool;
-pub use core::cast;
 pub use core::cell;
 pub use core::char;
 pub use core::clone;
index 5d18ca4141b1fed73faddf93295d63c5e4ef446a..1a971594837df31e91ab622dda3138ec8d00cafa 100644 (file)
 // 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 @@ pub fn replace(&'static self, data: Option<T>) -> Option<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 @@ pub fn replace(&'static self, data: Option<T>) -> Option<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.
index ea248b6d40defeec278c2b1438211bfa4adb3bdc..29c206b32fc36a89617360bfbadda42993166071 100644 (file)
 
 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 @@ fn classify(self) -> FPCategory {
         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 @@ fn frexp(self) -> (f32, int) {
 
     /// 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 {
index 77171a00befef8438038dac1889d8fdf63622999..c18ea5caba6298c3a1ce5fcefbc691262495137d 100644 (file)
 
 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 @@ fn classify(self) -> FPCategory {
         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 @@ fn frexp(self) -> (f64, int) {
 
     /// 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 {
index f21fbe1b6e669d2ad8423e15b3e02bda21040eb1..dfe7241d7af035b9c82f4d7201443a98f376bda4 100644 (file)
 
 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 @@ fn filename_str<'a>(&'a self) -> Option<&'a str> {
     #[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 {
index e0fe75fd907101aa291ca6726c80c739eedec0b9..bc489bc399f848d8070e03b276b3768d9dd5c903 100644 (file)
@@ -23,7 +23,7 @@
 
 */
 
-use cast::transmute;
+use mem::transmute;
 use cell::Cell;
 use clone::Clone;
 use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
index 6e47203b56c0a5e632d4f2bb03109c83a969ff14..6029f504d10b62a5b426e935f628d852f011282f 100644 (file)
@@ -16,7 +16,7 @@
 
 #![allow(missing_doc)]
 
-use cast::transmute;
+use mem::transmute;
 use char;
 use container::Container;
 use io;
@@ -157,7 +157,7 @@ pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool {
                 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);
index df0f1d8d449e44f44919b7351a45b0d366eb3ae6..95d0eabd336d86416c0923091642e6fb175fc6a1 100644 (file)
@@ -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 @@ fn with_lock<T>(f: || -> T) -> T {
     }
 
     fn get_global_ptr() -> *mut Option<Box<Vec<~[u8]>>> {
-        unsafe { cast::transmute(&global_args_ptr) }
+        unsafe { mem::transmute(&global_args_ptr) }
     }
 
     // Copied from `os`.
index 051bc494adc7fbe0b7ec43b803159231e6a04f89..c892a73d9348433101e348968681400ee3b7ae96 100644 (file)
 //!
 //! 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| {
index ee8041f68802ce4db494ecb4b760c1612eb2cda9..f4cb770544c46f96579d804755647d5f4e4d9cee 100644 (file)
@@ -237,9 +237,9 @@ macro_rules! demangle(
 #[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 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
 
         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
index efc8072594bbfcf1d81a6275f0a6c4b412290875..5feec7fd9d2d93641a04fdf081ca21b4a8c9f26a 100644 (file)
 
 //! 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 @@ pub fn alloc(&mut self, drop_glue: fn(*mut u8), size: uint, align: uint) -> *mut
         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 @@ pub fn realloc(&mut self, ptr: *mut Box, size: uint) -> *mut Box {
         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 @@ pub fn realloc(&mut self, ptr: *mut Box, size: uint) -> *mut Box {
     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 @@ fn update_size(&mut self, size: u32) {
     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 @@ fn malloc(&mut self, size: uint) -> *mut Box {
             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 @@ fn realloc(&mut self, alloc: *mut Box, size: uint) -> *mut Box {
             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 @@ fn free(&mut self, alloc: *mut Box) {
         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)
index 39c0d9a54820744abc4c3615f8f2904bb6f653bc..1197a4ccbe670078c3ee1ed2843c53f311bf57de 100644 (file)
@@ -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 @@ fn drop(&mut self) {
             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 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut 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 unsafe fn cleanup() {}
     /// 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 unsafe fn put<T>(sched: Box<T>) {
     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 unsafe fn try_take<T>() -> Option<Box<T>> {
         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 unsafe fn try_take<T>() -> Option<Box<T>> {
     /// 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 unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
 /// 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 unsafe fn cleanup() {
     #[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 unsafe fn take<T>() -> Box<T> {
         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 unsafe fn try_take<T>() -> Option<Box<T>> {
                 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 unsafe fn unsafe_take<T>() -> Box<T> {
         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 fn maybe_tls_key() -> Option<tls::Key> {
     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())
         }
     }
 }
index ccde8d9c96af08cf15bcc141624531a4d5009aab..bc3a483f30d2b5d471d63719b866a673d695f4f7 100644 (file)
 //! 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 @@ pub fn borrow() -> Option<LocalIo> {
         // 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 @@ pub fn get<'a>(&'a mut self) -> &'a mut IoFactory {
         // 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)
         }
     }
 }
index 77bcb7b9904ac8b9e3a78273490d1fd1e391d441..cd0445056b29034fc416ee75a292a63bc10594d3 100644 (file)
@@ -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 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 @@ pub fn run(~self, mut f: ||) -> Box<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 @@ pub fn maybe_take_runtime<T: 'static>(&mut self) -> Option<Box<T>> {
         //      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 @@ pub fn wake(self) -> Option<Box<Task>> {
             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 @@ pub fn block(task: Box<Task>) -> 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 @@ pub fn make_selectable(self, num_handles: uint) -> Take<BlockedTasks> {
     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 @@ pub unsafe fn cast_to_uint(self) -> uint {
     #[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)
         }
     }
index 89d44473a9462c5a6460307289bb1c4ddc60ab56..4f0d7d35ce892f4618821719cce83558fa4c36a1 100644 (file)
@@ -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 @@ pub struct Thread<T> {
     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 @@ pub fn start_stack<T: Send>(stack: uint, main: proc():Send -> T) -> Thread<T> {
         // 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 @@ fn drop(&mut self) {
 
 #[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 @@ pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread {
 
         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 @@ fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES,
 
 #[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 @@ pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread {
             },
         };
 
-        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 @@ fn min_stack_size(attr: *libc::pthread_attr_t) -> libc::size_t {
         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) }
         }
     }
 
index 7706206863617528c9118e82c585d1ab2a2b0a1c..2551c89972e59e0fb21cfcdec8ed24e17c173b51 100644 (file)
@@ -95,7 +95,7 @@ pub unsafe fn destroy(key: Key) {
 
 #[test]
 fn tls_smoke_test() {
-    use cast::transmute;
+    use mem::transmute;
     unsafe {
         let mut key = 0;
         let value = box 20;
index 5f3731eb819d3b68e9848c1b78a4d7f8dcb58cb3..e10e0716f67f2bea6c58168c7289280deb30f9f8 100644 (file)
@@ -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::task::Task;
 use str::Str;
 use task::TaskResult;
-use intrinsics;
 
 use uw = rt::libunwind;
 
@@ -98,7 +97,7 @@ pub fn try(&mut self, f: ||) {
         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 @@ pub fn try(&mut self, f: ||) {
 
         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 @@ fn rust_fail() -> ! {
                     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 @@ extern "C" fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
                 rtdebug!("exception_cleanup()");
                 unsafe {
                     let _: Box<uw::_Unwind_Exception> =
-                        cast::transmute(exception);
+                        mem::transmute(exception);
                 }
             }
         }
index b97c55ad70139a6957bca134bd1dc28318efd457..b0868dd0daf54d1d56b80b59226f1dfe3e54ba65 100644 (file)
@@ -97,8 +97,7 @@
 
 */
 
-use cast::transmute;
-use cast;
+use mem::transmute;
 use clone::Clone;
 use cmp::{TotalOrd, Ordering, Less, Greater};
 use cmp;
@@ -333,7 +332,7 @@ fn to_owned(&self) -> ~[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 @@ fn to_owned(&self) -> ~[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);
             }
         }
     }
index fb3dcc972871d67ac51fb365bd2ad57767e7ea26..24cf9681ca84dfc648e977d7ed3798687c7bcd03 100644 (file)
@@ -74,23 +74,23 @@ fn main() {
 
 */
 
-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 @@ fn from_str(s: &str) -> Option<~str> { Some(s.to_owned()) }
 /// 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 @@ macro_rules! utf8_acc_cont_byte(
 /// ```
 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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 /// 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 unsafe fn from_c_str(buf: *libc::c_char) -> ~str {
     /// 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 unsafe fn from_byte(u: u8) -> ~str { from_utf8_owned(box [u]) }
     /// 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 @@ fn to_owned(&self) -> ~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]
index 8e05b2f527d0830903ad9dead6ec053099906be0..45ab690b0a2be8afa4fbf9ef068e0cffacca3b21 100644 (file)
 //! 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())
         }
     }
 
index 676c836c459d72458a6abd468ea213dda1ad628c..7dcfe62ffb8a673ff603773ca627b290284bdb62 100644 (file)
 //! 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 @@ fn drop(&mut self) {
                 //  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);
             }
         }
     }
index 2fba59c3233e264ba6dff6d1e55166506d09fcb4..6ddae97e901ae1f017ee2773d7654913ea804019 100644 (file)
 #![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 @@ pub fn compare_and_swap(&self, old: *mut T, new: *mut T, order: Ordering) -> *mu
 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 @@ pub fn empty() -> AtomicOption<T> { AtomicOption { p: Unsafe::new(0) } }
     #[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 @@ pub fn swap(&self, val: Box<T>, order: Ordering) -> Option<Box<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 @@ pub fn take(&self, order: Ordering) -> Option<Box<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))
             }
         }
     }
index 8dfd691e6ffdc09f500af0e84d4d8c26a5aad01f..175bb03d2620cc7a16de874624474c4b93e7df38 100644 (file)
@@ -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;
 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 @@ fn new(mut pool: BufferPool<T>) -> 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 @@ unsafe fn pop(&mut self) -> Option<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 @@ unsafe fn steal(&mut self) -> Stolen<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 @@ unsafe fn maybe_shrink(&mut self, b: int, t: int) {
     // 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 @@ unsafe fn swap_buffer(&mut self, b: int, old: *mut Buffer<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 @@ fn drop(&mut self) {
         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 @@ unsafe fn get(&self, i: int) -> 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 @@ fn no_starvation() {
             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() {
index e05959e25918ba7862cb4d5d84902ba251d72b62..4cdcd05e9b450a4d787108f76a587a77d6e6c186 100644 (file)
@@ -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 @@ pub fn pop(&mut self) -> PopResult<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 @@ fn drop(&mut self) {
             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;
             }
         }
index 7854a0e168ebd95e71fb0dd0fb78008992ffc911..ed6d690def06aef480e6cba286bf32049bd4af72 100644 (file)
@@ -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 @@ pub fn pop(&mut self) -> Option<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 @@ fn drop(&mut self) {
             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;
             }
         }
index e2a9f6a5c4821c481ace94816a41577fcdf4c6fa..87d531cc627e093dbc7723749e800086931d2a43 100644 (file)
@@ -17,8 +17,8 @@
 */
 
 use c_str::ToCStr;
-use cast;
 use iter::Iterator;
+use mem;
 use ops::*;
 use option::*;
 use os;
@@ -97,7 +97,7 @@ pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<T, ~str> {
         // 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))
         }
     }
 }
index aa10be1d1be47a26f03894c8c72c89ae5578479d..528ab72762aab904a695541dba25c27fc79e700b 100644 (file)
 
 //! 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 @@ pub fn new() -> 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 @@ pub fn from_fn(length: uint, op: |uint| -> 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 @@ pub fn from_fn(length: uint, op: |uint| -> 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 @@ pub fn from_elem(length: uint, value: 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), 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 @@ fn len(&self) -> uint {
 #[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 @@ pub fn reserve(&mut self, capacity: uint) {
     /// 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 @@ pub fn reserve_exact(&mut self, capacity: uint) {
     /// 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 @@ pub fn shrink_to_fit(&mut self) {
             }
         } 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 @@ pub fn pop(&mut self) -> Option<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 @@ pub fn truncate(&mut self, len: uint) {
     #[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 @@ pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [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 @@ pub fn insert(&mut self, index: uint, element: 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 @@ fn from_vec(mut v: Vec<T>) -> ~[T] {
             // as it still needs to free its own allocation.
             v.set_len(0);
 
-            transmute(ret)
+            mem::transmute(ret)
         }
     }
 }
index 226eb7afb5f801f4d44cd809ff484540e3543db3..4dc965d5d841ca26f7bc70cd7d44a6caf1113a86 100644 (file)
@@ -13,7 +13,7 @@
  * between tasks.
  */
 
-use std::cast;
+use std::mem;
 use std::ptr;
 use std::rt::heap::exchange_free;
 use std::sync::atomics;
@@ -76,7 +76,7 @@ pub fn new(data: T) -> Arc<T> {
             weak: atomics::AtomicUint::new(1),
             data: data,
         };
-        Arc { x: unsafe { cast::transmute(x) } }
+        Arc { x: unsafe { mem::transmute(x) } }
     }
 
     #[inline]
@@ -149,7 +149,7 @@ pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
         // reference count is guaranteed to be 1 at this point, and we required
         // the Arc itself to be `mut`, so we're returning the only possible
         // reference to the inner data.
-        unsafe { cast::transmute::<&_, &mut _>(self.deref()) }
+        unsafe { mem::transmute::<&_, &mut _>(self.deref()) }
     }
 }
 
index 14dfa8417fac9619f8f2bf4cfd1d5793a710279f..acbb2982c90311abe5b0f6fd6c4acf5f623330b7 100644 (file)
@@ -33,7 +33,7 @@
 // http://www.1024cores.net/home/lock-free-algorithms
 //                         /queues/intrusive-mpsc-node-based-queue
 
-use std::cast;
+use std::mem;
 use std::sync::atomics;
 use std::ty::Unsafe;
 
@@ -97,7 +97,7 @@ pub unsafe fn push(&self, node: *mut Node<T>) {
     pub unsafe fn pop(&self) -> Option<*mut Node<T>> {
         let tail = *self.tail.get();
         let mut tail = if !tail.is_null() {tail} else {
-            cast::transmute(&self.stub)
+            mem::transmute(&self.stub)
         };
         let mut next = (*tail).next(atomics::Relaxed);
         if tail as uint == &self.stub as *DummyNode as uint {
@@ -116,7 +116,7 @@ pub unsafe fn pop(&self) -> Option<*mut Node<T>> {
         if tail != head {
             return None;
         }
-        let stub = cast::transmute(&self.stub);
+        let stub = mem::transmute(&self.stub);
         self.push(stub);
         next = (*tail).next(atomics::Relaxed);
         if !next.is_null() {
@@ -135,6 +135,6 @@ pub fn new(t: T) -> Node<T> {
         }
     }
     pub unsafe fn next(&self, ord: atomics::Ordering) -> *mut Node<T> {
-        cast::transmute::<uint, *mut Node<T>>(self.next.load(ord))
+        mem::transmute::<uint, *mut Node<T>>(self.next.load(ord))
     }
 }
index 313720fa932dce5a35fcd361fe375dfd174ea74d..990aba3ebff611605ff9a2983be3faaa58de8735 100644 (file)
@@ -15,9 +15,8 @@
 //! `sync` crate which wrap values directly and provide safer abstractions for
 //! containing data.
 
-use std::cast;
 use std::kinds::marker;
-use std::mem::replace;
+use std::mem;
 use std::sync::atomics;
 use std::unstable::finally::Finally;
 
@@ -109,7 +108,7 @@ struct SemGuard<'a, Q> {
 impl<Q: Send> Sem<Q> {
     fn new(count: int, q: Q) -> Sem<Q> {
         let inner = unsafe {
-            cast::transmute(box SemInner {
+            mem::transmute(box SemInner {
                 waiters: WaitQueue::new(),
                 count: count,
                 blocked: q,
@@ -168,7 +167,7 @@ pub fn access<'a>(&'a self) -> SemGuard<'a, Q> {
 impl<Q: Send> Drop for Sem<Q> {
     fn drop(&mut self) {
         let _waiters: Box<SemInner<Q>> = unsafe {
-            cast::transmute(self.inner)
+            mem::transmute(self.inner)
         };
         self.inner = 0 as *();
     }
@@ -317,8 +316,8 @@ pub fn broadcast_on(&self, condvar_id: uint) -> uint {
                     // To avoid :broadcast_heavy, we make a new waitqueue,
                     // swap it out with the old one, and broadcast on the
                     // old one outside of the little-lock.
-                    queue = Some(replace(state.blocked.get_mut(condvar_id),
-                                               WaitQueue::new()));
+                    queue = Some(mem::replace(state.blocked.get_mut(condvar_id),
+                                              WaitQueue::new()));
                 } else {
                     out_of_bounds = Some(state.blocked.len());
                 }
@@ -578,7 +577,7 @@ pub fn downgrade(self) -> RWLockReadGuard<'a> {
         let lock = self.lock;
         // Don't run the destructor of the write guard, we're in charge of
         // things from now on
-        unsafe { cast::forget(self) }
+        unsafe { mem::forget(self) }
 
         let old_count = lock.read_count.fetch_add(1, atomics::Release);
         // If another reader was already blocking, we need to hand-off
@@ -626,7 +625,7 @@ mod tests {
     use arc::Arc;
     use super::{Semaphore, Mutex, RWLock, Condvar};
 
-    use std::cast;
+    use std::mem;
     use std::result;
     use std::task;
 
@@ -902,7 +901,7 @@ fn test_rwlock_exclusion(x: Arc<RWLock>,
             let ptr: *int = &*sharedstate;
             task::spawn(proc() {
                 let sharedstate: &mut int =
-                    unsafe { cast::transmute(ptr) };
+                    unsafe { mem::transmute(ptr) };
                 access_shared(sharedstate, &x2, mode1, 10);
                 tx.send(());
             });
index 0f3b96c2132b6ce65b85081f119d4d435ede885f..84525718bd95b08b0e34affa7a875c8ecee97b83 100644 (file)
@@ -29,9 +29,9 @@
 use visit::Visitor;
 use util::small_vector::SmallVector;
 
-use std::cast;
-use std::unstable::dynamic_lib::DynamicLibrary;
+use std::mem;
 use std::os;
+use std::unstable::dynamic_lib::DynamicLibrary;
 
 pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
     match e.node {
@@ -544,7 +544,7 @@ fn load_extern_macros(krate: &ast::ViewItem, fld: &mut MacroExpander) {
         // Intentionally leak the dynamic library. We can't ever unload it
         // since the library can do things that will outlive the expansion
         // phase (e.g. make an @-box cycle or launch a task).
-        cast::forget(lib);
+        mem::forget(lib);
     }
 }
 
index 57529228b51f9d1d82a63b325618a2bc1fbb5af2..f93c3576943ef8252203e1a2834fd7917bdddb4e 100644 (file)
@@ -10,7 +10,7 @@
 
 use std::default::Default;
 use std::hash::Hash;
-use std::{cast, mem, raw, ptr, slice};
+use std::{mem, raw, ptr, slice};
 use serialize::{Encodable, Decodable, Encoder, Decoder};
 
 /// A non-growable owned slice. This would preferably become `~[T]`
@@ -48,7 +48,7 @@ pub fn from_vec(mut v: Vec<T>) -> OwnedSlice<T> {
         } else {
             let p = v.as_mut_ptr();
             // we own the allocation now
-            unsafe {cast::forget(v)}
+            unsafe {mem::forget(v)}
 
             OwnedSlice { data: p, len: len }
         }
@@ -60,7 +60,7 @@ pub fn into_vec(self) -> Vec<T> {
         unsafe {
             let ret = Vec::from_raw_parts(self.len, self.len, self.data);
             // the vector owns the allocation now
-            cast::forget(self);
+            mem::forget(self);
             ret
         }
     }
@@ -74,7 +74,7 @@ pub fn as_slice<'a>(&'a self) -> &'a [T] {
             self.data as *T
         };
 
-        let slice: &[T] = unsafe {cast::transmute(raw::Slice {
+        let slice: &[T] = unsafe {mem::transmute(raw::Slice {
             data: ptr,
             len: self.len
         })};
index 8fb2fe61b833d8fb669fcfa1f6429e2d2bb18800..3888ed6b8d1d48528523bb32178b44e7e02e29d0 100644 (file)
@@ -17,9 +17,9 @@
 use util::interner;
 
 use serialize::{Decodable, Decoder, Encodable, Encoder};
-use std::cast;
 use std::fmt;
 use std::path::BytesContainer;
+use std::mem;
 use std::rc::Rc;
 use std::strbuf::StrBuf;
 
@@ -585,7 +585,7 @@ fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
         // DST.
         unsafe {
             let this = self.get();
-            cast::transmute(this.container_as_bytes())
+            mem::transmute(this.container_as_bytes())
         }
     }
 }
index 8486a8aeb352c30eb5cee489e1b2b040a1adda60..71c2f6337e0e6cfd5e7f292115058a963787d6cf 100644 (file)
@@ -26,9 +26,9 @@
 use print::pp::{Breaks, Consistent, Inconsistent, eof};
 use print::pp;
 
-use std::cast;
 use std::io::{IoResult, MemWriter};
 use std::io;
+use std::mem;
 use std::rc::Rc;
 use std::str;
 use std::strbuf::StrBuf;
@@ -140,9 +140,9 @@ pub fn to_str(f: |&mut State| -> IoResult<()>) -> StrBuf {
         // FIXME(pcwalton): A nasty function to extract the string from an `io::Writer`
         // that we "know" to be a `MemWriter` that works around the lack of checked
         // downcasts.
-        let (_, wr): (uint, Box<MemWriter>) = cast::transmute_copy(&s.s.out);
+        let (_, wr): (uint, Box<MemWriter>) = mem::transmute_copy(&s.s.out);
         let result = str::from_utf8_owned(wr.get_ref().to_owned()).unwrap();
-        cast::forget(wr);
+        mem::forget(wr);
         result.to_strbuf()
     }
 }
index 7f85684572286fd05433cb563263065f9cd742ea..c3c9596bfc469f841ea189ebaf195c60b5a738cb 100644 (file)
 use ast::Name;
 
 use collections::HashMap;
-use std::cast;
 use std::cell::RefCell;
 use std::cmp::Equiv;
 use std::fmt;
 use std::hash::Hash;
+use std::mem;
 use std::rc::Rc;
 
 pub struct Interner<T> {
@@ -198,7 +198,7 @@ pub fn get_ref<'a>(&'a self, idx: Name) -> &'a str {
         let vect = self.vect.borrow();
         let s: &str = vect.get(idx as uint).as_slice();
         unsafe {
-            cast::transmute(s)
+            mem::transmute(s)
         }
     }
 
index 060c40b04d838ef9e712ebc210f9e6bcec91ce64..25188d699beb4c38b6e3c8686fffc46727eb28c6 100644 (file)
@@ -71,7 +71,7 @@ fn main() {
 extern crate rand;
 extern crate serialize;
 
-use std::cast::{transmute,transmute_copy};
+use std::mem::{transmute,transmute_copy};
 use std::char::Char;
 use std::default::Default;
 use std::fmt;
index 9e4d90e979ded9d0ee79249b91f276a6d7a05b00..0831993119ae829b2b5c7959a2b3669741767b19 100644 (file)
@@ -10,7 +10,7 @@
 
 // for this issue, this code must be built in a library
 
-use std::cast;
+use std::mem;
 
 trait A {}
 struct B;
@@ -20,6 +20,6 @@ fn bar<T>(_: &mut A, _: &T) {}
 
 fn foo<T>(t: &T) {
     let b = B;
-    bar(unsafe { cast::transmute(&b as &A) }, t)
+    bar(unsafe { mem::transmute(&b as &A) }, t)
 }
 
index c22c4014f47bf7c5a009b34ad84d3717f498d123..d9fbc08b3211dd39a9d5ad6bb15100ac2d8603c4 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 fn main() {
-    let x: Option<&[u8]> = Some("foo").map(std::cast::transmute);
+    let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
     //~^ ERROR: mismatched types
 }
index ac41cc116825a83cd2b9812cb62efc692b0dc022..4e0131a580128349e4f50450ff15f63c97cead87 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
+use std::mem;
 
 fn main() {
-    cast::transmute(0);  //~ ERROR: cannot determine a type for this expression: unconstrained type
+    mem::transmute(0);  //~ ERROR: cannot determine a type for this expression: unconstrained type
 }
index c74d80df5dc271a7bc7250db3b68f76ac201eb2e..45e6b76e200386aa2f9ad3df2f044e101e6d77c7 100644 (file)
@@ -15,7 +15,7 @@
 
 // error-pattern: transmute called on types with different size
 
-use std::cast;
+use std::mem;
 
 #[packed]
 struct Foo<T,S> {
@@ -31,7 +31,7 @@ struct Oof<T, S> {
 fn main() {
     let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
     unsafe {
-        let oof: Oof<[u8, .. 5], i32> = cast::transmute(foo);
+        let oof: Oof<[u8, .. 5], i32> = mem::transmute(foo);
         println!("{:?}", oof);
     }
 }
index b9a8a53469d5a8a5f7c23acb43f1e4bdcadd7bac..24be7d3a2972f8d9113a4adb4a01616c570fd6ae 100644 (file)
@@ -15,7 +15,7 @@
 
 // error-pattern: transmute called on types with different size
 
-use std::cast;
+use std::mem;
 
 #[packed]
 struct Foo {
@@ -31,7 +31,7 @@ struct Oof {
 fn main() {
     let foo = Foo { bar: 1, baz: 10 };
     unsafe {
-        let oof: Oof = cast::transmute(foo);
+        let oof: Oof = mem::transmute(foo);
         println!("{:?}", oof);
     }
 }
index 67c7eb30da6ed7917b19860cdcb08716a2d189ce..43d82e75c4dda0e516d160ce0f040702fe46390f 100644 (file)
@@ -32,8 +32,8 @@ enum AnotherNilEnum {}
 // 2. That gdb prints the string "{<No data fields>}" for empty structs (which may change some time)
 fn main() {
     unsafe {
-        let first: ANilEnum = std::cast::transmute(());
-        let second: AnotherNilEnum = std::cast::transmute(());
+        let first: ANilEnum = std::mem::transmute(());
+        let second: AnotherNilEnum = std::mem::transmute(());
 
         zzz();
     }
index b60c9c4a4b967b375b126dd76dbbe8c7e721ca2a..5c44703f6f2c90b712d394a3a5aaa115b1527903 100644 (file)
@@ -69,21 +69,21 @@ struct NamedFieldsRepr<'a> {
 
 fn main() {
 
-    let some: Option<&u32> = Some(unsafe { std::cast::transmute(0x12345678) });
+    let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678) });
     let none: Option<&u32> = None;
 
-    let full = Full(454545, unsafe { std::cast::transmute(0x87654321) }, 9988);
+    let full = Full(454545, unsafe { std::mem::transmute(0x87654321) }, 9988);
 
     let int_val = 0;
-    let empty: &MoreFieldsRepr = unsafe { std::cast::transmute(&Empty) };
+    let empty: &MoreFieldsRepr = unsafe { std::mem::transmute(&Empty) };
 
     let droid = Droid {
         id: 675675,
         range: 10000001,
-        internals: unsafe { std::cast::transmute(0x43218765) }
+        internals: unsafe { std::mem::transmute(0x43218765) }
     };
 
-    let void_droid: &NamedFieldsRepr = unsafe { std::cast::transmute(&Void) };
+    let void_droid: &NamedFieldsRepr = unsafe { std::mem::transmute(&Void) };
 
     zzz();
 }
index ecaae7f5cc72d5ed6f96f1c2ed88b8ba2298bf15..2044d6f1cc815c5083034c06eba31bf33ce3a041 100644 (file)
@@ -12,7 +12,7 @@
 
 #![feature(managed_boxes)]
 
-use std::cast;
+use std::mem;
 
 fn failfn() {
     fail!();
@@ -25,7 +25,7 @@ struct r {
 impl Drop for r {
     fn drop(&mut self) {
         unsafe {
-            let _v2: Box<int> = cast::transmute(self.v);
+            let _v2: Box<int> = mem::transmute(self.v);
         }
     }
 }
@@ -39,8 +39,8 @@ fn r(v: *int) -> r {
 fn main() {
     unsafe {
         let i1 = box 0;
-        let i1p = cast::transmute_copy(&i1);
-        cast::forget(i1);
+        let i1p = mem::transmute_copy(&i1);
+        mem::forget(i1);
         let x = @r(i1p);
         failfn();
         println!("{:?}", x);
index cb74a5eb240ab4f621fcea3a9a37a660514d12cf..d60cc05cc9f9cbeca66d87eb58550a75ac635c56 100644 (file)
@@ -11,6 +11,6 @@
 #![crate_type = "dylib"]
 extern crate both;
 
-use std::cast;
+use std::mem;
 
-pub fn addr() -> uint { unsafe { cast::transmute(&both::foo) } }
+pub fn addr() -> uint { unsafe { mem::transmute(&both::foo) } }
index ed8675eb7064fa508450a8bebebde0a1c8f17f77..8006987e9f349152d125f7aa4e651ce3ec74f659 100644 (file)
@@ -11,9 +11,9 @@
 extern crate dylib;
 extern crate both;
 
-use std::cast;
+use std::mem;
 
 fn main() {
-    assert_eq!(unsafe { cast::transmute::<&int, uint>(&both::foo) },
+    assert_eq!(unsafe { mem::transmute::<&int, uint>(&both::foo) },
                dylib::addr());
 }
index 3e3d9aab84e89dd584f7ae6ca376a6d228632f29..331e947586ab8fa160cc6a96f08be5d294020bb5 100644 (file)
@@ -48,9 +48,9 @@ fn test_box() {
 
 fn test_ptr() {
     unsafe {
-        let p1: *u8 = ::std::cast::transmute(0);
-        let p2: *u8 = ::std::cast::transmute(0);
-        let p3: *u8 = ::std::cast::transmute(1);
+        let p1: *u8 = ::std::mem::transmute(0);
+        let p2: *u8 = ::std::mem::transmute(0);
+        let p3: *u8 = ::std::mem::transmute(1);
 
         assert_eq!(p1, p2);
         assert!(p1 != p3);
@@ -82,8 +82,8 @@ fn test_class() {
 
   unsafe {
   println!("q = {:x}, r = {:x}",
-         (::std::cast::transmute::<*p, uint>(&q)),
-         (::std::cast::transmute::<*p, uint>(&r)));
+         (::std::mem::transmute::<*p, uint>(&q)),
+         (::std::mem::transmute::<*p, uint>(&r)));
   }
   assert_eq!(q, r);
   r.y = 17;
index de7bdd15fa25e7ac606ddf84df975451b8038399..202ec7edb1939e30745c076746806dd3ff73543e 100644 (file)
@@ -11,7 +11,7 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-use std::cast;
+use std::mem;
 use std::io::stdio::println;
 
 fn call_it(f: proc(~str) -> ~str) {
@@ -74,7 +74,7 @@ pub fn main() {
 
     call_cramped(|| 1, || unsafe {
         static a: uint = 100;
-        cast::transmute(&a)
+        mem::transmute(&a)
     });
 
     // External functions
index 5763c61379865a88fef04703b0a2b908a1b2420a..2a8293fcba8d0ec5e2e15790209c9d4b148cfe43 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
 use std::mem;
 
 fn addr_of<T>(ptr: &T) -> uint {
@@ -17,7 +16,7 @@ fn addr_of<T>(ptr: &T) -> uint {
 
 fn is_aligned<T>(ptr: &T) -> bool {
     unsafe {
-        let addr: uint = cast::transmute(ptr);
+        let addr: uint = mem::transmute(ptr);
         (addr % mem::min_align_of::<T>()) == 0
     }
 }
index 0c897b959a5a3412783e4a8105a137d3cfb80472..41e5381d73c2b727e1fd7939812a8a57b47845ad 100644 (file)
@@ -33,7 +33,7 @@ extern "C" fn foo(_x: uint) -> Foo { B }
 
 pub fn main() {
   unsafe {
-    let f: extern "C" fn(uint) -> u32 = ::std::cast::transmute(foo);
+    let f: extern "C" fn(uint) -> u32 = ::std::mem::transmute(foo);
     assert_eq!(f(0xDEADBEEF), B as u32);
   }
 }
index 147cfb16fa2fd3e3ab49ff43f2ebdde0a728503a..b56847b2da0d61b5b779136f71445640ae19f137 100644 (file)
@@ -10,7 +10,7 @@
 
 extern crate libc;
 
-use std::cast;
+use std::mem;
 use std::unstable::run_in_bare_thread;
 
 #[link(name = "rustrt")]
@@ -23,14 +23,14 @@ pub fn main() {
     unsafe {
         run_in_bare_thread(proc() {
             let i = &100;
-            rust_dbg_call(callback, cast::transmute(i));
+            rust_dbg_call(callback, mem::transmute(i));
         });
     }
 }
 
 extern fn callback(data: libc::uintptr_t) {
     unsafe {
-        let data: *int = cast::transmute(data);
+        let data: *int = mem::transmute(data);
         assert_eq!(*data, 100);
     }
 }
index 9227477c31e917aa6dadcc773d6a82ed6e731efe..1ac3602293807ddc614bad706c0dca91ca034952 100644 (file)
@@ -149,7 +149,7 @@ pub fn main() {
     // make sure that format! doesn't cause spurious unused-unsafe warnings when
     // it's inside of an outer unsafe block
     unsafe {
-        let a: int = ::std::cast::transmute(3u);
+        let a: int = ::std::mem::transmute(3u);
         format!("{}", a);
     }
 
index 5f5c1444819d21b9b998893ea80bfcac8fcea43f..752c9464cf62008776c05801e3661fdecb84e023 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast::transmute;
+use std::mem::transmute;
 
 mod rusti {
     extern "rust-intrinsic" {
index 1fa9fa8f4fb344098465ccf11ab7649fca289828..a319ee5e600cc5046bafbcb2252279a32377f810 100644 (file)
 
 extern crate libc;
 
-use std::cast;
+use std::mem;
 use libc::{c_double, c_int};
 
 fn to_c_int(v: &mut int) -> &mut c_int {
     unsafe {
-        cast::transmute_copy(&v)
+        mem::transmute_copy(&v)
     }
 }
 
index 2b1ba332841cb4115e6b380b9d99bba581d2807d..9636a61269cae710cae2c9f11c1f5b09e45b5973 100644 (file)
@@ -14,9 +14,9 @@
 // tjc: I don't know why
 pub mod pipes {
     use super::Task;
-    use std::cast::{forget, transmute};
-    use std::cast;
+    use std::mem::{forget, transmute};
     use std::mem::{replace, swap};
+    use std::mem;
     use std::task;
 
     pub struct Stuff<T> {
@@ -42,7 +42,7 @@ pub struct packet<T> {
 
     pub fn packet<T:Send>() -> *packet<T> {
         unsafe {
-            let p: *packet<T> = cast::transmute(box Stuff{
+            let p: *packet<T> = mem::transmute(box Stuff{
                 state: empty,
                 blocked_task: None::<Task>,
                 payload: None::<T>
@@ -60,7 +60,7 @@ mod rusti {
     // We should consider moving this to ::std::unsafe, although I
     // suspect graydon would want us to use void pointers instead.
     pub unsafe fn uniquify<T>(x: *T) -> Box<T> {
-        cast::transmute(x)
+        mem::transmute(x)
     }
 
     pub fn swap_state_acq(dst: &mut state, src: state) -> state {
@@ -165,7 +165,7 @@ fn drop(&mut self) {
             unsafe {
                 if self.p != None {
                     let self_p: &mut Option<*packet<T>> =
-                        cast::transmute(&self.p);
+                        mem::transmute(&self.p);
                     let p = replace(self_p, None);
                     sender_terminate(p.unwrap())
                 }
@@ -195,7 +195,7 @@ fn drop(&mut self) {
             unsafe {
                 if self.p != None {
                     let self_p: &mut Option<*packet<T>> =
-                        cast::transmute(&self.p);
+                        mem::transmute(&self.p);
                     let p = replace(self_p, None);
                     receiver_terminate(p.unwrap())
                 }
@@ -222,7 +222,7 @@ pub fn entangle<T:Send>() -> (send_packet<T>, recv_packet<T>) {
 }
 
 pub mod pingpong {
-    use std::cast;
+    use std::mem;
 
     pub struct ping(::pipes::send_packet<pong>);
     pub struct pong(::pipes::send_packet<ping>);
@@ -230,7 +230,7 @@ pub mod pingpong {
     pub fn liberate_ping(p: ping) -> ::pipes::send_packet<pong> {
         unsafe {
             let _addr : *::pipes::send_packet<pong> = match &p {
-              &ping(ref x) => { cast::transmute(x) }
+              &ping(ref x) => { mem::transmute(x) }
             };
             fail!()
         }
@@ -239,7 +239,7 @@ pub fn liberate_ping(p: ping) -> ::pipes::send_packet<pong> {
     pub fn liberate_pong(p: pong) -> ::pipes::send_packet<ping> {
         unsafe {
             let _addr : *::pipes::send_packet<ping> = match &p {
-              &pong(ref x) => { cast::transmute(x) }
+              &pong(ref x) => { mem::transmute(x) }
             };
             fail!()
         }
index e89e661e9d84778029818fc2ffc2dc311ac7202b..d96568df63a4dd57293ad9d85de76fac2a86ac10 100644 (file)
@@ -12,7 +12,7 @@
 
 extern crate libc;
 
-use std::cast::transmute;
+use std::mem::transmute;
 use libc::c_void;
 
 struct NonCopyable(*c_void);
index 04b2e94f1a0c7ff6bd74493aa6b0d25994d3ae79..fb61bea83da8d7e5c1521914e2e8a45d39b10c06 100644 (file)
@@ -10,7 +10,7 @@
 
 #![feature(macro_rules)]
 
-use std::{option, cast};
+use std::{option, mem};
 
 // Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions,
 // which "says that a destructor applied to an object built from a constructor
@@ -78,8 +78,8 @@ pub fn main() {
     check_type!(@19: @int);
     check_type!("foo".to_owned(): ~str);
     check_type!(vec!(20, 22): Vec<int> );
-    let mint: uint = unsafe { cast::transmute(main) };
+    let mint: uint = unsafe { mem::transmute(main) };
     check_type!(main: fn(), |pthing| {
-        assert!(mint == unsafe { cast::transmute(*pthing) })
+        assert!(mint == unsafe { mem::transmute(*pthing) })
     });
 }
index 8b20b8e14c483dbca59c17a5c3fbb3ecaa81de64..202697661582f75058b5dd1840c5fc69c9f86a8f 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
+use std::mem;
 
 #[packed]
 struct S<T, S> {
@@ -20,7 +20,7 @@ struct S<T, S> {
 pub fn main() {
     unsafe {
         let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 };
-        let transd : [u8, .. 9] = cast::transmute(s);
+        let transd : [u8, .. 9] = mem::transmute(s);
         // Don't worry about endianness, the numbers are palindromic.
         assert!(transd ==
                    [0xff, 0xff, 0xff, 0xff,
@@ -29,7 +29,7 @@ pub fn main() {
 
 
         let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16};
-        let transd : [u8, .. 4] = cast::transmute(s);
+        let transd : [u8, .. 4] = mem::transmute(s);
         // Again, no endianness problems.
         assert!(transd ==
                    [1, 2, 0b10000001, 0b10000001]);
index 0dc781805007e5593e5e33c754b0411443e924da..7f9bf8e7d57fe458602f22e9a1b63d2aeffd6c57 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
+use std::mem;
 
 #[packed]
 struct S4 {
@@ -25,11 +25,11 @@ struct S5 {
 pub fn main() {
     unsafe {
         let s4 = S4 { a: 1, b: [2,3,4] };
-        let transd : [u8, .. 4] = cast::transmute(s4);
+        let transd : [u8, .. 4] = mem::transmute(s4);
         assert!(transd == [1, 2, 3, 4]);
 
         let s5 = S5 { a: 1, b: 0xff_00_00_ff };
-        let transd : [u8, .. 5] = cast::transmute(s5);
+        let transd : [u8, .. 5] = mem::transmute(s5);
         // Don't worry about endianness, the u32 is palindromic.
         assert!(transd == [1, 0xff, 0, 0, 0xff]);
     }
index 0cdaeddf25db39ed087c84e3a5cca68969b429eb..3ec6182beb2615ab0dca92c94e10c75824b36108 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast;
+use std::mem;
 
 #[packed]
 struct S4(u8,[u8, .. 3]);
 pub fn main() {
     unsafe {
         let s4 = S4(1, [2,3,4]);
-        let transd : [u8, .. 4] = cast::transmute(s4);
+        let transd : [u8, .. 4] = mem::transmute(s4);
         assert!(transd == [1, 2, 3, 4]);
 
         let s5 = S5(1, 0xff_00_00_ff);
-        let transd : [u8, .. 5] = cast::transmute(s5);
+        let transd : [u8, .. 5] = mem::transmute(s5);
         // Don't worry about endianness, the u32 is palindromic.
         assert!(transd == [1, 0xff, 0, 0, 0xff]);
     }
index 742df0f5c6d87f60bd8f72aa654be60a482a2ea5..26bf06794ca0c215f4a67d5b30af8ac3a73c0fcc 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cast::transmute;
+use std::mem::transmute;
 
 mod a {
     extern {
index fabf4b7b42876aa02544918947f8761dd9a89662..7e071177ff9f1241246467a9bdf24113559a4888 100644 (file)
@@ -21,7 +21,6 @@
 
 use arena::Arena;
 use collections::HashMap;
-use std::cast;
 use std::mem;
 
 type Type<'tcx> = &'tcx TypeStructure<'tcx>;
index b0198d56e05a57b382299d1ab0204cb1a700221f..e6b997f758814475e30f21cc634ea1d7e782e048 100644 (file)
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 extern crate libc;
-use std::cast;
 use std::mem;
 
 struct arena(());
@@ -29,7 +28,7 @@ struct Ccx {
 
 fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> {
     unsafe {
-        cast::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
+        mem::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
             as libc::size_t))
     }
 }
@@ -42,7 +41,7 @@ fn g(fcx : &Fcx) {
     let bcx = Bcx { fcx: fcx };
     let bcx2 = h(&bcx);
     unsafe {
-        libc::free(cast::transmute(bcx2));
+        libc::free(mem::transmute(bcx2));
     }
 }
 
index 72f2917a2129acd75b0e404272fa2e36c2d2cfb1..a260ad66ce294c6bd4b0da36ae4552ef4119877b 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-linux #7340 fails on 32-bit linux
 // ignore-macos #7340 fails on 32-bit macos
 
-use std::cast;
+use std::mem;
 
 enum Tag<A> {
     Tag(A)
@@ -27,7 +27,7 @@ fn mk_rec() -> Rec {
 }
 
 fn is_8_byte_aligned(u: &Tag<u64>) -> bool {
-    let p: uint = unsafe { cast::transmute(u) };
+    let p: uint = unsafe { mem::transmute(u) };
     return (p & 7u) == 0u;
 }
 
index 70590b768b1d671e00a57d23e7ff76dfd147af04..1e22f0f3dee80d6a4fa6d303a7451152a1a28f6d 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-linux #7340 fails on 32-bit linux
 // ignore-macos #7340 fails on 32-bit macos
 
-use std::cast;
+use std::mem;
 
 enum Tag<A,B> {
     VarA(A),
@@ -30,7 +30,7 @@ fn mk_rec<A,B>(a: A, b: B) -> Rec<A,B> {
 }
 
 fn is_aligned<A>(amnt: uint, u: &A) -> bool {
-    let p: uint = unsafe { cast::transmute(u) };
+    let p: uint = unsafe { mem::transmute(u) };
     return (p & (amnt-1u)) == 0u;
 }
 
index 4c126d68fef90ad0375dc52865c48f9f40f89d24..f3996065936554e743c313536083853b36bdddbf 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-linux #7340 fails on 32-bit linux
 // ignore-macos #7340 fails on 32-bit macos
 
-use std::cast;
+use std::mem;
 
 enum Tag {
     Tag(u64)
@@ -27,7 +27,7 @@ fn mk_rec() -> Rec {
 }
 
 fn is_8_byte_aligned(u: &Tag) -> bool {
-    let p: uint = unsafe { cast::transmute(u) };
+    let p: uint = unsafe { mem::transmute(u) };
     return (p & 7u) == 0u;
 }
 
index 9cdcd8759527a3e543b414091094d3d6f0a67cf2..e070757eaf4ea1b2f04a40d7bb65db50809b5680 100644 (file)
@@ -13,6 +13,6 @@
 
 pub fn main() {
     unsafe {
-        ::std::cast::transmute::<[int,..1],int>([1])
+        ::std::mem::transmute::<[int,..1],int>([1])
     };
 }
index 953140fcfef928a2af87dd9ab9e6adcbc5229912..7f46b0ff6e797983bf5afa172c40523d48cda5a0 100644 (file)
 // unified with the type *T, and so the type variable
 // in that type gets resolved.
 
-use std::cast;
+use std::mem;
 
 fn null<T>() -> *T {
     unsafe {
-        cast::transmute(0)
+        mem::transmute(0)
     }
 }