about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2012-08-14 13:32:41 -0400
committerBen Blum <bblum@andrew.cmu.edu>2012-08-14 17:53:18 -0400
commit589ee65fd4ea311beeb42ebdc5e6a4b6960bd303 (patch)
treec4a96d2a6e076864ab160f9469d9fd18c872c422 /src/libcore
parent1779ab4754d71859306e11d9893d071c35ce691f (diff)
downloadrust-589ee65fd4ea311beeb42ebdc5e6a4b6960bd303.tar.gz
rust-589ee65fd4ea311beeb42ebdc5e6a4b6960bd303.zip
Add rw_arc.downgrade() + std and cfail tests. Tons of region FIXMEs... (cf #2282, #3154)
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/ptr.rs2
-rw-r--r--src/libcore/unsafe.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index c06f3f1d3a4..b7b63af0afb 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -152,7 +152,7 @@ fn to_uint<T>(thing: &T) -> uint unsafe {
 
 /// Determine if two borrowed pointers point to the same thing.
 #[inline(always)]
-fn ref_eq<T>(thing: &T, other: &T) -> bool {
+fn ref_eq<T>(thing: &a/T, other: &b/T) -> bool {
     to_uint(thing) == to_uint(other)
 }
 
diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs
index f8c6074abcf..f945cb8ad1d 100644
--- a/src/libcore/unsafe.rs
+++ b/src/libcore/unsafe.rs
@@ -1,6 +1,7 @@
 //! Unsafe operations
 
 export reinterpret_cast, forget, bump_box_refcount, transmute;
+export transmute_mut, transmute_immut, transmute_region, transmute_mut_region;
 
 export SharedMutableState, shared_mutable_state, clone_shared_mutable_state;
 export get_shared_mutable_state, get_shared_immutable_state;
@@ -53,6 +54,17 @@ unsafe fn transmute<L, G>(-thing: L) -> G {
     return newthing;
 }
 
+/// Coerce an immutable reference to be mutable.
+unsafe fn transmute_mut<T>(+ptr: &T) -> &mut T { transmute(ptr) }
+/// Coerce a mutable reference to be immutable.
+unsafe fn transmute_immut<T>(+ptr: &mut T) -> &T { transmute(ptr) }
+/// Coerce a borrowed pointer to have an arbitrary associated region.
+unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(ptr) }
+/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
+unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T {
+    transmute(ptr)
+}
+
 /****************************************************************************
  * Shared state & exclusive ARC
  ****************************************************************************/