From 044abef0e56f02c36cf93fd9572813c2b27f98af Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 8 May 2013 15:03:39 -0400 Subject: fix incorrect region code based on the old 'self also removes unnecessary casts from the RcMut implementation --- src/libstd/rc.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 6f72d8dc16d..815f03f4269 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -29,7 +29,7 @@ pub struct Rc { priv ptr: *mut RcBox, } -pub impl<'self, T: Owned> Rc { +pub impl Rc { fn new(value: T) -> Rc { unsafe { let ptr = malloc(sys::size_of::>() as size_t) as *mut RcBox; @@ -40,8 +40,8 @@ pub impl<'self, T: Owned> Rc { } #[inline(always)] - fn borrow(&self) -> &'self T { - unsafe { cast::transmute_region(&(*self.ptr).value) } + fn borrow<'r>(&'r self) -> &'r T { + unsafe { cast::copy_lifetime(self, &(*self.ptr).value) } } } @@ -119,7 +119,7 @@ pub struct RcMut { priv ptr: *mut RcMutBox, } -pub impl<'self, T: Owned> RcMut { +pub impl RcMut { fn new(value: T) -> RcMut { unsafe { let ptr = malloc(sys::size_of::>() as size_t) as *mut RcMutBox; @@ -136,7 +136,7 @@ pub impl<'self, T: Owned> RcMut { assert!((*self.ptr).borrow != Mutable); let previous = (*self.ptr).borrow; (*self.ptr).borrow = Immutable; - f(cast::transmute_region(&(*self.ptr).value)); + f(&(*self.ptr).value); (*self.ptr).borrow = previous; } } @@ -147,7 +147,7 @@ pub impl<'self, T: Owned> RcMut { unsafe { assert!((*self.ptr).borrow == Nothing); (*self.ptr).borrow = Mutable; - f(cast::transmute_mut_region(&mut (*self.ptr).value)); + f(&mut (*self.ptr).value); (*self.ptr).borrow = Nothing; } } -- cgit 1.4.1-3-g733a5