From 43165b54e05d0640fda8cf419de09d9f6d032724 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 7 May 2013 12:57:28 -0400 Subject: [PATCH 1/2] rc: remove the managed pointer workaround --- src/libstd/rc.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 3eb480f9ea8..6f72d8dc16d 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -24,9 +24,9 @@ struct RcBox { } /// Immutable reference counted pointer type +#[non_owned] pub struct Rc { priv ptr: *mut RcBox, - priv non_owned: Option<@()> // FIXME: #5601: replace with `#[non_owned]` } pub impl<'self, T: Owned> Rc { @@ -35,7 +35,7 @@ pub impl<'self, T: Owned> Rc { let ptr = malloc(sys::size_of::>() as size_t) as *mut RcBox; assert!(!ptr::is_null(ptr)); intrinsics::move_val_init(&mut *ptr, RcBox{value: value, count: 1}); - Rc{ptr: ptr, non_owned: None} + Rc{ptr: ptr} } } @@ -64,7 +64,7 @@ impl Clone for Rc { fn clone(&self) -> Rc { unsafe { (*self.ptr).count += 1; - Rc{ptr: self.ptr, non_owned: None} + Rc{ptr: self.ptr} } } } @@ -113,9 +113,10 @@ struct RcMutBox { } /// Mutable reference counted pointer type +#[non_owned] +#[mutable] pub struct RcMut { priv ptr: *mut RcMutBox, - priv non_owned: Option<@mut ()> // FIXME: #5601: replace with `#[non_owned]` and `#[non_const]` } pub impl<'self, T: Owned> RcMut { @@ -124,7 +125,7 @@ pub impl<'self, T: Owned> RcMut { let ptr = malloc(sys::size_of::>() as size_t) as *mut RcMutBox; assert!(!ptr::is_null(ptr)); intrinsics::move_val_init(&mut *ptr, RcMutBox{value: value, count: 1, borrow: Nothing}); - RcMut{ptr: ptr, non_owned: None} + RcMut{ptr: ptr} } } @@ -171,7 +172,7 @@ impl Clone for RcMut { fn clone(&self) -> RcMut { unsafe { (*self.ptr).count += 1; - RcMut{ptr: self.ptr, non_owned: None} + RcMut{ptr: self.ptr} } } } From 96eb1e50a49ce24adf198458e3d09fcd1117a70f Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 7 May 2013 13:00:00 -0400 Subject: [PATCH 2/2] arc: mark RWARC as non-Const --- src/libstd/arc.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 98d7a01b928..6c39fa1f9dc 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -252,6 +252,7 @@ struct RWARCInner { lock: RWlock, failed: bool, data: T } * * Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested. */ +#[mutable] struct RWARC { x: SharedMutableState>, cant_nest: ()