From 589ee65fd4ea311beeb42ebdc5e6a4b6960bd303 Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Tue, 14 Aug 2012 13:32:41 -0400 Subject: Add rw_arc.downgrade() + std and cfail tests. Tons of region FIXMEs... (cf #2282, #3154) --- src/libcore/ptr.rs | 2 +- src/libcore/unsafe.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/libcore') 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(thing: &T) -> uint unsafe { /// Determine if two borrowed pointers point to the same thing. #[inline(always)] -fn ref_eq(thing: &T, other: &T) -> bool { +fn ref_eq(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(-thing: L) -> G { return newthing; } +/// Coerce an immutable reference to be mutable. +unsafe fn transmute_mut(+ptr: &T) -> &mut T { transmute(ptr) } +/// Coerce a mutable reference to be immutable. +unsafe fn transmute_immut(+ptr: &mut T) -> &T { transmute(ptr) } +/// Coerce a borrowed pointer to have an arbitrary associated region. +unsafe fn transmute_region(+ptr: &a/T) -> &b/T { transmute(ptr) } +/// Coerce a borrowed mutable pointer to have an arbitrary associated region. +unsafe fn transmute_mut_region(+ptr: &a/mut T) -> &b/mut T { + transmute(ptr) +} + /**************************************************************************** * Shared state & exclusive ARC ****************************************************************************/ -- cgit 1.4.1-3-g733a5