From 4c08a8d6c31f55bfeed0ef0c2bf8b91f90415cfe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 23 Apr 2013 19:33:33 -0400 Subject: Removing more unnecessary unsafe blocks throughout --- src/libstd/arc.rs | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 8abe0262314..33aa6171de4 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -177,15 +177,13 @@ pub impl MutexARC { */ #[inline(always)] unsafe fn access(&self, blk: &fn(x: &mut T) -> U) -> U { - unsafe { - let state = get_shared_mutable_state(&self.x); - // Borrowck would complain about this if the function were - // not already unsafe. See borrow_rwlock, far below. - do (&(*state).lock).lock { - check_poison(true, (*state).failed); - let _z = PoisonOnFail(&mut (*state).failed); - blk(&mut (*state).data) - } + let state = get_shared_mutable_state(&self.x); + // Borrowck would complain about this if the function were + // not already unsafe. See borrow_rwlock, far below. + do (&(*state).lock).lock { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data) } } @@ -195,16 +193,14 @@ pub impl MutexARC { &self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { - unsafe { - let state = get_shared_mutable_state(&self.x); - do (&(*state).lock).lock_cond |cond| { - check_poison(true, (*state).failed); - let _z = PoisonOnFail(&mut (*state).failed); - blk(&mut (*state).data, - &Condvar {is_mutex: true, - failed: &mut (*state).failed, - cond: cond }) - } + let state = get_shared_mutable_state(&self.x); + do (&(*state).lock).lock_cond |cond| { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data, + &Condvar {is_mutex: true, + failed: &mut (*state).failed, + cond: cond }) } } } -- cgit 1.4.1-3-g733a5